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
8cec80480a4e0c9726cffc124787c3bd28a37121
spitum/MITx-6.00.1x
/week 3/biggest.py
360
3.90625
4
def biggest(aDict): ''' aDict: A dictionary, where all the values are lists. returns: The key with the largest number of values associated with it ''' max_len = 0 max_key = "" for key in aDict: cur_len = len(aDict[key]) if cur_len>max_len: max_key = key ...
b0a221d7e4e1e6b4acc691effb23b3ae4061af42
phate09/SafeDRL
/polyhedra/script_sort.py
449
3.5625
4
import numpy as np a = np.array([[1, 2, 3], [2, 1, 3], [3, 2, 1]]) print(a) # sorted_a = a[a[:,2].argsort()] # First sort doesn't need to be stable. # sorted_a = sorted_a[sorted_a[:,0].argsort(kind='mergesort')] # sorted_a = sorted_a[sorted_a[:,1].argsort(kind='mergesort')] # sorted_a=np.sort(a,axis=0) # print(sorted_...
43524195534e641e35be2aca21378b509dc7b523
abhi9835/python
/MultiThreading.py
9,588
4.6875
5
""" example """ ##here all the statements are getting executed line by line. So, all of the lines comes under same thread print("statement") print("statement") print("statement") print("statement") print("statement") print("statement") print("statement") print("statement") print("statement") """ Now using multi_thr...
2c8fab0029e69d4de12efab80069f76bf3b93e1b
kbbingbai/WebSplider
/chapter03/Demo02.py
1,489
3.78125
4
#!/user/bin/env python3 # -*- coding: utf-8 -*- # @Time :2019/8/8 17:26 # @Author :zhai shuai """ 作用 一:读取csv的两种方式 难点 注意点 """ import csv def read_csv_01(): """ <class 'list'> ['张三', '22', '1', '中国'] <class 'list'> ['lishi', '52', '2', '四口'] """ with open(...
ab002ce8fbd32b618dc37ba70d18bf19682d7d06
tingyu/Leetcode
/Search in Rotated Sorted Array/Search.py
1,003
3.984375
4
'''' Search in Rotated Sorted Array Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array return its index, otherwise return -1. You may assume no duplicate exists in the array. '''' ...
1af4de39b76cbea35cbb36023d16cd66926a3967
rowaishanna/Intro-Python-II
/src/adv.py
10,924
3.75
4
from room import Room from player import Player from item import Item # create item objects that can be in the rooms or held by the player rock = Item('Rock') flashlight = Item('Flashlight') toilet_paper = Item('Toilet Paper') umbrella = Item('Umbrella') bag = Item('Bag') shoes = Item('Shoes') computer = Item('Compute...
039a1b96ee75fe7db97135030a01c286aa4ee6cc
skatz96/python_projects
/Arrays and Loops/2dArrays.py
1,640
3.875
4
# arr = [ # ['-','-','-'], # ['-','-','-'], # ['-','-','-'] # ] # def printBoard(arr): # print(arr[0][0] + " | " + arr[0][1] + " | " + arr[0][2]) # print(arr[1][0] + " | " + arr[1][1] + " | " + arr[1][2]) # print(arr[2][0] + " | " + arr[2][1] + " | " + arr[2][2]) # printBoard(arr) # print("") # arr[2][2] = 'X' ...
3d0870611aa1933731954766c9bf0023f489d650
jraigosa/python-challenge
/raigosa_hw_3_election.py
1,889
3.625
4
import os import csv # function builds a string of the candidates, votes and percentages from the results dict def build_votes_string( results, total_votes ): votes_string = "" for key in results: votes = results[key] votes_string += f"{key}: {votes/total_votes*100:.3f}% ({votes})\n" return...
fe7dad7782ed143451c1c48fe9b82333393a41e3
mmarotta/interactivepython-005
/guess-the-number.py
2,540
4.15625
4
import simplegui import random import math # int that the player just guessed player_guess = 0 # the number that the player is trying to guess secret_number = 0 # the maximum number in the guessing range (default 100) max_range = 100 # the number of attempt remaining (default 7) attempts_remaining = 7 # helper functi...
369e9921ec9ee26d2ddaafd4ed39e3b6e1401b3c
JustAidanP/Toy-NeuralNetwork
/toy-neuralnetwork/activation_functions/protocol.py
747
3.609375
4
import typing class ActivationFunction(typing.Protocol): def at(self, x: float) -> float: """ Returns the value of the function at the given input :param x: The input to the function :raises ValueError: Raised if the input isn't in the function's domain (function specific) ...
fcd4a847688be0325f862fd55f7055aa774b7210
hklb94/qualification-seminar-materials-2018
/session-7/homework_solutions/sherlock_sort.py
606
3.625
4
from cli_text_analysis import find_10_most_common_names from touple_sort import touple_bubble_sort as touple_sort def dict_to_touple(data_dict): """ Writes a dict as touple.""" new_touple = [] for name in data_dict.keys(): new_touple.append((name,data_dict[name])) return new_touple def sherlo...
b0e546dc50d719b4cf17166543a7c8dc7d0782f1
rodasalfaro/Ibmclouddev
/passtest.py
218
3.5
4
name = input('Ingresa tu nombre :') pass1 = input('Ingresa tu password :') longpass = len(pass1) passhidden = '*' * longpass print(f'password {passhidden} is {longpass} letters long') #print('*' *10)
842a0dd091380793d4c4b6a74ff39c09f3868572
effedib/the-python-workbook-2
/Chap_04/Ex_92.py
566
4
4
# Ordinal Date to Gregorian Date # This function takes an ordinal date as its parameter (year and day) and returns the day and month corresponding to that ordinal date # Non sono riuscito a risolverlo """ from Ex_91 import isLeap J = 105 + (365*2020) y = 4716 v = 3 j = 1401 u = 5 m = 2 s = 153 n = 12 w = 2 r = 4 B...
c439df82328da0dac0f03bfce15558cd274fb636
effedib/the-python-workbook-2
/Chap_01/Ex_28.py
358
4.1875
4
# Body Mass Index # Read height ed weight from user height, weight = input("Inserisci l'altezza in metri ed il peso in kg: ").split() # Convert the variables from string to float height, weight = [float(height), float(weight)] # Compute the BMI bmi = weight / (height * height) # Display the result print("Il tuo ind...
0fabb98b1c2a86dc202f5eecb58b9a5d3011019e
effedib/the-python-workbook-2
/Chap_06/Ex_142.py
463
4.4375
4
# Unique Characters # Determine which is the number of unique characters that composes a string. unique = dict() string = input('Enter a string to determine how many are its unique characters and to find them: ') for c in string: if c not in unique: unique[c] = 1 num_char = sum(unique.values()) print(...
f3a3d5e579092cfe05d7dd072336f7bb1336aafc
effedib/the-python-workbook-2
/Chap_04/Ex_87.py
536
4.28125
4
# Shipping Calculator # This function takes the number of items in an orger for an online retailer and returns the shipping charge def ShippingCharge(items: int) -> float: FIRST_ORDER = 10.95 SUBSEQ_ORDER = 2.95 ship_charge = FIRST_ORDER + (SUBSEQ_ORDER * (items - 1)) return ship_charge def main(...
182bf7a4858162954223f42c72bae8ff258c9ef0
effedib/the-python-workbook-2
/Chap_04/Ex_96.py
816
4.125
4
# Does a String Represent an Integer? def isInteger(string: str) -> bool: string = string.strip() string = string.replace(' ', '') if string == "": return False elif string[0] == '+' or string[0] == '-': if len(string) == 1: return False for i in string[1...
87d0ede5b1b93df61d11cd4fbc12ec748a6f4042
effedib/the-python-workbook-2
/Chap_01/Ex_06.py
541
4.09375
4
# Tax and Tip # Compute tax and tip based on the cost of a meal oredered at restaurant # Conversion rate TAX_RATE = 0.22 TIP_RATE = 0.18 # Read the cost of the meal meal = float(input("How much for the meal? ")) # Compute tax, tip and total tax = (meal * TAX_RATE) tip = (meal * TIP_RATE) total = (meal + tax + tip) ...
0050797557855d27088eed9dbf73027031d5de12
effedib/the-python-workbook-2
/Chap_01/Ex_14.py
390
4.46875
4
# Height Units # Conversion rate FOOT = 12 # 1 foot = 12 inches INCH = 2.54 # 1 inch = 2.54 centimeters # Read height in feet and inches from user feet = int(input("Height in feet: ")) inches = int(input("Add the number of inches: ")) # Compute the conversion in centimeters cm = (((feet * FOOT) + inches) *...
d2d56139ba9962a8faa87c358b5de4081255570e
effedib/the-python-workbook-2
/Chap_01/Ex_21.py
326
4.40625
4
# Area of a Triangle (3 sides) import math # Read the sides from user s1, s2, s3 = input("Inserisci i 3 lati: ").split() s1,s2,s3 = [float(s1), float(s2), float(s3)] # Compute the area s = (s1 + s2 + s3) / 2 area = math.sqrt(s * (s - s1) * (s - s2) * (s - s3)) # Display the result print("Area del triangolo: %.2f" %...
9b15b4f104947f8fd306784d22c0d4f12c574c55
effedib/the-python-workbook-2
/Chap_02/Ex_48.py
1,934
4.46875
4
# Birth Date to Astrological Sign # Convert a birth date into its zodiac sign # Read the date from user birth_month = input("Enter your month of birth: ").lower() birth_day = int(input("Enter your day of birth: ")) # Find the zodiac sign if (birth_month == 'december' and birth_day >= 22) or (birth_month == 'january'...
cc33896b761eba91b55e31d018a0b90fcfc46321
effedib/the-python-workbook-2
/Chap_05/Ex_113.py
504
4.28125
4
# Avoiding Duplicates # Read words from the user and display each word entered exactly once # Read the first word from the user word = input("Enter a word (blank to quit): ") # Create an empty list list_words = [] # Loop to append words into the list until blank is entered and if is not a duplicate while word != ''...
c5760240a654bab3f91c9148952005e4f6c02a32
effedib/the-python-workbook-2
/Chap_01/Ex_05.py
396
3.90625
4
# Bottle deposits # Conversion rate LESS_LITER = 0.10 MORE_LITER = 0.25 # Read the number of containers from user less_liter = int(input("How many containers until 1 liter? ")) more_liter = int(input("How many containers have more than 1 liter? ")) # Compute refund refund = (less_liter * LESS_LITER) + (more_liter * ...
48183c543b5a31ac2e622d8ebb0e17d33614de0f
effedib/the-python-workbook-2
/Chap_01/prove_chap1.py
300
3.796875
4
#Prova input e concatenazione stringhe quantity = int(input('quantity ')) price = float(input('price ')) total = quantity*price print('total ', total) name = "Francesco" name2 = "Attilio" quant = 6998 print("Benvenuti %s e %s, entrate pure se avete mangiato %.2f biscotti" % (name, name2, quant))
2acaac01a17a6d6f066b5f0a07cd1d59c8edccf1
effedib/the-python-workbook-2
/Chap_03/Ex_69.py
708
4.1875
4
# Admission Price # Compute the admission cost for a group of people according to their ages # Read the fist age first_age = input("Enter the age of the first person: ") # Set up the total total_cost = 0 age = first_age while age != "": # Cast age to int type age = int(age) # Check the cost if age ...
74a039d010118274d5d437cf34c016713a4cc210
effedib/the-python-workbook-2
/Chap_08/Ex_177.py
672
4.125
4
# Roman Numerals # This function converts a Roman numeral to an integer using recursion. def roman2int(roman: str) -> int: romans_table = {'M': 1000, 'D': 500, 'C': 100, 'L': 50, 'X': 10, 'I': 1} roman = roman.upper() if roman == '': return 0 if len(roman) > 1: if romans_table[rom...
dcbcbadbe3b33e0e50b792d7dafb00039f7ac41a
effedib/the-python-workbook-2
/Chap_08/Ex_183.py
1,706
4.21875
4
# Element Sequences # This program reads the name of an element from the user and uses a recursive function to find the longest # sequence of elements that begins with that value # @param element is the element entered by the user # @param elem_list is the list of elements to check to create the sequence # @return t...
95cffa4e93b281b5534b209ec831400b7c320de7
effedib/the-python-workbook-2
/Chap_04/Ex_99.py
463
4.21875
4
# Next Prime # This function finds and returns the first prime number larger than some integer, n. def nextPrime(num: int): from Ex_98 import isPrime prime_num = num + 1 while isPrime(prime_num) is False: prime_num += 1 return prime_num def main(): number = int(input("Enter a non negati...
4b25aa4c98e34db99f3fd8654477ce4c3a2cebad
effedib/the-python-workbook-2
/Chap_01/Ex_17.py
675
4.15625
4
# Heat Capacity # Read the mass of water and the temperature change mass_water = float(input("Inserisci la quantità d'acqua in ml: ")) temperature = float(input("Inserisci il cambio di temperatura desiderato in gradi Celsius: ")) # Define constants for heat capacity and electricity costs HEAT_CAPACITY = 4.186 ELEC_CO...
0472a1b1d4f3ad867a6b9d8c42477d8b9e36b7ba
effedib/the-python-workbook-2
/Chap_01/Ex_08.py
375
3.921875
4
# Wisgets and gizmos # Products cost in grams WIDGET = 75 GIZMO = 112 # Read the number of widgets and gizmos from user num_widgets = int(input("How many widgets? ")) num_gizmos = int(input("How many gizmos? ")) # Compute total weight in kg tot_weight = (num_gizmos * GIZMO + num_widgets * WIDGET) / 1000 # Display ...
aaa01b2ce41701e351067b0ea953db842e7a391f
effedib/the-python-workbook-2
/Chap_03/Ex_84.py
784
4.3125
4
# Coin Flip Simulation # Flip simulated coins until either 3 consecutive faces occur, display the number of flips needed each time and the average number of flips needed from random import choices coins = ('H', 'T') counter_tot = 0 for i in range(10): prev_flip = choices(coins) print(prev_flip[0], end=" ") ...
ecc22e65773bcc269fbd5fcc18abff21ab301162
effedib/the-python-workbook-2
/Chap_04/Ex_95.py
734
4.1875
4
# Capitalize It # This function takes a string as its only parameter and returns a new copy of the string that has been correctly capitalized. def Capital(string: str) -> str: marks = (".", "!", "?") new_string = "" first = True for i, c in enumerate(string): if c != " " and first is True: ...
c0e3387fb01e402d647e3c7954a4d8ccba653f6f
effedib/the-python-workbook-2
/Chap_01/Ex_22.py
325
4.34375
4
import math s1 = float(input('Enter the length of the first side of the triangle:')) s2 = float(input('Enter the length of the second side of the triangle:')) s3 = float(input('Enter the length of the third side of the triangle:')) s = (s1+s2+s3)/2 A = math.sqrt(s*(s-s1)*(s-s2)*(s-s3)) print('The area of the triangle i...
d41046ceabddad69bcbf57fdf7cad495c3a2b6d0
effedib/the-python-workbook-2
/Chap_03/Ex_76.py
908
4.1875
4
# Multiple Word Palindromes # Extend the solution to EX 75 to ignore spacing, punctuation marks and treats uppercase and lowercase as equivalent # in a phrase # Make a tuple to recognize only the letters letters = ( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", ...
4259b2e9d383daf2f189f50f7e40923b3354b1ae
effedib/the-python-workbook-2
/Chap_08/Ex_182.py
2,174
4.21875
4
# Spelling with Element Symbols # This function determines whether or not a word can be spelled using only element symbols. # @param word is the word to check # @param sym is the list of symbols to combine to create the word # @param result is the string to return at the end, it was initialized as empty string # @pa...
c48d9f119f221b6f5daabf3b49d61376341eaae9
NateRiv3r/HeroCTF_v2
/Challenges/Reverse/PyCode/solve.py
184
3.859375
4
#!/usr/bin/env python3 def deobfuscate(arg): ret = "" for i, c in enumerate(arg): ret += chr(ord(c) ^ (1 + i % 3)) return ret print(deobfuscate("M4j2l3GpQhUC"))
b89b31a8bb288cb2c6a3f579fc855240d64c75ad
rahultiwari796/google-translator
/data-translator/data_translator.py
1,587
3.609375
4
import json from py_translator import Translator from difflib import get_close_matches languages_code = json.load(open("language.json","r")) translator = Translator() def data_translator(word , language="en"): if language.lower() in languages_code.keys(): return translator.translate(word,dest=language.lo...
4fd179832c3a1365a1327021e3ba810f94319036
PT-DataStructures/Projects
/Chapter 2/binaryConversion.py
265
4.03125
4
binaryNumber = int(input("Enter a 3 digit number: ")) right = binaryNumber % 10 binaryNumber = binaryNumber // 10 middle = binaryNumber % 10 binaryNumber = binaryNumber // 10 left = binaryNumber % 10 answer = (left*4) + (middle*2) + (right*1) print(answer)
fa3eb4e33f17440f874f0787a49e7e048166ad1f
qlqldldh/Rgorithms
/baekjun/data_structure/workbook.py
603
3.578125
4
def get_value_from_input(): return map(int, input().split()) def sort_except_conds(_lst, _conds): for i in range(1, len(_lst) - 1): if _lst[i] > _lst[i + 1] and (_lst[i], _lst[i + 1]) not in _conds: _lst[i], _lst[i + 1] = _lst[i + 1], _lst[i] n, m = get_value_from_input() lst = [i for i...
be08725ada1a4fbae5f9ecfd754b74bcd222db61
davidfoerster/codegolf
/roman_numeral.py
5,338
3.59375
4
#!/usr/bin/python3 # -*- coding: utf-8 """ Convert between decimal and roman numerals """ __all__ = ('to_int', 'to_roman', 'NUMERAL_LIST', 'UNUMERAL_LIST', 'NUMERAL_MAP') import operator import itertools import collections.abc NUMERAL_LIST = ( ('M', 1000), ('D', 500), ('C', 100), ('L', 50), ('X', 10), ('V', 5)...
edbe35d0172d1c78007e551e10f97d53ac12cee4
axelniklasson/adventofcode
/2017/day4/part2.py
1,640
4.34375
4
# --- Part Two --- # For added security, yet another system policy has been put in place. Now, a valid passphrase must contain no two words that are anagrams of each other - that is, a passphrase is invalid if any word's letters can be rearranged to form any other word in the passphrase. # For example: # abcde fghij...
b4ce929864bad688bded24b0a746d9273fc8eff1
axelniklasson/adventofcode
/2017/day18/duet.py
6,689
3.703125
4
# --- Day 18: Duet --- # You discover a tablet containing some strange assembly code labeled simply "Duet". Rather than bother the sound card with it, you decide to run the code yourself. Unfortunately, you don't see any documentation, so you're left to figure out what the instructions mean on your own. # It seems lik...
080872ea6c787a54ffd7eadc0a52aeaca989c846
axelniklasson/adventofcode
/2017/day1/part2.py
1,270
3.8125
4
# You notice a progress bar that jumps to 50% completion. Apparently, the door isn't yet satisfied, but it did emit a star as encouragement. The instructions change: # Now, instead of considering the next digit, it wants you to consider the digit halfway around the circular list. That is, if your list contains 10 item...
00143be58afa005b48a78b79d1b3d6e95fc7862e
ryankupyn/euler5
/listcombiner.py
409
3.515625
4
def main(biglist, littlelist): messylist = biglist for hop in range(0, len(littlelist)-1): match = False for jump in range(0, len(messylist)-1): if messylist[jump] == littlelist[hop]: if match == False: messylist.pop(jump) match = T...
bcd5658e96365509fc455058cdb7d7a7fc7109c2
couchjd/School_Projects
/Python/EXTRA CREDIT/6PX_12.py
2,279
4.25
4
#12 Rock, Paper, Scissors Game import random import time def numberGen(): #generates a random value to be used as the computer's choice random.seed(time.localtime()) return random.randrange(1,3) def compare(compChoice, userChoice): #compares user choice vs computer choice compDict = {1:'rock', 2:'pa...
e7a492a39e77c0331f8e8b7bfaa845e2543f1692
couchjd/School_Projects
/Python/EXTRA CREDIT/3PX_7.py
322
3.65625
4
def getInfo(): global fatCal, carbCal fatCal = int(input("Grams of fat: "))*9 carbCal = int(input("Grams of carbs: "))*4 def printInfo(fatCal, carbCal): print("%d calories from fat.\n%d calories from carbs." % (fatCal, carbCal)) def main(): getInfo() printInfo(fatCal, carbCal) main(...
dee422c3e12ec0314c0e72fe187454934fd3104e
couchjd/School_Projects
/Python/EXTRA CREDIT/6PX_5.py
394
4.15625
4
#5 Kinetic Energy def kinetic_energy(mass, velocity): kEnergy = ((1/2)*mass*velocity**2) #calculates kinetic energy, given a return kEnergy #mass and velocity def main(): print("The kinetic energy is %.2f joules." % kinetic_energy(float(input("Enter mass of object: ")), ...
934219588347e4e2310dea8fce58c9e5b444c279
couchjd/School_Projects
/Python/EXTRA CREDIT/4PX_10.py
645
3.953125
4
#10 BMI Enhancement def getInfo(): info = {} info['height'] = float(input("Height (in inches): ")) info['weight'] = float(input("Weight (in pounds): ")) return info def calcBMI(height, weight): BMI = (weight*703/(height**2)) return BMI def optimal(BMI): if BMI < 18.5: print("You ar...
a7da3adbb2fd3759b7f7351f744e237bc0adb71d
couchjd/School_Projects
/Python/EXTRA CREDIT/5PX_9.py
339
4.0625
4
#9 Star Pattern def printStars(): for x in range(7): #iterates through outer loop #inner loop -- designates number of * #to be printed per line for y in range(7-x): #prints * pattern and strips trailing newline print('*', end='') print() def main(): pr...
2d209365530fb7f60103d7b3db3112959a355d6c
hitsumabushi845/Lab-repository
/Input_A_coefficients_nx.py
5,906
3.5625
4
import numpy as np import matplotlib.pyplot as plt import networkx as nx def show_graph(G): pos = nx.spring_layout(G) nx.draw_networkx_nodes(G, pos, node_size=700) nx.draw_networkx_edges(G, pos, width=6) nx.draw_networkx_labels(G, pos,font_size=20, font_family='sans-selif') plt.show() if __name_...
0cb19f7f08eafd81fcffed36d46a2a7ac42eda3a
MandipGurung233/Decimal-to-Binary-and-vice-versa-conversion-and-adding
/validatingData.py
2,976
4.25
4
## This file is for validating the entered number from the user. When user are asked to enter certain int number then they may enter string data type ## so if such cases are not handled then their may occur run-time error, hence this is the file to handle such error where there is four different function..:) de...
73ef198d2a47801f75df1a48393244febed9e85a
daneven/Python-programming-exercises
/Exersise_4.py
1,034
4.34375
4
#!/usr/bin/python3 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ''' @Filename : Exersises @Date : 2020-10-28-20-31 @Project: Python-programming-exercises @AUTHOR : Dan Even ''' #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ''' Question 4 Level 1 Question: Write ...
e1bf679159088e4653f0c21ebac8311e63b6b304
daneven/Python-programming-exercises
/Exersise_5.py
1,104
4.375
4
#!/usr/bin/python3 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ''' @Filename : Exersises @Date : 2020-10-28-20-31 @Project: Python-programming-exercises @AUTHOR : Dan Even ''' #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ''' Question 5 Level 1 Question: Define...
22f022815490d7772899cfa78e7aeade93d4d7a8
jayyei/Repositorio
/Python/REST-APIS-flask-pyhton_jose_udemy/refresh-python/list-comprehesion.py
439
3.90625
4
numbers = [1, 3, 5] doubled = [] for num in numbers: doubled.append(num * 2) print(doubled) doubled_comp = [num * 2 for num in numbers] print(doubled_comp) friends = [ "Rolf", "Sam", "Samantha", "Saurabh", "Jen"] starts_s = [] for friend in friends: if friend.startswith("S"): starts_s.append(fr...
d0e89556bbb48099744671e76eb14da7272b1719
trichau123/DataStructure261
/DoubleLinklist.py
2,778
4.03125
4
class Node(object): def __init__(self,d, n = None , p = None): self.data = d self.next_node = n self.prev_node = p #getter setter access change, data, pre, next pointer def get_next (self): return self.next_node; def set_next (self, n): self.next_node = n de...
e5fc31293d27eb55ed14df44c3f4cf6074ae161b
trichau123/DataStructure261
/HashtablePlayername.py
963
4
4
def display_hash(hashTable): for i in range(len(hashTable)): print(i, end = " ") for j in hashTable[i]: print("-->", end = " ") print(j, end = " ") print() # Creating hashtable as # A nested list HashTable = [[] for _ in range(10)] #Hasing Function to return #Key for every value def Hash...
386a08d884f31869297b8579cd3e2742bfe796a7
dragomir-parvanov/VUTP-Python-Exercises
/03/2-simple-calculator.py
1,049
4.375
4
# Python Program to Make a Simple Calculator def applyOperator(number1, operator,number2): if currentOperator == "+": number1 += float(number2) elif currentOperator == "-": number1 -= float(number2) elif currentOperator == "*": number1 *= float(number2) elif currentO...
e937a40b941f9599bcd2ecf407d8cc03376403b4
dragomir-parvanov/VUTP-Python-Exercises
/02/8-negative-positive-or-zero.py
237
4.40625
4
# Check if a Number is Positive, Negative or 0 numberInput = int(input("Enter a number: ")) if numberInput > 0: print("Number is Positive") elif numberInput < 0: print("Number is negative") else: print("Number is 0(ZERO)")
e70614b7782ba5b61320707ad74e575e15bdf656
dragomir-parvanov/VUTP-Python-Exercises
/04/5-website-suffixes.py
542
3.953125
4
#["www.zframez.com", "www.wikipedia.org", "www.asp.net", "www.abcd.in"] #Write a python program to print website suffixes (com , org , net ,in) from this list urlList = ["www.zframez.com", "www.wikipedia.org", "www.asp.net", "www.abcd.in"] suffixes = [] for url in urlList: currentSuffix = "" for symbol in re...
64bac979efd85d472f6fb58eece170f939404800
germano-beep/trabalho01_SAS
/rsa_algoritmo.py
2,245
3.5
4
# biblibote para gerar número aleatórios import random import time # função utilizada para encontrar o maximo divisor comum, utilizado para # escolher um número entre 1 < e < φ(x) def mdc(num1, num2): while(num2 != 0): resto = num1 % num2 num1 = num2 num2 = resto return num1 # função ...
7f71c4c433a9e8c1b2e32686587dfeda41676378
vlodko-afk/-Python
/Змійка/snake.py
1,686
3.578125
4
import pygame from qui import Qui qui = Qui() class Snake: def __init__(self): self.head = [45,45] self.body = [[45,45],[34,45]] self.run = 0 self.k = 0 def moove(self,control): if control.flag_direction == "RIGHT": self.head[0] += 11 elif ...
0e3c33418d2b105126d18b41669d3074719d9045
EMathioni/Web-Status-v1
/Web Status.py
1,304
3.625
4
import requests print("Bem vindo ao Web Status v1 :)") print("GitHub: https://github.com/EMathioni") print("------------") def request_func(lista_url): try: request = requests.get(lista_url) if request.status_code >= 200 or request.status_code <= 299: print(f"{lista_url} --> Site online") elif requ...
126f258cc39563b311a03ca2198a13f0edb0e658
robotsecr/hangman
/hangman.py
1,686
4.03125
4
import random def hangman(choice): key=True key2=True key3='n' turn=9 key4='Y' word=['theroy','chocolate','court','joly','robot','water','Bang'] theword=random.choice(word) if not choice.isalpha(): print("Sorry You enter a special character,try again") else: while key: if key3 =='Y': print("Enter yo...
99c21a0fd97ebd27001ddb6b20e74440e9a381a3
kristhefox/Exercises
/Ex2/ex2_2.py
158
3.609375
4
# ex2_2 from itertools import permutations def perm(x): """ this function generates all permutations of x """ l = list(permutations(x)) print(l)
79ccbbac541b5bbac6dcb0a60aba12948e5f246e
cchvuth/acss-grp-5-git-python
/mazes.py
1,862
4.125
4
# Mazes # by Yuzhi_Chen def Mazes(): print(" ") print("The width and height should be more than 5 and the height should be an odd number.") print(" ") input_str = input("Enter the width of the maze: ") w = int(input_str) input_str = input("Enter the height of the maze: ") h = ...
f976c2242466f0bb05e759080fbbf959bb7ef18e
ytrevor81/NFL-Stats-Library
/main/data_functions.py
48,912
3.734375
4
'''This page holds reusable code used in views.py. All of the functions on this page are used more than one time''' class DataTypes(object): '''Used to process a list of strings to a list of usable integers or floats.''' @classmethod def integers(cls, list): '''Returns a list of integers, from a l...
62f7c4c4dd0480985a1d47b524b507d61a799102
Syakyr/My-Python-Projects
/ProjectEuler/0004-Largest-palindrome-product.py
1,609
4.0625
4
# A palindromic number reads the same both ways. The largest palindrome made from # the product of two 2-digit numbers is 9009 = 91 × 99. # # Find the largest palindrome made from the product of two 3-digit numbers. # # Answer: 906609 import time # Own method def LPF(lowerlimit, upperlimit): # LPF: Largest Palindrome...
b44d5b3751726974f98a036bd32bbf7304800d51
ChenFangzheng/learn_python
/mlearning/predict_house_price.py
1,467
3.640625
4
import matplotlib.pyplot as plt import numpy as np import pandas as pd from sklearn import datasets, linear_model def get_data(file_name): data = pd.read_csv(file_name) X_parameter = [] Y_parameter = [] for single_square_feet, single_price_value in zip(data['square_feet'], data['price']): X_...
7a524d1793978f551518f5df72a828dec309f827
ChenFangzheng/learn_python
/mlearning/pla.py
1,739
3.5625
4
# -×-coding:utf-8-*- ''' PLA算法实现 ''' ITERATION = 70 W = [1, 1, 1] def createData(): lines_set = open('./data_pla.txt').readlines() linesTrain = lines_set[1:7] # 测试数据 linesTest = lines_set[9:13] # 训练数据 trainDataList = processData(linesTrain) # 生成训练集(二维列表) testDataList = processData(linesTest...
6b28edfa6ae646c7854e7f8ffd543c305ab41643
mattwkim/Sudoku-Solver
/SudokuSolver.py
6,730
3.96875
4
#Backtracking Algorithm import sys def CreateDataStructures(boxanswers, rowanswers, columnanswers,allanswers, board): """Creates containers for all answers in each box/row/column, a container for looking up the box number, and a list of all of the empty spaces that need to be filled.""" increme...
88ff525e751b4e21af01de0d2aa9cc52d988ed40
da1dude/Python
/OddOrEven.py
301
4.28125
4
num1 = int(input('Please enter a number: ')) #only allows intigers for input: int() check = num1 % 2 # Mudelo % checks if there is a remainder based on the number dividing it. In this case 2 to check if even or odd if check == 0: print('The number is even!') else: print('The number is odd!')
dc58e4a968e6ecce87703b47f326f54e0e379943
vochong/project-euler
/python/euler31.py
543
3.78125
4
def euler31(): """ In England the currency is made up of Pound and pence, and there are eight coins in general circulation. 1p, 2p, 5p, 10p, 20p, 50p, 1P (100p), 2P (200p) It is possible to make 2P the following way: 1x1P + 1x50p + 2x20p + 1x5p + 1+2p + 3x1p How many different ways can 2P be using any nu...
9b8a3c6ded901f9118d2c57711ccb8b5da636eb0
vochong/project-euler
/python/euler36.py
486
3.71875
4
def euler36(): """ The decimal number, 585 = 1001001001 (binary), is palindromic in both bases. Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. (Please note that the palindromic number, in either base, may not include leading zeros.) """ pal_sum = 0 for i i...
da8ee01d08de784ad544821d8e0ee80f27776068
vochong/project-euler
/python/euler02.py
515
3.875
4
def euler02(): """ Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the e...
3ceb0c1cd1512ed659b103bae8a072e1b745df82
vochong/project-euler
/python/100+/euler179.py
427
3.59375
4
def calc_divisors(n): divisors = [1] * n for i in range(2, n): idx = i while idx < n: divisors[idx] += 1 idx += i return divisors def euler179(): count = 0 divs = calc_divisors(10**7) for i in range(2, len(divs)): if...
d409efb3c78133b7efc92c50dad941c739dc30b9
vochong/project-euler
/python/euler13.py
303
3.75
4
def euler13(): """ Work out the first ten digits of the sum of the following one-hundred 50 digit numbers [in nums.txt]. """ f = open("nums13.txt") nums = [int(line) for line in f.read().split()] return sum(nums) / (10 ** (len(str(sum(nums))) - 10)) if __name__ == "__main__": print euler13()
4bf109d541dd10a1b1af3ba0ac00d38939ca67a8
vochong/project-euler
/python/euler26.py
986
3.75
4
def cycle_length(n): numer = 1 digits = [] rems = [] while True: while numer < n: numer *= 10 digits.append(numer / n) numer = numer % n if numer == 0: return 0 if numer in rems: return len(rems) - rems.index(numer) else: rems.append(numer) def euler26(): """ A unit fraction contains 1 in th...
4e645f0c66a23bc33c01b9ad78105a705905d93c
vochong/project-euler
/python/euler57.py
240
3.59375
4
def euler57(): acc = 0 m, n = 3, 2 for _ in range(1000): if len(str(m)) > len(str(n)): acc += 1 tmp = n n = m + n m = n + tmp return acc if __name__ == "__main__": print euler57()
df66b4e640200c8a5750d6c0a04ab741d6eb3800
vochong/project-euler
/python/euler04.py
443
4
4
def euler04(): """ A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. Find the largest palindrome made from the product of two 3-digit numbers. """ largest = 0 for i in range(100, 1000): for j in range(i, 1000): if str(i*j...
16dae1476ddab46356f037c74325bd1282b3d1ea
vochong/project-euler
/python/euler19.py
1,623
3.9375
4
def euler19(): """ You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-...
70b965084212803618ab17088fa8774e8262664d
vochong/project-euler
/python/euler94.py
750
3.515625
4
def gen_tris(lim): x, y, x1, y1, n = 2, 1, 2, 1, 3 count = 0 while 2*x + 2 < lim: # side is 1 unit shorter than the other two a = (2*x - 1) / 3.0 if int(a) == a: area = (y * (a-1)) / 2.0 if area != 0 and int(area) == area: count += (3*a-1) # side is ...
f27e042ae7271ac8e602927fb0095069b3f11f17
vochong/project-euler
/python/euler52.py
586
3.984375
4
def euler52(): """ It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. """ x = 0 while True: x += 1 if sorted(str(x)) != sorted(str(2*x)):...
a69c16de15dd9f0992acaa9ac2f63d93401faf0e
AnhLe1194/Python_HW
/PyBank.py
2,276
3.953125
4
#!/usr/bin/env python # coding: utf-8 # In[30]: import os import csv # In[31]: csvpath = os.path.join("Resources", "Homework_03-Python_Instructions_PyBank_Resources_budget_data.csv") # In[32]: total_months = 0 total_revenue = 0 months = [] total_change = [] with open(csvpath) as csvfile: csvreader = cs...
749a76a746928c91872d26ebca75224085054c07
asdvalenzuela/common-interview-algorithms
/BinarySearchTree.py
3,368
3.9375
4
class Node(object): def __init__(self, value): self.left = None self.right = None self.value = value class BinarySearchTree(object): def __init__(self): self.root = None def append_node(self, value): new_node = Node(value) if not self.root: self.root = new_node else: node = self.root whil...
83456b904d04c8a26548b10f8cee5b22b9556ccb
DilshanKMGL/Data-Structures-and-Algorithms-Specialization
/Algorithmic Toolbox/week1_programming_challenges/2_maximum_pairwise_product/max_pairwise_product.py
553
4.0625
4
# python3 def max_pairwise_product(numbers): n = len(numbers) max_num1_i = 0 max_num1 = 0 max_num2 = 0 for i in range(n): if numbers[i] > max_num1: max_num1 = numbers[i] max_num1_i = i for i in range(n): if (i != max_num1_i) and (max_num1 >= numbers[i] ...
b9bd153886194726840fa940231afed161399585
andrew5205/Python_cheatsheet
/string_formatting.py
712
4.15625
4
name = "Doe" print("my name is John %s !" %name) age = 23 print("my name is %s, and I am %d years old" %(name, age)) data = ["Jonh", "Doe", 23] format_string = "Hello {} {}. Your are now {} years old" print(format_string.format(data[0], data[1], data[2])) # tuple is a collection of objects which ordered and i...
ca889379fb4d1134377f2ffde3785300c8758b1b
andrew5205/Python_cheatsheet
/basic_operator.py
511
4.03125
4
number = 1 + 2 * 3 / 4.0 print(number) # 2.5 remainder = 11 % 3 print(remainder) # 2 squared = 7 ** 2 print(squared) # 49 helloworld = "hello" + " " + "world" print(helloworld) # hello world lotsofhellos = "hello" * 10 print(lotsofhellos) # hellohel...
a8316089e57e625eac3b7e9177ae3bb99a3bccb3
SevagSA/Python-Sudoku-Solver
/sudoku.py
2,075
4.0625
4
import numpy as np sudoku = [[7, 8, 0, 4, 0, 0, 1, 2, 0], [6, 0, 0, 0, 7, 5, 0, 0, 9], [0, 0, 0, 6, 0, 1, 0, 7, 8], [0, 0, 7, 0, 4, 0, 2, 6, 0], [0, 0, 1, 0, 5, 0, 9, 3, 0], [9, 0, 4, 0, 6, 0, 0, 0, 5], [0, 7, 0, 3, 0, 0, 0, 1, 2], [1, 2, 0, 0, 0, 7, 4, 0, 0], [0, 4, 9, 2, 0, 6, 0, 0, 7]] def num...
2b4f687603b1b2031d4e262f114feb7585b18f4f
PauloViniciusBaleeiro/Uri---Online
/1117.py
367
3.8125
4
valid = False results = [] media = [] while valid == False: grade = float(input()) if(grade < 0 or grade > 10): results.append('nota invalida') else: media.append(grade) if(len(media) == 2): valid = True break calc = ((media[0] + media[1])/2) results.append('media = {0:.2f}'.format(round(cal...
c64b382012f4e0aa7560e7d569b5db246e9dd412
PauloViniciusBaleeiro/Uri---Online
/1157.py
77
3.75
4
num = int(input()) for x in range(1, num+1): if num % x == 0: print(x)
5f66c231ee35a96bab5b05ee2ff8e1099e3349a4
PauloViniciusBaleeiro/Uri---Online
/1075.py
89
3.515625
4
number = int(input()) for x in range(10000): if (x % number) == 2: print(x)
eeab4bd1d13f757a5623153e791684991d56fa1e
suvanshm/DSAlgos
/DataStructures/Tree.py
4,117
4.0625
4
# Implementing Basic Tree class TreeNode: def __init__(self, root): self.value = root self.children = [] def add_child(self, child): self.children.append(child) def __repr__(self, level=0): ret = "--->" * level + repr(self.value) + "\n" for child in self.children:...
88134e17aaeb97f8fefcc20e3a573fc765eeab12
MajorAxe/TimusProbs
/1567 SMS-спам.py
184
3.6875
4
s = input() cost = 0 for i in range(0, len(s)): if s[i] in 'adgjmpsvy. ': cost += 1 elif s[i] in 'behknqtwz,': cost += 2 else: cost += 3 print(cost)
45d6419a59532d7ef44b4caaab13a1fd5bb35f56
SR-KING/Surendhiraraj-S---Project-Shape-AI-
/Surendhiraraj S - Project ( Shape AI)/Surendhiraraj S - Project ( Shape AI).py
1,214
3.78125
4
import requests api_key=str(input("Enter your API KEY: ")) place=input("Enter your City name: ") complete_api_link="https://api.openweathermap.org/data/2.5/weather?q="+place+"&appid="+api_key api_link=requests.get(complete_api_link) api_data=api_link.json() temperature_of_city=((api_data['main']['temp'])-...
44c6688195cb8dfd4f3fe27055bfa604d9a8237b
LukeMainwaring/EEG_classifier_spotify
/spotify.py
2,795
3.609375
4
''' This program includes aspects from the rest of the project. The Spotify program begins by creating a classifier from the initial dataset we've been using, and then using the classifier to predict whether or not the input data is relaxing. Since I have no ability to generate EEG data, I have hardcoded test_data for ...
97eee67fca78bfeeef2fe40c038268d273c5ab9e
MGoldstein18/learningPython
/k_nearest_neighbor.py
1,335
3.75
4
# import relevent Python modules from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier from matplotlib import pyplot as plt # load data breast_cancer_data = load_breast_cancer() # explore data print(breast_cancer_data.da...
cfc6c866b7bc9589d35671f741f84c2cc7eb1ac7
MGoldstein18/learningPython
/dictionaries.py
2,006
4.03125
4
# working with given dictionary to create, modify and display a new dictionary # create an empty dictionary medical_costs = {} # populate the dictionary medical_costs.update({"Marian": 6607.0, "Vinay": 3225.0, "Connie": 8886.0, "Isaac": 16444.0, "Valentina": 6420.0}) # update a value in the dic...
12ab0b7cf9e33922490155949cdaa9ac1f8dba9f
Kejioo/lyoshas
/Проект Эйлера/9 (произведение тройки Пифагора).py
331
3.515625
4
import math found = False for a in range(1, 1000): for b in range(1, 1000): c = math.sqrt(a**2 + b**2) if a + b + c == 1000: c = int(c) print("a = {0}, b = {1}, c = {2}\na * b * c = {3}".format(a, b, c, a * b * c)) found = True break if found: ...
240582ed7bb2192cca7faf69f0a641d283e2e628
ChangePlusPlusVandy/change-coding-challenge-sarah-s-zhang
/apiconnect.py
1,846
3.75
4
# @author Sarah Zhang, Twitter API Sample Code import config import requests # class ApiConnect # Accesses the Twitter API to get Tweets from a specific username class ApiConnect: # Constructor def __init__(self, username): self.__username = username self.__authSuccess = False heade...
aa078c26fa428cd3e72a12aad485d19cdebf6665
KrishantTharun/python-beg
/vowel_r_consonent.py
205
3.984375
4
ya=input() if ya.isalpha(): xa=ya.lower() if xa=='a' or xa=='e' or xa=='i' or xa=='o' or xa=='u': print("Vowel") else: print("Consonant") else: print("Invalid")