blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
6ffba84aafcdb3a4491c8268cba8ea1e2adfdf1e
JapoDeveloper/think-python
/exercises/chapter6/exercise_6_2.py
951
4.3125
4
""" Think Python, 2nd Edition Chapter 6 Exercise 6.2 Description: The Ackermann function, A(m,n), is defined: n + 1 if m = 0 A(m,n) = A(m-1, 1) if m > 0 and n = 0 A(m-1, A(m,n-1)) if m > 0 and n > 0 See http://en.wikipedia.org/wiki/Ackermann_function. Write a function named ac...
508a885f71292a801877616a7e8132902d1af6c5
JapoDeveloper/think-python
/exercises/chapter6/exercise_6_4.py
643
4.3125
4
""" Think Python, 2nd Edition Chapter 6 Exercise 6.4 Description: A number, a, is a power of b if it is divisible by b and a/b is a power of b. Write a function called is_power that takes parameters a and b and returns True if a is a power of b. Note: you will have to think about the base case. """ def is_power(a...
125124731c5b0b32448eb2ffd2a144ec826cecdb
DDDlyk/learningpython
/01_Python基础/07_买苹果增强.py
249
3.96875
4
# 1. 输入苹果单价 price_str = input("苹果的单价:") # 2. 输入苹果重量 weight_str = input("苹果的重量:") # 3. 计算支付的总金额 price = float(price_str) weight = float(weight_str) money = price * weight print(money)
1f6ff08de38c7d153a37dc5a821d91613150a6f5
DDDlyk/learningpython
/02_分支/01_判断年龄.py
290
3.984375
4
# 1. 定义一个整数变量记录年龄 age = 23 # 2. 判断是否满了18岁 if age >= 18: # 3. 如果满了18岁,可以进网吧嗨皮 print("你已经成年,欢迎进网吧嗨皮") else: print("未满18岁,请回吧,施主") print("看看什么时候会执行")
643e110affedc0b55ab47ef462c743ec2e8cea50
DDDlyk/learningpython
/network/15_循环为多个客户端服务并且多次服务一个客户端.py
1,774
3.75
4
import socket def main(): # 1.买个手机(创建套接字) tcp_server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 2.插入手机卡(绑定本地信息) tcp_server_socket.bind(("", 7788)) # 3.将手机设置为正常的响铃模式(让默认的套接字由主动变为被动 listen) tcp_server_socket.listen(128) # 这个while true循环为多个客户端服务 while True: pr...
9d89589c9137605389db181b0414240dc963f4c2
DDDlyk/learningpython
/08_面向对象/ddd_16_士兵突击_03_士兵开火.py
1,212
3.703125
4
class Gun: def __init__(self, model): # 1.抢的型号 self.model = model # 2.子弹的数量 self.bullet_count = 0 def add_bullet(self, count): self.bullet_count += count def shoot(self): # 1.判断子弹数量 if self.bullet_count <= 0: print ("[%s]没有子弹了..." % ...
8568a51f56ca37c1d25411e07c8047bd5f345268
DDDlyk/learningpython
/07_语法进阶/ddd_20_递归求和.py
270
3.75
4
def sum_numbers(num): # 1.出口 if num == 1: return 1 # 2. 数字的累加 num +(1....num - 1) # 假设 sum_numbers能够正确处理1....num-1 temp = sum_numbers(num-1) return num + temp result = sum_numbers(100) print(result)
8c5faf13fe2952f33dd45000bf56e87bd1a0747e
Shubham1304/Semester6
/ClassPython/4.py
711
4.21875
4
#31st January class #string operations s='hello' print (s.index('o')) #exception if not found #s.find('a') return -1 if not found #------------------check valid name------------------------------------------------------------------------------------- s='' s=input("Enter the string") if(s.isalpha()): print ("Valid ...
f6623a49a565eb677d0e43fff9e717d081d6b0a4
saahil1292/fsdse-python-assignment-7
/prime_numbers.py
280
3.625
4
def get_prime_numbers(n): prime_numbers = [] for num1 in range(2,n+1): for num2 in range(2, num1): if (num1 % num2 == 0): break; else: prime_numbers.append(num1) return prime_numbers n = 20 get_prime_numbers(n)
4dac98267bf7d419c085190c2540c32ef54ea430
anivanchen/stuycs-classlist
/getClass.py
976
3.53125
4
import requests from bs4 import BeautifulSoup print("Enter your teacher's name in the format firstInitialLastName. Example: dholmes") teacherName = str(input('Teacher Name (ex. dholmes): ')) print("Enter your term name in the format [fall/spring]year. Example: fall2021") term = str(input("Enter the term (fall2021): ")...
b896f3577f80daaf46e56a70b046aecacf2288cb
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/17.py
718
4.375
4
''' Write a version of a palindrome recognizer that also accepts phrase palindromes such as "Go hang a salami I'm a lasagna hog.", "Was it a rat I saw?", "Step on no pets", "Sit on a potato pan, Otis", "Lisa Bonet ate no basil", "Satan, oscillate my metallic sonatas", "I roamed under it as a tired nude Maori", "Rise t...
9b2ff0337869bc9125c8134ca93e43b33262488b
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/42.py
2,350
3.921875
4
''' A sentence splitter is a program capable of splitting a text into sentences. The standard set of heuristics for sentence splitting includes (but isn't limited to) the following rules: Sentence boundaries occur at one of "." (periods), "?" or "!", except that 1. Periods followed by whitespace followed by a lower ca...
e7cba5438a771a16987ca6f1bf55a7f8bd0e160d
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/45.py
4,064
3.578125
4
''' A certain childrens game involves starting with a word in a particular category. Each participant in turn says a word, but that word must begin with the final letter of the previous word. Once a word has been given, it cannot be repeated. If an opponent cannot give a word in the category, they fall out of the gam...
52419c3a1ddf2587d2d6d771351be6d380a78650
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/06.py
430
3.9375
4
''' Define a function sum() and a function multiply() that sums and multiplies (respectively) all the numbers in a list of numbers. For example, sum([1, 2, 3, 4]) should return 10, and multiply([1, 2, 3, 4]) should return 24. ''' def sum1(x): c=0 for i in x: c += i return c print sum1([1, 2,...
f18204d3dab48280b29808613a3e039eab72ec4b
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/22.py
2,488
4.125
4
''' In cryptography, a Caesar cipher is a very simple encryption techniques in which each letter in the plain text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 3, A would be replaced by D, B would become E, and so on. The method is named after Julius Caesar, who...
40589034a276810b9b22c31ca519399df66bd712
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/02.py
277
4.125
4
''' Define a function max_of_three() that takes three numbers as arguments and returns the largest of them. ''' def max_of_three(a,b,c): if a>b and a>c: print a elif b>c and b>a: print b else: print c print max_of_three(0,15,2)
2c90729cf624a34ca2c7a6a4f1afe63fe4bba7a7
Isonzo/100-day-python-challenge
/Day 1/day 1.4 exercise.py
249
3.90625
4
#Don't change code below! a = input("a: ") b = input("b: ") #Don't change code above! #Switch a and b variables c = a a = b b = c #Don't change code below! print("a = " + a) print("b = " + b) #Don't change code above!
728b7a20adbaf507242e6a090a0d19a403c01fda
Isonzo/100-day-python-challenge
/Day 9/silent_auction.py
918
3.59375
4
import os from silent_auction_art import logo def clear(): os.system('cls' if os.name == 'nt' else 'clear') auction_record = {} def check_highest_bidder(auction_record): highest_bid = 0 for bidder in auction_record: bid_amount = auction_record[bidder] if bid_amount > hig...
5de58b512ac999c7df3c3f76ab1aaa7289ed1ef5
Isonzo/100-day-python-challenge
/Day 32/main.py
1,243
3.65625
4
import pandas as pd import datetime as dt import random import smtplib my_email = "isonzo@gmail.com" password = "not_going_to_put_my_password" # Extra Hard Starting Project ###################### # 1. Update the birthdays.csv data = pd.read_csv("birthdays.csv") birthdays = data.to_dict(orient="records") now = d...
252960bd12d66af9c6f9e2edbf1b423a726f894c
Isonzo/100-day-python-challenge
/Day 14/higher_lower.py
2,158
3.828125
4
import random from art import logo, vs from game_data import data import os def clear(): os.system('cls' if os.name == 'nt' else 'clear') def higher_lower(): score = 0 game_not_lost = True def pick_celebrity(): """Picks a random celebrity from data""" return rand...
fc24e9ff6df3c2d766e719892fae9426e33f81f6
Isonzo/100-day-python-challenge
/Day 8/prime_number_checker.py
460
4.15625
4
def prime_checker(number): if number == 0 or number == 1: print("This number is neither prime nor composite") return prime = True for integer in range(2, number): if number % integer == 0: prime = False break if prime: print("It's a...
2b7449866da41f54572d858520c2acf0b5404f92
shash222/Project_Euler_Python
/03LargestPrimeFactor.py
253
3.6875
4
def isPrime(i): for j in range(2,i): if (i%j==0): return False return True num=600851475143 largest=0; for i in range(int("%.0f" % num**(1/2))): if(num%i==0): if(isPrime(i)): largest=i print(largest)
8377f2cd5a0dbb6be074c203a80fb55d71a5d98c
alexcomu/python-examples
/properties_classmethods.py
674
3.765625
4
class Address(object): _cap = [] def __init__(self): self._cap = [] def append_cap(self, value): self._cap.append(value) # append to global, all classes def append_global_cap(self, value): self.__class__._cap.append(value) # property definition @property def c...
b3f1c9211b20e36ce97ea3d73ec5eb2b58b59676
jwilliams8899/CS_1301
/HW05.py
8,150
4.40625
4
#!/usr/bin/env python3 """ Georgia Institute of Technology - CS1301 HW05 - Tuples & Modules """ __author__ = " Jared Williams " __collaboration__ = """ I worked on this homework assignment alone, using only this semester's resources. """ """ Function name: cubeVolume Parameters: tuple Returns: tuple Description: Wri...
14601b1d69c3fe8845df4f75715eb6e2bc07a34c
oversj96/NumericalMethodsHW
/Homework 3/Newton Method.py
232
3.875
4
# Author: Justin Overstreet # Purpose: Test Newton-Raphson Method for finding zeros. def f(x): return x - ((x ** 2 - 2 * x - 1) / (2 * x - 2)) list = [2.5] i = 0 while (len(list) < 4): list.append(f(list[i])) i += 1 print(list)
c97e005896dcb2c66f218583a8d75179e1962d8b
Matzikratzi/AoC2020
/12/12.py
1,403
4.0625
4
#!/usr/bin/python3 def Movement(pos, direction, instruction): action = instruction[0] value = int(instruction[1:]) newPos = pos.copy() newDirection = direction if action == 'N': newPos[1] += value elif action == 'S': newPos[1] -= value elif action == 'E': newPos[0] ...
30acdc43cd634f05c95d71165925d67dcbfaeefe
biewdev/unicid-python-exercises
/lista-1/acertos.py
376
3.796875
4
points = 0 answer_one = input("Resposta da primeira questão: ") if answer_one.lower() == "B".lower(): points += 1 answer_two = input("Resposta da segunda questão: ") if answer_two.lower() == "A".lower(): points += 1 answer_three = input("Resposta da terceira questão: ") if answer_three.lower() == "D".lower()...
a579085f352f2b9c4d1c5c0b85d1cc99fde7ee9f
paveltsytovich/telegram-course
/Code/Module 3/Exercies/transfer.py
153
3.828125
4
x = input("введите строку >") d = int(x) y = input("введите другую строку >") print(float(y)) print(bin(d)) print(hex(d))
962b23479b12f885243add0f6ced0b8e7c6dae0e
paveltsytovich/telegram-course
/Code/Module 3/Exercies/string.py
309
3.859375
4
x = input("введите строку >") y = input("введите вторую строку >") print(x*5) print(x+y) print(len(x)+len(y)) if y in x: print("Вторая строка является подстрокой первой") else: print("строки являютеся разными")
a914a0732f5c79630dab6419a9ba5094e888c6a2
paveltsytovich/telegram-course
/Code/Module 3/Live/list.py
179
3.59375
4
x = [1,2,3,4] x.append(5) print(x) y = [6,7,8,9] print(x + y) x.extend(y) print(x) x.insert(2,99) print(x) print(x.pop()) print(x.count(2)) x.reverse() print(x) x.clear() print(x)
1b14889db04fed658d481fd563213b7c9ef3e4d8
lucasrumney94/Python
/Python/Catching the Cold or-the-Flu/1/StringBuilder.py
988
3.546875
4
import time iterations = 100 word_list = ["Hello ", "there! ", "How ", "are ", "you ", " doing", " today?"] with open('freebsddictionary.txt', 'r') as file_object: for line in file_object: word_list.append(file_object.readline()) # additive string concatenation def join_words(words): sentence = '' ...
3c14a40a15d5205d30f126cde1378373a4d82a76
CKalinowski/KalinowskiChloeTP03
/main.py
3,079
4.3125
4
print ('1. Listes') print ('1.1 Modifier une liste') annee = ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre',10,11,12] print('1.1.1 Supprimez les trois derniers éléments un par un, dans un premier temps') print (annee) del(annee[-1]) print (annee) del(annee[-1]) print (annee) del(annee[-...
d228d4888770b45dfc5b444f547024ff3830815f
hobbz216/Number-Guessing-Game
/number_guess.py
3,118
3.9375
4
#Number guessing game import random from replit import clear import art def answer(): answer = random.choice(range(1, 101)) return answer print(answer) def difficulty(choice): if choose == 'easy': return easy_guess else: return hard_guess player_guess = 0 game_answe...
a4a77a7a6d168d1ba0c1778a6170915cb51b38a6
esvrindha/python-programming
/largest.py
211
4
4
dig1=int(raw_input("")) dig2=int(raw_input("")) dig3=int(raw_input("")) if (dig1>dig2)and(dig1>dig3): largest = dig1 elif (dig2>dig1)and(dig2>dig3): largest = dig2 else: largest= dig3 print(largest)
b8815b4957ae8ca3e96f6b5e6926657828d7f87c
esvrindha/python-programming
/97.py
90
3.578125
4
vrin=int(raw_input("")) e=0 while (vrin!=0): r=vrin%10; e=e*10+r vrin/=10; print(e)
99139c2ecf70d3985d8eef46bf11350d6a4a9843
esvrindha/python-programming
/eveninrange.py
98
3.53125
4
moni=int(input("")) vamp=int(input("")) for i in range(moni+1,vamp): if(i%2 == 0): print(i)
6b85d1e3ad83c50cbfdc9b2117de0faf0b8c9b52
esvrindha/python-programming
/powof2.py
95
3.78125
4
i=int(raw_input("")) if (i%2)==0: print("yes") if (i==1): print("yes") else: print("no")
52a268329f255d74fa721ae8d175e9024e39377e
kashenfelter/IXL-Learning-Coding-Challenge
/reduced_fraction_sums.py
1,209
3.546875
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 27 01:37:03 2018 @author: raleigh-littles """ import fractions, unittest def reducedFractionSums(expressions): """ Fairly self-explanatory, just use the built-in fractions package to perform the fraction addition -- they'll be automatically reduced in the en...
14e6ae9bb95689aa234afe00ec5a6396cc41dd8b
M0673N/Programming-Fundamentals-with-Python
/05_lists_advanced/lab/04_palindrome_strings.py
210
3.78125
4
data = input().split() search = input() counter = 0 data2 = [palindrome for palindrome in data if palindrome == "".join(reversed(palindrome))] print(data2) print(f"Found palindrome {data.count(search)} times")
d5c0a82cafd613bc94898650c051945e195d85b0
M0673N/Programming-Fundamentals-with-Python
/04_functions/exercise/10_list_manipulator.py
3,395
3.71875
4
from sys import maxsize def exchange(index): array = data[index + 1:] + data[:index + 1] return array def max_even(): max_num = -maxsize max_num_index = -1 for index in range(len(data)): if data[index] >= max_num and data[index] % 2 == 0: max_num = data[index] max...
133c061729e061076793a84878ad0cb4347fc016
M0673N/Programming-Fundamentals-with-Python
/exam_preparation/final_exam/05_mock_exam/03_problem_solution.py
1,713
4.15625
4
command = input() map_of_the_seas = {} while not command == "Sail": city, population, gold = command.split("||") if city not in map_of_the_seas: map_of_the_seas[city] = [int(population), int(gold)] else: map_of_the_seas[city][0] += int(population) map_of_the_seas[city][1] += int(gold...
743ddca34beba4ccbe754971a751106cb2e7b1f5
M0673N/Programming-Fundamentals-with-Python
/03_lists_basics/more exercises/04_car_race.py
592
3.703125
4
data = [int(i) for i in input().split()] route_1 = data[:len(data) // 2] route_2 = data[len(data) // 2 + 1:] route_2.reverse() total_time_route_1 = 0 total_time_route_2 = 0 for i in route_1: if i == 0: total_time_route_1 *= 0.8 else: total_time_route_1 += i for i in route_2: if i == 0: ...
9b7d84c119d2cffe523113566fd286682c4ee0cb
M0673N/Programming-Fundamentals-with-Python
/05_lists_advanced/exercise/05_office_chairs.py
397
3.609375
4
rooms = int(input()) free_chairs = 0 flag = False for room in range(1, rooms + 1): command = input().split() if len(command[0]) < int(command[1]): print(f"{int(command[1]) - len(command[0])} more chairs needed in room {room}") flag = True else: free_chairs += len(command[0]) - int(co...
955aa650829c230ad2bec9d3ae3674a1fc108889
M0673N/Programming-Fundamentals-with-Python
/07_dictionaries/exercise/05_softuni_parking.py
708
3.828125
4
n = int(input()) data = {} for i in range(n): command = input().split() if command[0] == "register": username = command[1] plate = command[2] if username not in data: data[username] = plate print(f"{username} registered {plate} successfully") else: ...
fceea066bb99f0f3e16b0668c1f19a79896b376d
M0673N/Programming-Fundamentals-with-Python
/03_lists_basics/more exercises/01_zeros_to_back.py
231
3.578125
4
string = [int(i) for i in input().split(", ")] counter = 0 for i in range(len(string)): if string[i] == 0: counter += 1 result = [i for i in string if i != 0] for i in range(counter): result.append(0) print(result)
be9abb9d6b95ef9b00fee1f9865791b9b0d099b9
M0673N/Programming-Fundamentals-with-Python
/02_data_types_and_variables/exercise/07_water_overflow.py
200
3.828125
4
n = int(input()) capacity = 0 for i in range(n): litres = int(input()) if capacity + litres > 255: print("Insufficient capacity!") else: capacity += litres print(capacity)
38a12439edb079a049bbe6b82ca1c7ae7691f7dc
M0673N/Programming-Fundamentals-with-Python
/02_data_types_and_variables/exercise/05_print_part_of_the_ASCII_table.py
125
3.90625
4
start_char = int(input()) end_char = int(input()) for char in range(start_char, end_char + 1): print(chr(char), end=" ")
90887abf69343cca14a0732c30a7ad54233ec9de
M0673N/Programming-Fundamentals-with-Python
/03_lists_basics/exercise/10_bread_factory.py
1,189
3.59375
4
data = input().split("|") energy = 100 coins = 100 for i in range(len(data)): data[i] = data[i].split("-") for i in range(len(data)): if data[i][0] == "rest": if energy + float(data[i][1]) <= 100: energy += float(data[i][1]) print(f"You gained {float(data[i][1]):.0f} energy.")...
f3e71dd7e6bcd7f159f12408140b4d7bb6d481f3
M0673N/Programming-Fundamentals-with-Python
/02_data_types_and_variables/exercise/01_integer_operations.py
127
3.75
4
num1 = int(input()) num2 = int(input()) num3 = int(input()) num4 = int(input()) print(int((int((num1 + num2) / num3)) * num4))
44bc85447139252b30c7c9b2ea4ef689ecea196b
M0673N/Programming-Fundamentals-with-Python
/02_data_types_and_variables/exercise/09_snowballs.py
347
3.5625
4
n = int(input()) best = 0 for i in range(n): snow = int(input()) time = int(input()) quality = int(input()) value = (snow / time) ** quality if value > best: best_snow = snow best_time = time best_quality = quality best = value print(f"{best_snow} : {best_time} = {int...
83c8656882b2d869dc2bdc6ea0e397b449e27e33
M0673N/Programming-Fundamentals-with-Python
/05_lists_advanced/exercise/06_electron_distribution.py
282
3.78125
4
electrons = int(input()) counter = 1 result = [] while electrons > 0: if electrons - 2 * counter ** 2 >= 0: result.append(2 * counter ** 2) electrons -= 2 * counter ** 2 counter += 1 else: result.append(electrons) break print(result)
ba8907050af53baa67dcbbaba314ab151ea20d41
M0673N/Programming-Fundamentals-with-Python
/04_functions/exercise/04_odd_and_even_sum.py
261
4.28125
4
def odd_even_sum(num): odd = 0 even = 0 for digit in num: if int(digit) % 2 == 0: even += int(digit) else: odd += int(digit) print(f"Odd sum = {odd}, Even sum = {even}") num = input() odd_even_sum(num)
5df9b99440b11611715bcd857315518e77020cdc
M0673N/Programming-Fundamentals-with-Python
/09_regular_expressions/exercise/02_find_variable_names_in_sentences.py
122
3.734375
4
import re data = input() pattern = r"\b[_]([A-Za-z0-9]+\b)" result = re.findall(pattern, data) print(",".join(result))
050bbbd9b7c21004b600b9bd5215623ce38c7736
shaybrynes/MatrixPy
/MatrixPy/print_matrix.py
387
3.890625
4
__author__ = "Shay Brynes" __license__ = "Apache License 2.0" def print_matrix(matrix): for n in range(0, len(matrix)): for m in range(0, len(matrix[n])): if m == 0: print("(", end="") print(matrix[n][m], end="") if m == len(matrix[n])-1: ...
e4a3e396396c895e4b2cb900e184cff9d7a3fdd3
ojaisnielsen/project-euler
/ProjectEuler/Problem14.py
279
3.671875
4
def collatz(n): yield n while n > 1: if n % 2 == 0: n = n / 2 else: n = 3 * n + 1 yield n max = 0 arg_max = 0 for a in range(1, 1000000): l = sum(1 for x in collatz(a)) if a % 10000 == 0: print a, max if l > max: max = l arg_max = a print arg_max, max
69c56a925315c330cccca84de2d760871b970f9f
AdityaDolas/CJPJHCVN
/python/CFLOW008.py
149
3.9375
4
z=int(input()) while(z>0): a=int(input()) if(a<10): print("What an obedient servant you are!") else: print("-1") z-=1
e6127b87f2f91c10538c5d5c97d5108866c13c2d
camilleemig/CSE231
/Project11/proj11-app.py
2,897
3.71875
4
########################################################### # Computer Project #11 # # Imports classes # Trys to open two files # Reads assignment weights from file # Reads assignment names from file # Reads student grades and ids from file # Seperates student grades a...
53c0dcf5bea7d37c051f30ac88194424a2ea63c3
camilleemig/CSE231
/Project2/control_example.py
708
3.96875
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 8 10:25:11 2016 @author: Camille """ points_str = input("Enter the lead in points: ") points_ahead_int = int(points_str) lead_calculation_float = float(points_ahead_int - 3) has_ball_str = input("Does the lead team have the ball (Yes or No)? ") if has_ball_str == "Yes...
536e2492179562082c1e94c7828f4d965e6dda0e
Alejandro-Larumbe/appAcademy-backend-frontend-project-skeleton
/week17-Python/monday-basics/sets.py
494
3.625
4
# SETS # a = set('banana') # b = set('scarab') # print(a, b) # print(a | b) # print(a.union(b)) # print(a & b) # print(a.intersection(b)) # print(a ^ b) # print(a.symmetric_difference(b)) # print(a - b) # print(a.difference(b)) # error # print(a + b) unsupported operand # purchasingEmails = ('bob@gmail.com', 'sa...
1c6fbf0268874aed0a8a4b89efb3c8c538199e3a
Alejandro-Larumbe/appAcademy-backend-frontend-project-skeleton
/week17-Python/monday-basics/pythonBasics.py
2,753
4.0625
4
# print('Hello world') # Arithmetic # ~~~~~~~~~~~~~~~~~~ # x = 25 # integer # y = 5 # float # print(x, y) # 25 5 # print(x + y) # 30 # print(x - y) # 20 # print(x * y) # 125 # print(x / y) # 5 # print(x // y) # 5 # print(x % y) # 0 # print(x ** 2) # print(y ** 2) # Input / Output # ~~~~~~~~~~~~~~~~~~ # name...
e32a9549aedd90cd0c5995dae17827c9a5c004cc
WillyRenzo/Introduction-to-Python
/Minicurso2209/ex10.py
479
3.90625
4
lista = ['Willy', 1000, 5.00, 'Sei la', 70.2] print("Lista: \n") print lista print lista[0] print lista[1:3] print lista[2:] print("\nTupla:\n") tupla = ('Willy', 1000, 5.00, 'Sei la', 70.2) tinytuple = (123, 'pedro') print tupla print tupla[0] print tupla[1:3] print tupla[2:] print tinytuple * 2 print tupla + tinyt...
6e8ac25e465a4c45f63af8334094049c0b660c4b
IrisCSX/LeetCode-algorithm
/476. Number Complement.py
1,309
4.125
4
""" Promblem: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fit within the range of a 32-bit signed integer. You could assume no leading zero bit in the integer’s binary representation. Example...
a9a18bd52d6f79f9c013e43929633445d513f2a8
samsonosiomwan/printer-model
/printer/printing_machine.py
1,501
3.75
4
from data.data import * class Printer: """this class holds template for format and resources attrbute, estimated resources(calculates resources to be used) and report""" color,greyscale = FORMAT['coloured']['materials']['ink'],FORMAT['greyscale']['materials']['ink'] colored_price,greyscale_price = FORMAT['c...
90f00c6b29d23379ceff38454d9300a58eb8ff67
litrin/MonkeyTyping
/monkey_typing.py
614
3.609375
4
import random import time CHARS = "abcdefjhijklmnopqrstuvwxyz" GOAL = 'match' def typing(): charaters_count = len(CHARS) count = 0 while True: count += 1 i = 0 word = '' while i < len(GOAL): i += 1 charater_number = random.randint(1, charaters_coun...
d3ff0dbbec0de62b85ed373e71029904c89f7482
shivang-123/pro-coder
/player_set1_ques3.py
110
3.53125
4
import re pat = r'\d+' n = input() if bool(re.match(pat, n)): print(n[::-1]) else: print("Invalid")
81928885e8373265f26459dbb7c5eaac1d887792
KozielPiotr/Character-creator-for-Dungeons-and-Dragons
/game/mechanics/throws/dice_throw.py
407
4.0625
4
"""Throws n-number of n-sided dices""" from random import randint def throw_dices(dices, sides): """ Throw given number of seleted-sided dices :param dices: number of dices :param sides: number of sides of dices :return: list of every dice result """ throw = [] dice = 1 while dice...
560ecc2f6cf8c42714c36e0743b40d525fcfb0b6
JAnto2017/pythonVarios
/pythonRPi/bucleWhile.py
197
3.609375
4
#uso de bucle while from time import sleep temp = 10 while temp < 15: temp+=1 print("La temp está "+str(temp)+" grados") print("aumento en 1ºC") sleep(1) print("Temp >= 15ºC")
726bb728209b9d3723953b3744ea5ab0c647fc2e
aanikooyan/CSULB-CECS-229
/Linear Algebra and Python (2).py
13,439
4.375
4
#!/usr/bin/env python # coding: utf-8 # # VECTOR AND MATRICES IN PYTHON NUMPY LIBRARY # IMPORTING THE NUMPY LIBRARY # In[ ]: import numpy as np # CREATING VECTOR AND MATRIX USING Numpy array # In[ ]: A = np.array([[1,2,3], [4,5,6], [7,8,9]]) # matrix # In[ ]: print(A) print(type(A)) # type of object prin...
4c6311954387c2f68fc7d19b87ffe7996070b37c
YosefatJQ/Python-Course-TC1014
/wsq10.py
554
3.765625
4
def total(l): x=0 sum = 0 while(x<10): sum = sum + l[x] x=x+1 return sum def promedio(t): promedio = t/10 return promedio def standarddeviation(l, p): x=0 sum = 0 while(x<10): s = (l[x]-p)**(2.0) sum = sum+s x=x+1 s = (sum/9)**(.5) return s x=0 l=[] print("This is a list of 10 numbers.") while (x<...
0922e3067fb1b997dfde1a6ca9dc80580c62db09
Yustyn/mebli_db
/test.py
1,506
3.796875
4
import unittest from methods import Admin, SuperAdmin class SuperAdminTests(unittest.TestCase): # valid data VALID_EMAIL = 'Correct@email.com' VALID_PASSWORD = 'AQwe12!_' # invalid data # INVALID_INIT = ('Incorrect@email.com', 12345678,) INVALID_EMAIL = 'Incorrect@@email..com' INVALID_PASS...
33603407b4541e901aade723adba8726ee8a5635
AKZMH/Python_Algos
/Урок 1. Практическое задание/task_4.py
1,954
3.71875
4
""" Задание 4. Написать программу, которая генерирует в указанных пользователем границах: случайное целое число; случайное вещественное число; случайный символ. Для каждого из трех случаев пользователь задает свои границы диапазона. Например, если надо получить случайный символ от 'a' до 'f', то вводятся эт...
c688cd33c59845b2dba167bcef914616a18dd473
1Mike1/Functional-programming-in-Python
/Functional Programming_In_Python.py
4,148
3.796875
4
''' Lets Understaned Higher Order Function (HOF) HOF if Function which will accept argument as function and return function as well. NOTE : Use Debugger to Understand the flow of code. ''' ''' Example ''' # 1 print('\nHigher Order Function\n') def Login(func,username,password): isValid = fu...
72961f6c43c619457c2c704a7dd2eed520403943
JhonnelN/examen_isep
/drops.py
470
3.953125
4
def drops(numero): # variable de tipo string vacia para poder anidar los resultados resultado = "" if numero % 3 == 0: resultado += "Plic" if numero % 5 == 0: resultado += "Plac" if numero % 7 == 0: resultado += "Ploc" return resultado or numero # Shortcircuit ...
124f02540d0b7712a73b5d2e2e03868ac809b791
anikaator/CodingPractice
/Datastructures/HashMap/Basic/Python/main.py
687
4.15625
4
def main(): # Use of dict contacts = {} contacts['abc'] = 81 contacts['pqr'] = 21 contacts['xyz'] = 99 def print_dict(): for k,v in contacts.items(): print 'dict[', k, '] = ', v print("Length of dict is %s" % len(contacts)) print("Dict contains:") print_dic...
5f542a3e4e1d4d187757e4133471ec488f8c007c
MaratAG/Netology_Python_T9
/Netology_Task_9.py
2,849
3.578125
4
"""Программа расчета необходимых для готовки блюд ингридиентов.""" def return_shop_list(cook_book, dishes, person_count): """Расчет необходимых для покупки ингридиентов.""" shop_list = {} for dish in dishes: for ingridient in cook_book[dish]: new_shop_list_item = dict(ingridient) ...
9ce433080385f3fc6ac6f9e1460a57d84b8e0273
rlyyah/erp_for_bill_gates
/inventory/inventory.py
10,809
3.5
4
""" Inventory module Data table structure: * id (string): Unique and random generated identifier at least 2 special characters (except: ';'), 2 number, 2 lower and 2 upper case letters) * name (string): Name of item * manufacturer (string) * purchase_year (number): Year of purchase * durabi...
8e9a3b4479db346d089f9926031dcc1a021b3fb8
tuouo/smallTools
/files/findFileByName.py
2,820
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os ''' Only under os.path.abspath('.'), a file can be distinguish as file. ''' def selectCondition(fileName, toFind, opt, path = '.'): flag = False if opt == 'name': if toFind == fileName.split('.')[0]: flag = True elif toFind =...
d5dfbda5011eac36fe7d54e581e5b28d52d11c17
lambdaydoty/programming-bitcoin
/ecc.py
5,703
3.640625
4
from random import randint class FieldElement: def __init__(self, num, prime): if num >= prime or num < 0: error = 'Num {} not in field range 0 to {}'.format(num, prime - 1) raise ValueError(error) self.num = num self.prime = prime def __repr__(self): r...
67ab4071647ea24bc2965f2226c90da56a89506b
umanelluri/test2
/sring+fun.py
197
3.765625
4
a="hello world!123" def let_dig(a): l=d=0 for i in range(len(a)): if a[i].isalpha(): l=l+1 elif a[i].isdigit(): d=d+1 print('letters are',l,'\n','digits are',d) let_dig(a)
e0338b9f8e57f5d54473d12ddd203f2bb216611e
BladeSides/Mathics
/Pytha.py
1,382
3.9375
4
print("PYTHAGOREAN TRIPLETS: \n") def run(): ar = [] y = 1 x = input("\nEnter the termination value or range of values (initial and final value)\n>>> ") for k in range (len(x)): if x[k] != ',': ar.append(x[k]) x = "".join(ar) l = x.split(" ") if(l.count("")>...
d765ef2276fd0aacd41d2d935929c593fc582173
nspavlo/AlgorithmsPython
/Algorithms/Goodrich/BinarySearch.py
757
3.90625
4
import unittest # The binary search algorithm runs in O(logn) time for a sorted # sequence with n elements. def binary_search(data, target, low, high) -> int: if low > high: return None else: mid = (low + high) // 2 if target == data[mid]: return mid elif target <...
d63c0d793b68e140e7381c19e59a5abe78fc0cec
pavanrao/python-projects
/wordplay/palindrome.py
640
3.8125
4
from pathlib import Path from pprint import pprint WORDS_FILE = '/usr/share/dict/words' def get_words(file_name=WORDS_FILE): try: text = Path(WORDS_FILE).read_text() except FileNotFoundError: print(f'File {file_name} not found.') return None words = text.strip().split('\n') wo...
744decff8f8848d3129e373dea40ec4a8a79ce6a
xennygrimmato/Data-Structures-and-Algorithms
/Longest Increasing Subsequence/lis.py
347
3.5
4
from bisect import bisect_left def lis(A, return_only_length=False): B = [] for a in A: i = bisect_left(B, a) if i == len(B): B.append(a) else: B[i] = a if return_only_length: return len(B) return B # Usage print(lis([3, 1, 5, 2, 4, 3])) print(li...
47e7c0230ca5611fabc28160162cfb9de5f2d2d1
dperezc21/ejercicios
/ejercicio/conteo_palidromas.py
538
3.640625
4
palabra = "holacomo" lista = [] cont = 0 def palindroma(string): lista = list(string) l = [] for i in lista: l.insert(0,i) cadena = ''.join(l) if cadena == string: return True else: return False for i in range(len(pa...
e2350657520b17cc90a0fb9406a4cc6f99cee53a
CookieComputing/MusicMaze
/MusicMaze/model/data_structures/Queue.py
1,532
4.21875
4
from model.data_structures.Deque import Deque class Queue: """This class represents a queue data structure, reinvented out of the wheel purely for the sake of novelty.""" def __init__(self): """Constructs an empty queue.""" self._deque = Deque() def peek(self): """Peek at the...
a1ae7f685f24b3d4ee366da29f46dd9894a82d8f
CookieComputing/MusicMaze
/tests/unit/model/graph/test_kruskal.py
7,128
3.625
4
from unittest import TestCase from model.graph.Graph import Graph from model.graph.kruskal import kruskal class TestKruskal(TestCase): """Tests to see that kruskal will return the set of edges corresponding to the minimum spanning tree from various graphs""" @staticmethod def contains_edge(v1, v2, e...
ee1afcafa7267dbe5629f8c5edc5ce99d7431966
KseniiaP-20/Python_Study
/task7_edit.py
1,224
4.03125
4
# Самостоятельное задание # Дана строка из двух слов. Поменяйте слова местами. string = 'test new' test_list = string.split( ) string_new = str(test_list[1] + ' ' + test_list[0]) print(string_new +'\n') # Домашнее задание import calendar # С помощью модуля calendar узнайте, является ли 2030 год високосным leap...
0d2c3e8c94d0669633ab4e938014fc5018a221d1
weekenlee/leetcode-c
/leetcodePython/leetcodePython/nqueues.py
678
3.5625
4
def solveNQueens(n): """ :type n :int :rtype: List[List[str]] """ def isqueens(depth, j): for i in range(depth): if board[i] == j or abs(depth - i) == abs(board[i] - j): return False return True def dfs(depth, row): if depth == n: ...
19ec1a1e76b9ef0cc6ed8340623b52505bf77a77
SliverOverlord/HPPython_research
/benchmarks/mat_multiplication_benchmark.py
5,257
3.890625
4
""" Author: Heecheon Park Note: Run python3 100x100_mat_generator.py first before running this program. Description: Read numbers from 100x100_matrix.txt Store each line into lists and numpy arrays. Then, benchmarks matrix multiplication. For example, list A and list B are 2-dimensional lists and performs list A ...
6559e13a3d8c617a02dc1ac6862d0961f66eef5e
SliverOverlord/HPPython_research
/benchmarks/mpi4py_benchmark.py
3,640
3.796875
4
#Author: Heecheon Park #Date: 8/11/2019 """ #Description: This program benchmarks numpy matrix multiplication vs standard python on mpi4py Read numbers from 100x100_matrix.txt Store each line into lists and numpy arrays. Then, benchmarks matrix multiplication. For example, list A and list B are 2-dimensional lists a...
da468dde42ec8cf37d5a6c500bcd7b844358708e
DaDa0013/data_structure_python
/My_first_balanced_tree_AVL/Main.py
11,636
4
4
class Node: def __init__(self, key): self.key = key self.parent = self.left = self.right = None self.height = 0 # 높이 정보도 유지함에 유의!! def __str__(self): return str(self.key) class BST: def __init__(self): self.root = None self.size = 0 def __len__(self):...
95e8e064dfa86d60977f725f8ec027dce139e0de
DaDa0013/data_structure_python
/Linked_List_Operation/Main.py
4,782
3.8125
4
class Node: def __init__(self, key=None): self.key = key self.next = None def __str__(self): return str(self.key) class SinglyLinkedList: def __init__(self): self.head = None self.size = 0 def __len__(self): return self.size def printList(self): # 변경없이 사용할 것! v = self.head while(v): print(v....
ee33c9f41a4d4a0f5a3211720ea315e529898c0f
krishnakaspe/bored_and_tried
/time_conversion.py
457
3.6875
4
def timeConversion(s): if "AM" in s: if s.split(':')[0] == '12': return s.replace('12','00').replace('AM','') return s.replace('AM','') else: hours = s.split(':')[0] if hours == '12': return s.replace('PM','') full_time = str((int(hours) + 12)) + ...
cce9f168e66431c2007ba19eebb889f3718c3ddf
worker-bee-micah/practice-only
/DnD_dice.py
894
3.546875
4
#code source Simon Monk 03_02_double_dice import random for x in range(1, 2): die_4 = random.randint(1,4) die_6 = random.randint(1, 6) die_8 = random.randint(1,8) die_10 = random.randint(1,10) die_12 = random.randint(1,12) die_20 = random.randint(1,20) total = die_4 + die_6 + die_8 + die_10 ...
abe30ce13e94e8525cb8800111924ee3177b638c
codewithgauri/HacktoberFest
/python/Algorithms/Implementation/Utopian Tree.py
252
3.609375
4
def utopianTree(n): k=int(n/2) m= 1 if n % 2 == 0 else 2 return 2 ** (k + m) - m if __name__ == '__main__': t = int(input()) for t_itr in range(t): n = int(input()) result = utopianTree(n) print(result)
9bc3ae714f881fd44890ed63429dc9bc4de89b5c
codewithgauri/HacktoberFest
/python/Learning Files/10-List Data Type , Indexing ,Slicing,Append-Extend-Insert-Closer look at python data types.py
1,129
4.28125
4
l=[10,20,22,30,40,50,55] # print(type(l)) # 1 Lists are mutable = add update and delete # 2 Ordered = indexing and slicing # 3 Hetrogenous # indexing and slicing: # print(l[-1]) # print(l[1:3]) #end is not inclusive # reverse a Lists # print(l[::-1]) # if you want to iterate over alternate characters # for value in l...
06e62fb57a55a421d1a01172ff5bd0bb3ba0e37e
codewithgauri/HacktoberFest
/python/pdf_scraper.py
484
3.5
4
#Downloading pdfs from a url and scraping them into a csv file #third part libraries needed: tabula-py and requests #pip install tabula-py #pip install requests import requests import tabula import os url= 'url.pdf' pdf = requests.get(url) pdf_name = input("Type the name for the pdf file: ") csv_name = input("Type...
f6588c81322c61935e9df0883ae83af41cee8229
codewithgauri/HacktoberFest
/python/Learning Files/28-Parsing JSON files using Python.py
1,456
3.84375
4
# json objects dict{"key":"value"} # numbers 10 10.25 int float # array[10,"string"] list # tuple # " " ' ' " " """ """ #Null None # true True # false False # json.load(f) load json data from a file ( or file like structure) # json.loads(s) loads jso...
9295676b5187719dd03a96c405f910a3e316a359
codewithgauri/HacktoberFest
/python/fizzbuzz.py
405
3.765625
4
def run_fizzbuzz(ceiling=25): """ Prints out a game of fizzbuzz up to the value of `ceiling`. :param ceiling: maximum value to count up to. :return: None """ for i in range(1, ceiling + 1): message = ''.join(('fizz' if not i % 3 else '', 'buzz' if not i % 5 else '')) print(messag...
9ac834cdaaac4f7666d02bb6838bb88ac965072a
codewithgauri/HacktoberFest
/python/countingnames.py
340
3.703125
4
z = input() x = open(z) lst = list() count = dict() for lines in x: if lines.startswith('From:'): z= lines.split() y= z[1] lst.append(y) # dict are made only by going through lists, so it is necessary to look through lists using for loop. for words in lst: count[words]= count.get(words, ...