blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
f3f4eca9cee37f6e1906840c088e1576421a0911 | fatimaalheeh/python_stack | /_python/assignments/users_with_bank_account.py | 2,858 | 4.28125 | 4 | class BankAccount:
interest=1
rate=1
balance=0
def __init__(self, int_rate=1, balance=0):
self.rate=int_rate
self.balance=balance
def deposit(self, amount):
self.balance+=amount
def withdraw(self, amount):
self.balance-=amount
def display_account_info(self):
... | true |
4690cd9ff624a71728980ad40c60d686da8fd5c0 | shrenik77130/Repo5Batch22PythonWeb | /#3_Python_Complex_Programs/Program15.py | 241 | 4.25 | 4 | #WAP to input three digit number and print its reverse
no = int(input("Enter 3 Digit Number :")) #276 -> 27 -> 2
rem=no%10 #6
rev=rem
no=no//10
rem=no%10 #7
rev=rev*10+rem
no=no//10
rem=no%10 #2
rev=rev*10+rem
print("Reverse = ",rev)
| true |
3833d1646b0470f64f8258265681cb1d098d9e39 | shrenik77130/Repo5Batch22PythonWeb | /#3_Python_Complex_Programs/Program10.py | 256 | 4.125 | 4 | #WAP to input two numbers and perform Swapping
a=int(input("Enter value of a :"))
b=int(input("Enter value of b :"))
print(f"value of a = {a} and value of b = {b}")
t=a
a=b
b=t
print("After interchange")
print(f"value of a = {a} and value of b = {b}")
| true |
55394cb82db15168880bdcddcfc2d3992bc2950b | shrenik77130/Repo5Batch22PythonWeb | /#4_IfElse_ConditionChecking/IfElseEx4.py | 375 | 4.1875 | 4 | '''
WAP to input any character and chek that entered character is vowel or consonent
'''
ch=input("Enter any Character :") #d
if ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u':
print(ch," is vowel")
else:
print(ch," is Consonent")
#Method-2
print("Using Method 2")
if ch in "aeiouAEIOU":
print(... | false |
2b44364a2d8bac7c9ac95bafe580d55e2e209613 | paris3200/AdventOfCode | /code/Y2015/D05.py | 2,562 | 4.15625 | 4 | import re
import string
if __name__ != "__main__":
from Y2015 import utils
else:
import utils
def check_three_vowels(text: str) -> bool:
"""Checks if the input text has 3 or more vowels [aeiou]."""
result = re.search("^(.*[aeuio].*){3,}$", text)
if result:
return True
else:
r... | true |
5ad40813a589481b8afa46844746a3eb6e4c9da6 | jessicagamio/calculator | /calculator.py | 2,605 | 4.15625 | 4 | """Calculator
>>> calc("+ 1 2") # 1 + 2
3
>>> calc("* 2 + 1 2") # 2 * (1 + 2)
6
>>> calc("+ 9 * 2 3") # 9 + (2 * 3)
15
Let's make sure we have non-commutative operators working:
>>> calc("- 1 2") # 1 - 2
-1
>>> calc("- 9 * 2 3") # 9 - (2 * 3)
3
>>> calc("/ 6 - 4 ... | true |
2e655cc1d809c964b90f44f24d76126547ca0bba | Seabagel/Python-References | /3-working-with-strings/6-counting-all-the-votes-function.py | 1,110 | 4.28125 | 4 | # Create an empty dictionary for associating radish names
# with vote counts
counts = {}
# Create an empty list with the names of everyone who voted
voted = []
# Clean up (munge) a string so it's easy to match against other strings
def clean_string(s):
return s.strip().capitalize().replace(" "," ")
# Check if s... | true |
407b01007f41aeb2f7a3d055a0492a2f19c539eb | Nemo1122/python_note | /Python笔记/python基础/内置函数/enumerate函数.py | 555 | 4.59375 | 5 | # enumerate
"""
enumerate()是python的内置函数
enumerate在字典上是枚举、列举的意思
对于一个可迭代的(iterable)/可遍历的对象(如列表、字符串),enumerate将其组成一个索引序列,
利用它可以同时获得索引和值
enumerate多用于在for循环中得到计数
"""
# for index, number in enumerate(range(10)):
# print(index, number)
# enumerate还可以接收第二个参数,用于指定索引起始值
for index, number in enumerate(rang... | false |
69b8ecf656173add61531024d7d8ed636e7f6f2b | maiwen/LeetCode | /Python/739. Daily Temperatures.py | 1,904 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on 2018/7/16 15:22
@author: vincent
Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.
For example, give... | true |
a8141241380818f22c3f8a0f6285a247e01d11ce | NRJ-Python/Learning_Python | /Ch3/dates_start.py | 923 | 4.5 | 4 | #
# Example file for working with date information
# (For Python 3.x, be sure to use the ExampleSnippets3.txt file)
from datetime import date
from datetime import time
from datetime import datetime
def main():
#Date Objects
#Get today's date from today() method from date class
today=date.today()
print("Today's date ... | true |
06f466b42e1bf98c87524ce271dbaa86356fdbe0 | decodificar/EstruturaDeDados | /Aula02/e1_maximo.py | 1,804 | 4.125 | 4 |
'''
defina uma funcao maximo2 que recebe dois numeros e retorna o maior deles
'''
def maximo2(a, b):
if a > b:
return a
return b
'''
defina uma funcao maximo3 que recebe três numeros e retorna o maior deles
'''
def maximo3(a, b, c):
m = maximo2(a, b)
if m > c:
return m
return c
''... | false |
ce8e850c1b992acfacce608077bca948c4f33373 | AlexDamiao86/python-projects | /Battleship.py | 1,142 | 4.1875 | 4 | from random import randint
board = []
#Inicializa um array com 5 posições com "O"
ocean = ["O"] * 5
#Inicializa a matriz de duas dimensões
for i in range(5):
board.append(ocean)
def print_board(board):
for row in board:
print(" ".join(row))
def random_row(board):
row = randint(0, len(board) - 1)... | false |
ff407d313085cd40426d61ffc481ffc44acb0f71 | srczhou/ProficientPython | /palindrome_linked_list.py | 2,355 | 4.21875 | 4 | #!/usr/bin/env python3
import sys
class ListNode:
def __init__(self, data=0, next_node=None):
self.data = data
self.next = next_node
#from reverse_linked_list_iterative import reverse_linked_list
def reverse_singly_list(L):
if not L:
return None
dummy_head = ListNode(0, L)
whil... | true |
4d3751389ef8147c17e6bb43da20015a41761864 | narnat/leetcode | /sort_list/sort_list.py | 2,728 | 4.15625 | 4 | #!/usr/bin/env python3
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
""" Regular recursive solution"""
def sortList(self, head: ListNode) -> ListNode:
if head is None or head.next is None:... | true |
90cdd14aa9dfef098b62b74116c000ad29a9783e | Bryan1998/python | /year-2/convert-km-mi.py | 532 | 4.1875 | 4 | # convert-km-mi.py bph
def print_menu():
print('1: Kilometers to Miles')
print('2: Miles to Kilometers')
def converter(selector):
if selector == 1:
distance = float(input('Enter a distance in Kilometers: '))
math = distance / 1.60934
elif selector == 2:
distance = float(input('Enter a distance in Miles: '))... | false |
a7198cf7640343771137bec333d57f8b777301b1 | Lyubov-smile/SEP | /Data/task24.py | 499 | 4.4375 | 4 | # 24. Write a Python program to print the elements of a given array.
Sample array : ["Ruby", 2.3, Time.now]
import sys
sv = (sys.version)
sv1 = sv[0:6]
print(sv)
print(sv1,"\n")
import datetime
import array
now = datetime.datetime.now()
dt = datetime.datetime.now().strftime("%H.%M")
print(dt, type(dt))
dt1 = floa... | true |
48f6dc47d99b3f3e679c12a02c44af0edc9885c7 | Lyubov-smile/SEP | /Statements_syntax/task23.py | 696 | 4.25 | 4 | # 23. Write a Python program to check whether a given value appears everywhere in a given array.
# A value is "everywhere" in an array if it presents for every pair of adjacent elements in the array.
n = int(input('Input the length of your array: '))
if n < 1:
print("The length of array can't be less than 1!")
ar... | true |
0ea8922947d6f6b578adf79034feb4af42f49620 | Lyubov-smile/SEP | /Statements_syntax/task14.py | 474 | 4.28125 | 4 | # 14. Write a Python program to check if a given array of integers contains 3 twice, or 5 twice.
n = int(input('Input the length of your array: '))
if n < 1:
print("The length of array can't be less than 1!")
arr = []
for i in range(n):
arr.append(int(input('Input an integer element of array: ')))
if arr.cou... | true |
29a7e843519581a67df4ac8a22a3c24512b17662 | Lyubov-smile/SEP | /Data/task04.py | 267 | 4.46875 | 4 | # 4. Write a Python program which accepts the radius of a circle from the user and compute the parameter and area.
r = float(input('Input the radius of a circle: '))
import math
p = 2 * r * math.pi
s = r ** 2 * math.pi
print('P=', p, sep='')
print('S=', s, sep='')
| true |
787360a936fa50633e29dac47347e9c49fb8a520 | Lyubov-smile/SEP | /Statements and syntax/task22.py | 360 | 4.375 | 4 | # 22. Write a Python program to check whether every element is a 3 or a 5 in a given array of integers.
arr = [3, 5, 3, 5, 3]
#[1, 3, 5, 2, 7, 5]
for i in range(len(arr)):
if arr[i] == 3 or arr[i] == 5:
i += 1
inf = 'Every element in array = 3 or 5'
else:
inf = 'Not every element in a... | true |
26100f9023f28861bcb35b8a5fbc20f26bcd15c4 | Lyubov-smile/SEP | /Statements_syntax/task17.py | 427 | 4.375 | 4 | # 17. Write a Python program to get the number of even integers in a given array.
n = int(input('Input the length of your array: '))
if n < 1:
print("The length of array can't be less than 1!")
arr = []
for i in range(n):
arr.append(int(input('Input an integer element of array: ')))
n = 0
for i in range(len(... | true |
a45b7b1ea7b5f9ab8d48c6507cd1d9c2f1d57f34 | Lyubov-smile/SEP | /Statements and syntax/task23.py | 425 | 4.21875 | 4 | # 23. Write a Python program to check whether a given value appears everywhere in a given array.
# A value is "everywhere" in an array if it presents for every pair of adjacent elements in the array.
arr = [1, 3, 5, 2, 7, 5]
value = 3
for i in range(len(arr)):
if arr[i] == 3:
i += 1
inf = 'Every e... | true |
507e355168f72472d5b189bb95e9783c6539e554 | 1877762890/python_all-liuyingyign | /day05任务及课上代码/代码/day05/demo/demo1.py | 1,153 | 4.28125 | 4 | '''
python:
56,23,25:整型(int)
56.31:浮点数据(float,double)
"hello world" "刘嘉伟":字符串(str)
True,False:布尔(boolean)
元组:(1,4,5,6,6,8,2,10) 不可能在改变
列表:[1,2,3,4,5,6,65,5,47] 数据可以随时改变
字典:{
"010":"南京",
"020":"上海",
... | false |
62683c96cca30403c196eaf641b2e3e712cb1a1b | Max-Rider/basic-number-guessing-game | /number_guesser.py | 952 | 4.25 | 4 | # Maxwell Rider
# September 23 2020
# A very simple number guessing game where you guess a number between 1 and 100
# and the computer tells you if its too high or too low
# This is simply to help boost my python knowledge as I am very much a beginner as of writting this
from __future__ import print_function
... | true |
dcfe96e876467e66b04247b2bf6b5cd0222b826f | avielz/self.py_course_files | /hangman_project/5.5.1.py | 1,823 | 4.28125 | 4 | #hangman code learning python
HANGMAN_ASCII_ART = ("""Welcome to the game Hangman\n _ _
| | | |
| |__| | __ _ _ __ __ _ _ __ ___ __ _ _ __
| __ |/ _` | '_ \ / _` | '_ ` _ \ / _` | '_ \'
| | | | (_| | | | | (_| | | | | | | (_| | | | |
|_| |_|\__,_|_| |_|\__, |_| |_| |_|\__,_|_| |_|
__/ ... | false |
be28e73a27607679fa8b6a87bc7c8f7c44279367 | avielz/self.py_course_files | /self.py-unit6 lists/6.1.2.py | 579 | 4.28125 | 4 |
def shift_left(my_list):
"""Shift items in the list to the left.
:param my_list: the list with the items
:param last_item: will get the last item from my list
:type my_list: list
:type last_item: string
:return: The list with the items shifted to the left
:rtype: list
"""
last_item = my_... | true |
2cf335bf134fe8301e05aa9c60ef03d154be10ab | nicholasji/IS211_Assignment1 | /assignment1_part1.py | 1,098 | 4.21875 | 4 | #!usr/bin/env python
# -*- coding: utf-8 -*-
"""Week 1 Part 1"""
class ListDivideException(Exception):
"""Exception"""
def listDivide(numbers, divide=2):
"""Divisible by divide.
Args:
numbers(list): a list of numbers
divide(integer): a divisor integer default set to 2
Return... | true |
2e88aa71a50bec39e0c64b8466c2f5bc888b7340 | delacruzfranklyn93/Python--Challenge | /PyBank/Bank.py | 2,486 | 4.1875 | 4 | # import libraries
import os
import csv
# Declare the variable that you think you might be using
months = 0
net_total = 0
avg_change = []
greatest_increase = 0
greatest_decrease = 0
current = 0
past = 0
month_increase = ""
month_decrease = ""
# Read in the data into a list
csv_path = os.path.join( "Resources", "b... | true |
9fac2d1b600b43bb2e9842ca5028532f5b6feb1b | icimidemirag/GlobalAIHubPythonCourse | /Homeworks/HW1.py | 542 | 4.4375 | 4 | #Create two lists. The first list should consist of odd numbers. The second list is also of even numbers.
#Merge two lists. Multiply all values in the newlist by 2.
#Use the loop to print the data type of the all values in the new list.
#Question 1
oddList = [1,3,5,7,9]
evenList = [0,2,4,6,8]
oddList.extend(evenList)... | true |
c17b1ed61bb9753fcae4633bb059af8f5ffba1e1 | BhargavKadali39/Python_Data_Structure_Cheat_Sheet | /anti_duplicator_mk9000.py | 474 | 4.125 | 4 | List_1 = [1,1,1,2,3,4,4,4,5,5,6,6]
'''
# The old method
List_2 = []
for i in List_1:
if i not in List_2:
List_2.append(i)
print(List_2)
# Still this old method is faster than the other.
# Execution time is: 0.008489199999999975
# That much doesn't matter much,not in the case while working with big amount... | true |
9e10430c18dbdc82851fa9e58dacfb435b749b5e | Dillonso/bio-django | /ReverseComplement/process.py | 547 | 4.25 | 4 | # reverseComplement() function returns the revurse complement of a DNA sequence
def reverseComplement(stringInput):
# Reverse the input
string = stringInput[::-1].upper()
# define pairs dict
pairs = {
'A':'T', 'T':'A',
'G':'C', 'C':'G'
}
# Turn string into list
_list = list(string)
# Define a new emp... | true |
5e55d26cb147fcb6afba6d672328471a00c39dc5 | compwron/euler_py | /euler9.py | 463 | 4.25 | 4 | # A Pythagorean triplet is a set of three natural numbers, a b c, for which,
# a2 + b2 = c2
# For example, 32 + 42 = 9 + 16 = 25 = 52.
# There exists exactly one Pythagorean triplet for which a + b + c = 1000.
# Find the product abc.
def pythagorean_triplet_adds_up_to(number):
for a in range(1, number -1):
for ... | false |
0f89dafea5460e09641fde03a3bba3f8571e4641 | arjunreddy-001/DSA_Python | /Algorithms/CountdownUsingRecursion.py | 294 | 4.25 | 4 | # use recursion to implement a countdown timer
def countdown(x):
if x == 0:
print("Done!")
return
else:
print(x, "...")
countdown(x - 1)
print("foo") # this code will execute after we reach the top of call stack
countdown(5)
| true |
ffbcd78e46dbb32c172ee980f837c5c32d3a118f | jkorstia/Intro2python | /population.py | 1,284 | 4.125 | 4 | # a program to calculate population size after a user specified time (in years)
# demographic rates are fixed, initial population size is 307357870 selfie taking quokkas
# This script is designed to model quokka populations! Use with other species at your own risk.
# ask user for number of years (inputs as string)
yr... | true |
673d177a709a5c019892d42b8579b12e6d13c790 | alexwolf22/Python-Code | /Cities QuickSort/quicksort.py | 1,203 | 4.34375 | 4 | #Alex Wolf
#Quicksort Lab
#functions that swaps two elements in a list based off indexs
def swap(the_list,x,y):
temp=the_list[x]
the_list[x]=the_list[y]
the_list[y]=temp
#partition function that partitions a list
def partition(the_list, p, r, compare_func):
pivot =the_list[r] #sets pivot to last ... | true |
60fab78905611616e336ccd8a320332099302905 | jjinho/rosalind | /merge_sort_two_arrays/main.py | 1,755 | 4.15625 | 4 | #!/usr/bin/python3
"""
Merge Sort Two Arrays
Given: A positive integer n <= 10^5 and a sorted array A[1..n] of integers
from -10^5 to 10^5, a positive integer m <= 10^5 and a sorted array B[1..m] of
integers from -10^5 to 10^5.
Return: A sorted array C[1..n+m] containing all the elements of A and B.
"""
def main():... | true |
d239f0a21759c9cc3275d87c740fca7a525a094c | jjinho/rosalind | /insertion_sort/main.py | 1,028 | 4.4375 | 4 | #!/usr/bin/python3
"""
Insertion Sort
Given: A positive ingeter n <= 10^3 and an array A[1..n] of integers.
Return: The number of swaps performed by insertion sort algorithm on A[1..n].
"""
def main():
n = 0 # number of integers in array A
array = []
# Parse in.txt
with open('./in.txt') as f:
... | true |
17c1ead3976a4f33a8a101096a3b963f722d95ed | gutnikvk/learning_python | /gvk/fibonacci/better_alg.py | 436 | 4.125 | 4 | def check_input_number(n):
if n < 0: raise ValueError('It has to be >= 0')
def get_fibonacci_number(n):
fibonacciRow = []
for i in range(n+1):
if i<=1: fibonacciRow.append(i)
else: fibonacciRow.append(fibonacciRow[i-1] + fibonacciRow[i-2])
return fibonacciRow[n]
if __name__ == '__mai... | false |
1df31164bee68d1f7a3d824d820f9be602797b3f | ziyang-zh/pythonds | /01_Introduction/01_03_input_and_output.py | 741 | 4.15625 | 4 | #input and output
#aName=input('Please enter your name: ')
aName="David"
print("Your name in all capitals is",aName.upper(),"and has length",len(aName))
#sradius=input("Please enter the radius of the circle ")
radius=2
radius=float(radius)
diameter=2*radius
print(diameter)
#format string
print("Hello")
print("Hello",... | true |
5cf1d1d96e8ea34205a206273b8e8eb7e1a466ca | prohodilmimo/turf | /packages/turf_helpers/index.py | 2,552 | 4.34375 | 4 | from numbers import Number
factors = {
"miles": 3960,
"nauticalmiles": 3441.145,
"degrees": 57.2957795,
"radians": 1,
"inches": 250905600,
"yards": 6969600,
"meters": 6373000,
"metres": 6373000,
"kilometers": ... | true |
7efe282d6ded5d17da05d420c71f7963be4dc419 | alexacanaan23/COSC101 | /hw03_starter/hw03_turtleword.py | 1,619 | 4.34375 | 4 | # ----------------------------------------------------------
# -------- HW 3: Part 3.1 ---------
# ----------------------------------------------------------
# ----------------------------------------------------------
# Please answer these questions after you have completed this
# program
# -... | true |
83c64368ab1d5b532f42d8a792f6e60c8b195f3c | AndriiSotnikov/py_fcsv | /fcsv.py | 462 | 4.28125 | 4 | """There is a CSV file containing data in this format: Product name, price, quantity
Calculate total cost for all products."""
import csv
def calc_price(filename: str, open_=open) -> float:
"""Multiply every second and third element in the row, and return the sum"""
with open_(filename, 'rt') as file:
... | true |
22815c71694d907bb322a2ef02f73bd2d617856d | newbieeashish/LeetCode_Algo | /3rd_30_questions/ConstructTheRectangle.py | 1,202 | 4.34375 | 4 | '''
For a web developer, it is very important to know how to design a
web page's size. So, given a specific rectangular web page’s area,
your job by now is to design a rectangular web page, whose length
L and width W satisfy the following requirements:
1. The area of the rectangular web page you designed must ... | true |
e0e976dd9ec32a240382544cb36bf2f42a59a0df | newbieeashish/LeetCode_Algo | /1st_100_questions/TransposeMatrix.py | 456 | 4.46875 | 4 | '''
Given a matrix A, return the transpose of A.
The transpose of a matrix is the matrix flipped over it's main diagonal,
switching the row and column indices of the matrix.
Example 1:
Input: [[1,2,3],[4,5,6],[7,8,9]]
Output: [[1,4,7],[2,5,8],[3,6,9]]
Example 2:
Input: [[1,2,3],[4,5,6]]
Output: [[1,4],[... | true |
884106b89d0e1bf8b34f22c55e53894f8b587191 | newbieeashish/LeetCode_Algo | /1st_100_questions/ShortestCompletingWord.py | 1,714 | 4.40625 | 4 | '''
Find the minimum length word from a given dictionary words, which has all the
letters from the string licensePlate. Such a word is said to complete the
given string licensePlate
Here, for letters we ignore case. For example, "P" on the licensePlate still
matches "p" on the word.
It is guaranteed an ans... | true |
a788778604536cd38c6f74e26c982157cd874fb0 | newbieeashish/LeetCode_Algo | /1st_100_questions/SelfDividingNumber.py | 1,010 | 4.21875 | 4 | '''
A self-dividing number is a number that is divisible by every digit it contains.
For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0,
and 128 % 8 == 0.
Also, a self-dividing number is not allowed to contain the digit zero.
Given a lower and upper number bound, output a list of ... | true |
86e19e215343fe545217ee67a4ea91ca28d2720c | newbieeashish/LeetCode_Algo | /1st_100_questions/CountLargestGroup.py | 889 | 4.34375 | 4 | '''
Given an integer n. Each number from 1 to n is grouped according to the sum of
its digits.
Return how many groups have the largest size.
Example 1:
Input: n = 13
Output: 4
Explanation: There are 9 groups in total, they are grouped according sum of its
digits of numbers from 1 to 13:
[1,10], [2,11]... | true |
ee428ee38ebe0ee081d7c0c3ebd982d6fa2c7649 | newbieeashish/LeetCode_Algo | /1st_100_questions/SubtractProductAndSumOfDigit.py | 656 | 4.21875 | 4 | '''
Given an integer number n, return the difference between the product of its
digits and the sum of its digits.
Example 1:
Input: n = 234
Output: 15
Explanation:
Product of digits = 2 * 3 * 4 = 24
Sum of digits = 2 + 3 + 4 = 9
Result = 24 - 9 = 15
Example 2:
Input: n = 4421
Output: 21
Expla... | true |
f1a7ee2726ef7de780efc31ba89d0e4e785036ee | newbieeashish/LeetCode_Algo | /1st_100_questions/ReverseWordsInSring3.py | 378 | 4.21875 | 4 | '''
Given a string, you need to reverse the order of characters in each word
within a sentence while still preserving whitespace and initial word order.
Example 1:
Input: "Let's take LeetCode contest"
Output: "s'teL ekat edoCteeL tsetnoc"
'''
def ReverseWords(s):
return ' '.join([w[::-1] for w in s.split... | true |
0305df4441a66096b9af78d25eff6892e76fdad1 | newbieeashish/LeetCode_Algo | /1st_100_questions/MinAbsoluteDiff.py | 976 | 4.375 | 4 | '''
Given an array of distinct integers arr, find all pairs of elements with the
minimum absolute difference of any two elements.
Return a list of pairs in ascending order(with respect to pairs),
each pair [a, b] follows
a, b are from arr
a < b
b - a equals to the minimum absolute difference of any two el... | true |
d15a64e9e07b8d528a42553c1a10ec070707b7ce | rob-kistner/modern-python | /orig_py_files/input.py | 218 | 4.28125 | 4 | """ ------------------------------
USER INPUT
------------------------------ """
# to get user input, just use the input() command...
answer = input("What's your favorite color? ")
print(f"you said {answer}")
| true |
fdd2452fb771381589ba1aba38a9614c38eb0e60 | olamiwhat/Algos-solution | /Python/shipping_cost.py | 1,798 | 4.34375 | 4 | #This program calculates the cheapest Shipping Method
#and Cost to ship a package at Sal's shipping
weight = int(input("Please, enter the weight of your package: "))
#define premium shipping cost as a variable
premium_shipping = 125.00
#Function to calculate cost of ground shipping
def ground_shipping (weight):
flat... | true |
9410bcb027d9e094a401b37f04d02058109e6ae8 | eduards-v/python_fundamentals | /newtons_square_root_problem.py | 573 | 4.125 | 4 | import math
x = 60 # a number to be square rooted
current = 1 # starting a guess of a square root value from 1
# function that returns a value based on a current guess
def z_next(z):
return z - ((z*z - x) / (2 * z)) # Newton's formula for calculating square root of a number
while current != z_next(current):
c... | true |
42c76cf495a75abc3db6ad82e690903c9eced113 | paco-portada/Python | /Python basico/arraysPython/unidimensionalesPython/ejercicio8.py | 644 | 4.125 | 4 | # -*- coding: utf-8 -*-
# ejercicio8.py
# Programa que pide la temperatura media que ha hecho en cada mes
# de un determinado año y muestra a continuación un diagrama de barras
# horizontales con esos datos. Las barras del diagrama se dibujan a base
# de asteriscos.
# entrada de datos
year = []
for i in range... | false |
f8466ceffa16b50353709259db1a57ae1e3c9814 | paco-portada/Python | /Python basico/secuencialesPython/ejercicio12.py | 595 | 4.21875 | 4 | # ejercicio12.py
# Pide al usuario dos pares de números x1,y2 y x2,y2,
# que representen dos puntos en el plano.
# Calcula y muestra la distancia entre ellos.
# @author Alvaro Garcia Fuentes
from math import sqrt
print( "Datos del primer punto." )
x1 = ( float( input( "Introduzca x1: " ) ) )
y1 = ( float... | false |
14dada3e093e658d0125a68a3521358f1d7d1a0d | kapis20/IoTInternships | /GPS/GPS_four_bytes.py | 1,494 | 4.125 | 4 | from decimal import Decimal
"""
Works similarly to the three byte encoder in that it will only work if the point
is located within that GPS coordinate square of 53, -1. Note that this is a far
larger area than could be transmitted by the three byte version. The encoder
strips the gps coordinates (Ex. 53.342, -1.445 -> ... | true |
7a66249816da377c1e4b76a361dcce543496ae65 | RashmiVin/my-python-scripts | /Quiz.py | 995 | 4.34375 | 4 | #what would the code print:
def thing():
print('Hello')
print('There')
#what would the code print:
def func(x):
print(x)
func(10)
func(20)
#what would the code print:
def stuff():
print('Hello')
return
print('World')
stuff()
#what would the code print:
def greet(lang):
if lang == 'es':
... | true |
708fd980e7acf93a457e282fd6f607ac61cea6cd | ksvtmb/python | /dz2/coin.py | 621 | 4.15625 | 4 | # подбрось монетку 100 раз и посчитай, сколько решек а сколько орлов
# переменные решек и орлов создать ты должен, падаван
reshka=0
orel=0
count=100
import random
while True:
guess=random.randint(0,1)
if guess==0:
reshka+=1
else:
orel+=1
# print (count)
count-=1
if count==0:
... | false |
8ad708f6ce4fc9fd48d76271f246a69685bd4024 | ksvtmb/python | /annag.py | 1,000 | 4.125 | 4 | # игра в слова по анаграма
import random
# константа
WORDS=("питон","гадюка", "кобра","мамба")
# выбираем один элемент с кортежа рандомно
word=random.choice(WORDS)
# записываем корректное выбраное словов в отдельную переменную
correct=word
# пустая анаграма
jumble=""
# начинаем цикл
while word:
position=random.r... | false |
9cb4a5716496f51d2fe167c7431e4e12e3647bff | money1won/Read-Write | /Read_Write EX_1.py | 591 | 4.375 | 4 | # Brief showing of how a file reads, writes, and appends
file = open("test.txt","w")
file.write("Hello World")
file.write("This is our new text file")
file.write("New line")
file.write("This is our new text file")
file.close
# Reads the entire file
# file = open("test.txt", "r")
# print(file.read())
... | true |
c2e1286123bab6e5e179d7f815ee62c763bf37fb | Jidnyesh/pypass | /pypass.py | 1,237 | 4.3125 | 4 | """
This is a module to generate random password of different length for your project
download this or clone and then from pypass import randompasswordgenerator
"""
import random
#String module used to get all the upper and lower alphabet in ascii
import string
#Declaring strings used in password
special_... | true |
5c67c7ebcf9390eb22bd0a7d951ee3e8ceb0ba42 | 61a-su15-website/61a-su15-website.github.io | /slides/09.py | 961 | 4.125 | 4 | def sum(lst):
"""Add all the numbers in lst. Use iteration.
>>> sum([1, 3, 3, 7])
14
>>> sum([])
0
"""
"*** YOUR CODE HERE ***"
total = 0
for elem in lst:
total += elem
return total
def count(d, v):
"""Return the number of times v occurs as
a value in dictionary... | true |
46abc1d446933a99fdab6df2a4c6b6b51495b625 | jorgecontreras/algorithms | /binary_search_first_last_index.py | 2,936 | 4.34375 | 4 |
# Given a sorted array that may have duplicate values,
# use binary search to find the first and last indexes of a given value.
# For example, if you have the array [0, 1, 2, 2, 3, 3, 3, 4, 5, 6]
# and the given value is 3, the answer will be [4, 6]
# (because the value 3 occurs first at index 4 and last at index 6... | true |
5af3949f1989ce98cb9c7e207eb5ff7453caa6c0 | jasha64/jasha64 | /Spring 2019/Python/5.31/带两颗星的形参.py | 406 | 4.1875 | 4 | #带两个星号参数的函数传入的参数存储为一个字典(dict),并且在
#调用时采取 key1 = value1, key2 = value2, ... 的形式。
#由于传入的参数个数不定,所以当与普通参数一同使用时,必须把带星号的参
#数放在最后。
#def demo(p):
def demo(**p):
for item in p.items():
print(item)
#demo({'x':1, 'y':2, 'z':3})
demo(x=1, y=2, z=3)
| false |
a67ff64f4cf8dfc80b5fae725f50e9bbbd9f3c86 | shahp7575/coding-with-friends | /Parth/LeetCode/Easy/rotate_array.py | 889 | 4.15625 | 4 | """
Runtime: 104 ms
Memory: 33 MB
"""
from typing import List
class Solution:
"""
Problem Statement:
Given an array, rotate the array to the right by k steps, where k is non-negative.
Input: nums = [1,2,3,4,5,6,7], k = 3
Output: [5,6,7,1,2,3,4]
Explanation:
rotate 1 steps to the right: [7... | true |
78a3034cbd3d459797a10a91cd52cd244a12cc05 | jinjuleekr/Python | /problem143.py | 466 | 4.21875 | 4 | #Roof
#Problem143
#Running the roof until the input is either even or odd
while True:
num_str = input("Enter the number : ")
if num_str.isnumeric():
num = int(num_str)
if num==0:
print("It's 0")
continue
elif num%2==1:
print("odd number")
... | true |
7a12958150d9f5d253e5f12de3feb7c879a21368 | DanyT011/EjerciciosExercism | /raindrops/raindrops.py | 753 | 4.21875 | 4 | def convert(number):
number = (int(input("Type the Number: ")))
if (number % 3 == 0 and number % 5 == 0 and number % 7 ==0):
return print('PlingPlangPlong')
else:
if (number % 3 == 0 and number % 5 == 0):
return print("PlingPlang")
elif (number % 3 == 0 and number % 7 =... | false |
279bb6837788f7a7cb77797940c35e9317891fbc | nagask/leetcode-1 | /310 Minimum Height Trees/sol2.py | 1,631 | 4.125 | 4 | """
Better approach (but similar).
A tree can have at most 2 nodes that minimize the height of the tree.
We keep an array of every node, with a set of edges representing the neighbours nodes.
We also keep a list of the current leaves, and we remove them from the tree, updating the leaf list.
We continue doing so until ... | true |
1d90053bbdce1a1c82312d77f0ee4f98e5fc3c2b | nagask/leetcode-1 | /25 Reverse Nodes in k-Group/sol2.py | 2,593 | 4.15625 | 4 | """
Reverse a linked list in groups of k nodes.
Before doing so, we traverse ahead of k nodes from the current point, to know wehre the next reverse will start.
The function `get_kth_ahead` returns the k-th node ahead of the current position (can be null) and a boolean indicating whether there are at list k nodes afte... | true |
5101c36f61e29a8015a67afacdb7c6927e0b3514 | SwagLag/Perceptrons | /deliverables/P3/Activation.py | 991 | 4.46875 | 4 | # Activation classes. The idea is as follows;
# The classes should have attributes, but should ultimately be callable to be used in the Perceptrons, in order
# to return an output.
# To this end, make sure that implemented classes have an activate() function that only takes a int or float input
# and outputs a int or ... | true |
01da994ca131afa3e8adcc1ff14e92ca5285f376 | tanmaysharma015/Tanmay-task-1 | /Task1_Tanmay.py | 657 | 4.3125 | 4 | matrix = []
interleaved_array = []
#input
no_of_arrays = int(input("Enter the number of arrays:")) #this will act as rows
length = int(input("Enter the length of a single array:")) #this will act as columns
print(" \n")
for i in range(no_of_arrays): # A for loop for row entries
a =[]
print("e... | true |
31f5fd00943b1cd8f750fec37958e190b6f2a041 | aanzolaavila/MITx-6.00.1x | /Final/problem3.py | 551 | 4.25 | 4 | import string
def sum_digits(s):
""" assumes s a string
Returns an int that is the sum of all of the digits in s.
If there are no digits in s it raises a ValueError exception. """
assert isinstance(s, str), 'not a string'
found = False
sum = 0
for i in s:
if i in string.di... | true |
6d251e9edeb2f9a67f9238f65c92c8161fe1e6cf | VivancoJose/Tarea_2 | /Tarea_2/ejercicio2.py | 318 | 4.21875 | 4 | #Realiza un programa que lea un número impar por teclado. Si el usuario no introduce un número impar,
# debe repetise el proceso hasta que lo introduzca correctamente.
numero_1= 0
while numero_1 % 2 == 0:
numero_1 = int(input(" Ingrese un numero impar: \n") )
print("El numemro ue ha introducido es correcto") | false |
7621071381ddeb2d5c5fdbde64ed90d87aeb8f67 | ebsbfish4/classes_lectures_videos_etc | /video_series/sentdex_machine_learning_with_pyhton/how_to_program_the_best_fit_slope.py | 869 | 4.15625 | 4 | '''
We know definition of line is y = mx + b.
So, first we will calculate for m.
Included next video in this file as well
'''
from statistics import mean
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
style.use('fivethirtyeight')
xs = np.array([1,2,3,4,5,6], dtype=np.float64)
ys = ... | false |
1ef2a328b5d3d4de6ab9a68a3c45d75959155ac3 | alejandradean/digital_archiving | /filename_list_with_dirs.py | 801 | 4.3125 | 4 | import os
directory_path = input("Enter directory path: ")
# the below will create a file 'filenames.txt' in the same directory the script is saved in. Enter the full path in addition to the .txt filename to create the file elsewhere.
with open('filenames.txt', 'a') as file:
for root, dirs, files in os.walk... | true |
a28a5240fb888c7686624e6186a5b3f77c5b4825 | speed785/Python-Projects | /lab8.py | 743 | 4.1875 | 4 | #lab8 James Dumitru
#Using built in
number_1 = int(input("Enter a number: "))
number_2 = int(input("Enter a number: "))
number_3 = int(input("Enter a number: "))
number_4 = int(input("Enter a number: "))
number_5 = int(input("Enter a number: "))
number_6 = int(input("Enter a number: "))
num_list = []
num_list.append(n... | true |
e0f95acb97a5f921722dacdf2773808421c80bc5 | speed785/Python-Projects | /Temperature converter.py | 1,289 | 4.28125 | 4 | #Coded by : James Dumitru
# input #
y=int(input("Please Enter A Number "))
x=int(input("Please Enter A Second Number "))
# variables #
add=x+y
multi=x*y
div=x/y
sub=x-y
mod=x%y
# What is shown #
print("This is the addition for the two numbers=", add)
print("This is the multiplication for the two numbers=", multi)
... | true |
b779cabe46235f12afb6d08104c2fe05e94f0c23 | khaldi505/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/5-text_indentation.py | 574 | 4.1875 | 4 | #!/usr/bin/python3
""" function that add a text indentation. """
def text_indentation(text):
"""
text = str
"""
txt = ""
if not isinstance(text, str):
raise TypeError("text must be a string")
for y in range(len(text)):
if text[y] == " " and text[y - 1] in [".", "?",... | true |
57c2fd29fa65988bcc3a38013f48ecb3a5c8aa02 | mafudge/learn-python | /content/lessons/07/Now-You-Code/NYC4-Sentiment-v1.py | 2,824 | 4.34375 | 4 | '''
Now You Code 3: Sentiment 1.0
Let's write a basic sentiment analyzer in Python. Sentiment analysis is the
act of extracting mood from text. It has practical applications in analyzing
reactions in social media, product opinions, movie reviews and much more.
The 1.0 version of our sentiment analyzer will start with... | true |
ac594af8db3882620707a74c6600e667f8d2b784 | tayloradam1999/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 627 | 4.34375 | 4 | #!/usr/bin/python3
"""
add_integer - adds 2 integers
a - first integer for addition
b - second integer for addition
Return: sum of addition
"""
def add_integer(a, b=98):
"""This def adds two integers and returns the sum.
Float arguments are typecasted to ints before additon is performed.
Raises a TypeErr... | true |
a88ee84f46356c83315bd3c0ce2e81d0328a8733 | tayloradam1999/holbertonschool-higher_level_programming | /0x0A-python-inheritance/1-my_list.py | 416 | 4.34375 | 4 | #!/usr/bin/python3
"""
This module writes a class 'MyList' that inherits from 'list'
"""
class MyList(list):
"""Class that inherits from 'list'
includes a method that prints the list, but in ascending order"""
def print_sorted(self):
"""Prints the list in ascending order"""
sort_list = []... | true |
3277de75085d160a739f2ea059361152403de931 | tayloradam1999/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/4-print_square.py | 542 | 4.375 | 4 | #!/usr/bin/python3
"""This module defines a square-printing function.
size: Height and width of the square."""
def print_square(size):
"""Defines a square-printing function.
Raises a TypeError if:
Size is not an integer
Raises a ValueError if:
Size is < 0"""
if not isinstance(size, in... | true |
4afb5f6f85657bb8b2586792c1ffdb03cabba379 | fitzystrikesagain/fullstack-nanodegree | /sql_and_data_modeling/psycopg-practice.py | 1,382 | 4.34375 | 4 | """
Exercise 1
----------
Create a database in your Postgres server (using `createdb`)
In psycopg2 create a table and insert some records using methods for SQL string composition. Make sure to establish
a connection and close it at the end of interacting with your database. Inspect your table schema and data in psql.
(... | true |
6e89046c4bab8515317fa3b4de91502ae333e8d0 | bj-mckay/atbswp | /Chapter 7/dateDetection.py | 1,454 | 4.4375 | 4 | #! python3
# dateDetection.py - detects dates in the DD/MM/YYY format
import re, sys
print('Enter a date DD/MM/YYYY.')
date = str(input())
#date = str('28/02/2001')
leapyear = None
dateRegex = re.compile(r'''(
([0][1-9]|[1|2][0-9]|[3][0|1]) # Day
\/ # slash
([0][0-9]|[1][0-2]) ... | false |
4f170c0d111c2c5b2ffcdd62714c0e8613eadfe2 | mariettas/SmartNinja_Project_smartninja_python2_homework | /fizzbuzz.py | 320 | 4.21875 | 4 | print("Hello, welcome to the fizzbuzz game!")
choice = int(input("Please, enter a number between 1 and 100: "))
for x in range(1, choice + 1):
if x % 3 == 0 and x % 5 == 0:
print("fizzbuzz")
elif x % 3 == 0:
print("fizz")
elif x % 5 == 0:
print("buzz")
else:
print(x)
| true |
552dcfca3facace254db3e547a547f11271d2cc0 | Vadum-cmd/lab5_12 | /cats.py | 1,867 | 4.125 | 4 | """
Module which contains classes Cat and Animal.
"""
class Animal:
"""
Class for describing animal's properties.
"""
def __init__(self, phylum, clas):
"""
Initializes an object of class Animal and sets its properties.
>>> animal1 = Animal("chordata", "mammalia")
>>> ass... | true |
84360bc297d4b20494db6d8782ed980cb9f55b9f | asimMahat/Advanced-python | /lists.py | 1,365 | 4.21875 | 4 |
mylist = ['banana', 'apple','orange']
# print(mylist)
mylist2 = [5,'apple',True]
# print (mylist2)
item = mylist[-1]
# print (item)
for i in mylist:
print(i)
'''
if 'orange' in mylist:
print("yes")
else:
print("no")
'''
# print(len(mylist))
mylist.append("lemon")
print(mylist)
mylist.insert(1,'berry')... | true |
517bf3dbd653001c3e70c1f222f00b695414d370 | asimMahat/Advanced-python | /tuples.py | 1,405 | 4.375 | 4 | #in tuples the paranthesis are optional
mytuples = "Max",28,"Boston"
print (type(mytuples))
print(mytuples)
item = mytuples[2]
print (item)
#tuples are immutable
for i in mytuples:
print(i)
if "Max" in mytuples:
print ("yes")
else:
print ("no")
print("---------------------------------------")
my_tuple... | false |
b9f9c0c94167c21e15632171149413eeeccc359a | Guessan/python01 | /Assignments/Answer_3.3.py | 971 | 4.34375 | 4 | #Assignment: Write a program to prompt for a score between 0.0 and 1.0.
#If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade using the following table:
#Score Grade
#>= 0.9 A
#>= 0.8 B
#>= 0.7 C
#>= 0.6 D
#< 0.6 F
#If the user enters a value out of range, print a suitable... | true |
eadb4a678a48bef0d15acb3e9e2abfb6929c8f2c | archimedessena/Grokkingalgo | /selectionsort.py | 1,626 | 4.3125 | 4 | # selection sort algorithm
def findSmallest(arr):
smallest = arr[0] #Stores the smallest value
smallest_index = 0 #Stores the index of the smallest value
for i in range(1, len(arr)):
if arr[i] < smallest:
smallest = arr[i]
smallest_index = i
return smallest_index
#Now you... | true |
9339fdaeb9f8271c05910ecc4b1ee7d0a71f7d30 | bekahbooGH/Stacks-Queues | /queue.py | 1,113 | 4.3125 | 4 | class MyQueue:
def __init__(self):
"""Initialize your data structure here."""
self.stack1 = Stack()
self.stack2 = Stack()
def push(self, x: int) -> None:
"""Push element x to the back of queue."""
while not self.stack2.empty():
self.stack1.push(self.stack2.pop(... | true |
cde4e88e4c072257ca7e7489888a9a370b34c47c | sumit-kushwah/oops-in-python | /files/Exercise Files/Ch 4/immutable_finished.py | 574 | 4.4375 | 4 | # Python Object Oriented Programming by Joe Marini course example
# Creating immutable data classes
from dataclasses import dataclass
@dataclass(frozen=True) # "The "frozen" parameter makes the class immutable
class ImmutableClass:
value1: str = "Value 1"
value2: int = 0
def somefunc(self, newval):
... | true |
fe480bc286b420be4109bbdbfa2ea9a2d7d97896 | sumit-kushwah/oops-in-python | /files/Exercise Files/Ch 4/datadefault_start.py | 471 | 4.3125 | 4 | # Python Object Oriented Programming by Joe Marini course example
# implementing default values in data classes
from dataclasses import dataclass, field
import random
def price_func():
return float(random.randrange(20, 40))
@dataclass
class Book:
# you can define default values when attributes are declared... | true |
a8c9d7355b63df85868b8c53198828b50d4098e8 | Richiewong07/Python-Exercises | /python-udemy/Assessments_and_Challenges/Statements/listcomprehension.py | 211 | 4.46875 | 4 | # Use List Comprehension to create a list of the first letters of every word in the string below:
st = 'Create a list of the first letters of every word in this string'
print([word[0] for word in st.split()])
| true |
ae16fb85dcd03542eb414a5ba6e1d707b9afc01f | Richiewong07/Python-Exercises | /python-assignments/python-part1/work_or_sleep_in.py | 396 | 4.21875 | 4 | # Prompt the user for a day of the week just like the previous problem.
# Except this time print "Go to work" if it's a work day and "Sleep in" if it's
# a weekend day.
input = int(input('What day is it? Enter (0-6): '))
def conv_day(day):
if day in range(1,6):
print('It is a weekday. Wake up and go to wo... | true |
56529869d13d6bc30f578675cc8bfb510f81a8c4 | Richiewong07/Python-Exercises | /python-assignments/functions/plot_function.py | 300 | 4.21875 | 4 | # 2. y = x + 1
# Write a function f(x) that returns x + 1 and plot it for x values of -3 to 3 in increments of 1.
import matplotlib.pyplot as plot
def f(x):
return x + 1
xs = list(range(-3,4))
ys = []
for x in xs:
ys.append(f(x))
plot.plot(xs, ys)
plot.axis([-3, 3, -2, 4])
plot.show()
| true |
f1531778b5f766b5512a34b1c6d373ee5da71c39 | Richiewong07/Python-Exercises | /callbox-assesment/exercise3.py | 854 | 4.625 | 5 | # Exercise 3:
# Write a function that identifies if an integer is a power of 2. The function should return a boolean. Explain why your function will work for any integer inputs that it receives.
# Examples:
# is_power_two(6) → false is_power_two(16) ... | true |
57ec4253919ae789a437781b3c0d3bd92b073480 | Richiewong07/Python-Exercises | /python-assignments/list/matrix_addition.py | 654 | 4.1875 | 4 | # 9. Matrix Addition
# Given two two-dimensional lists of numbers of the size 2x2 two dimensional list is represented as an list of lists:
#
# [ [2, -2],
# [5, 3] ]
# Calculate the result of adding the two matrices. The number in each position in the resulting matrix should be the sum of the numbers in the correspond... | true |
1cfee3a4f5f8af85c0f764ed9bacd4795df24ac6 | Richiewong07/Python-Exercises | /numpy/slicing_stacking.py | 503 | 4.28125 | 4 | import numpy as np
a = np.array([6,7,8])
print(a)
# HOW TO SLICE ARRAY
print(a[0:2])
print(a[-1])
a = np.array([[6,7,8], [1,2,3], [9,3,2]])
print(a)
# ROW 1 COLUMN 2 --> 3
print(a[1,2])
# FROM 0 TO 2ND ROW, COLUMN 2 --> [8,3]
print(a[0:2,2])
# GIVES LAST ELEMENT
print(a[-1])
# GIVES LAST ELEMENT, ELEMENTS 0 AND ... | false |
10d0346dabc7e4135ab9981d49f0df762694b43d | abhishekkulkarni24/Machine-Learning | /Numpy/operations_on_mobile_phone_prices.py | 1,643 | 4.125 | 4 | '''
Perform the following operations on an array of mobile phones prices 6999, 7500, 11999,
27899, 14999, 9999.
a. Create a 1d-array of mobile phones prices
b. Convert this array to float type
c. Append a new mobile having price of 13999 Rs. to this array
d. Reverse this array of mobile phones prices
e. Apply GST of 1... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.