blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5a1f4c5b2e16249516243c4df1418e245299f855
mn4774jm/PycharmProjects
/tutor_stuff/mipo_example1.py
1,723
4.1875
4
# # print('Welcome to More Than One Basket. You tell us the eggs and we tell you how many baskets you will need.') # # # def inputs(): # number_of_eggs = getPosint(message="Now, how many eggs are we working with?: ") # return number_of_eggs # # def getPosint(message): # ensures "int-able" input over 0 # po...
436311f64ec37c45c8d9312e60403c9e7f33575f
mn4774jm/PycharmProjects
/Pycharm_files/final_practice/final_1.py
2,885
4.125
4
# '''Final_practice1.py''' # # def main(): # while True: # try: # # number = input1() # new_num_added, num_added, num_add, num_mult=processing1(number) # output1(new_num_added, number, num_added, num_add, num_mult) # # except Exception as err: # print(...
7f2a07bfb814f4103b6f2b376ce15f9a8057de41
mn4774jm/PycharmProjects
/Pycharm_files/MaryBockProblems/coin_counter.py
2,524
4
4
'''Thomas Mullins coin_counter.py Def: Program asks the user for the numbers of coins that they have by type add values up both physical and monetary''' def main(): while True: try: quarters, dimes, nickles, pennies = input1() q_total, d_total, n_total, p_total, total_coins, grand_...
de3df175abfea015912a18ae9918e054d3dac670
mn4774jm/PycharmProjects
/Pycharm_files/Validation/Apollo.py
659
3.953125
4
'''Author: Thomas Mullins Date: 2/7/19 Apollo.py Definition: Improve Apollo program by adding additional comments and custom feedback''' #year = int(input('What year did Apollo 11 land on the moon? ')) #if year != 1969: #print(f'Sorry, {year} is the wrong answer.') #else: # print(f'Correct! {year} is right!') year =...
204173796dfdb2200a4c085ab870798f607f0b23
mn4774jm/PycharmProjects
/Pycharm_files/Functions_scope/chapter3lab.py
417
3.984375
4
def main(): stringData = input('Please enter a string: ') # input a string repeat = int(input('How many times to repeat? ')) # input a number stringRepeater(stringData, repeat) # function call with 2 arguments def stringRepeater(text, n): # called function receiving 2 parameter values repeatedString = ...
1a1ec99c3ebb7d2764239dc4094ecda75bcbbf30
mn4774jm/PycharmProjects
/Pycharm_files/Functions_scope/quizAvgFun.py
2,001
3.9375
4
print('\n') # Main def will always come first and should be empty def main(): try: #Exception handling begin #All main lines must be inside 'try:' to function #main program goes here #variables are assigned to inputData, data from input block always goes here quizScores, studentNumb...
f0b6147e2b70cb044fcffc74ef560aa405b52c0f
mn4774jm/PycharmProjects
/Pycharm_files/CSV/Chapter11_14_lab.py
1,474
3.90625
4
# import webbrowser, pyperclip, requests # # '''Using pyperclip and webbrowser modules''' # # #Minneapolis, MN # # address = pyperclip.paste() #Pastes the data copied to clipboard # # webbrowser.open('https://www.google.com/maps/place/' + address) # # # # '''Downloading data & files from the web''' # # import requests ...
7f99d555585db40556a4d78144447544b384c6a5
razack20/starting
/sort.py
115
3.515625
4
a={"johann":65,"ludwig":56,"frederic":39,"wolfgang":35} b=dict(sorted(a.items(),key= lambda x:x[1])) print(b)
3dc94525005efe1d55bf32cdb16a32ec66cd3fea
razack20/starting
/classes/passclass.py
738
3.875
4
#passing classs to another class class employee: def __init__(self, first, last, email): self.first = first self.last = last self.email = email class developer(employee): pass d1=developer("mohamad","razack","abdul@123") print(d1.first) print(d1.last) #********************************************************...
b5b798d5298faadb6920d6235b919cd8bc9e80ca
hairizuanbinnoorazman/Python_programming
/Algo/convert_base_num.py
873
4.375
4
# Convert the number to a different base # e.g. base10 to base5 # Convert 7 to base5 # 1 2 3 4 10 11 12 13 14 20 # # Convert 10 to base 7 # 1 2 3 4 5 6 10 11 12 13 # # Convert 15 to base 3 # 1 2 10 11 12 20 21 22 100 101 102 110 111 112 120 # # Convert 5 to base 2 # 1 10 11 100 101 def convert_base(convert_to_base: in...
a59373c0a8ce1ea59c7535db899ab8e0e68bee73
kimduuukbae/2DGP
/Drill/Drill 6-1/main.py
2,633
3.625
4
import turtle as t import random as r def stop(): t.bye() def draw_point(p): t.goto(p) t.dot(5, r.random(), r.random(), r.random()) def prepare_turtle_canvas(): t.setup(1024, 768) t.bgcolor(0.2, 0.2, 0.2) t.penup() t.hideturtle() t.shape('arrow') t.shapesize(2) t.pensize(5) ...
3553ebb86dadd19d6223d5235a118259fd51ee18
xjackx/EGit
/ITNPBD2 - Week 2 - Lab 2/lawoflargenos.py
2,944
3.703125
4
''' Name:Ranbir Dixit Program: Law of Large Nos. Version:1 Description: generates sample statistics based on different sample sizes in order to prove that as the number of samples drawn approaches infinity the sample statistic approaches the expected value https://en.wikipedia.org/wiki/Law_of_large_numbers ''' i...
88c1ff6dd408abc430dc48e4bab6d646f39c90ea
xjackx/EGit
/ITNPBD2 - Week 2 - Lab 2/lab5_q4.py
391
3.75
4
''' Name:Ranbir Dixit Program: Dictreader CSV Version:4 Description: uses DictReader to open a csv file and loop over all the rows to display only the names and email addresses of each person ''' import csv with open('C:\\Users\\rkd\\Desktop\\ITNPBD2\\lab-fileio-regex.csv') as f: r=csv.DictReader(f,delimite...
fa245bd360cb53ef2aad547d8d4a772eeb6ec253
xjackx/EGit
/ITNPBD2 - Week 2 - Lab 2/Lab5_q10.py
588
3.53125
4
''' Name:Ranbir Dixit Program: Dictreader CSV Version:10 Description: uses DictReader to open a csv file and loop over all the rows to display only the names of people starting in AX and prints this out to file ''' import csv import re with open("C:\\Users\\rkd\\Desktop\\ITNPBD2\\lab-fileio-regex.csv")as f: ...
78e90910659fe1ef2d8bfd5c9f58961afb8641cd
xjackx/EGit
/ITNPBD2 - Week 2 - Lab 2/test.py
776
3.9375
4
''' Name:Ranbir Dixit Program: Birthday Problem Version:1 Description: Simulates the birthday problem as found on (http://en.wikipedia.org/wiki/Birthday_problem). Probability that two people in a room share a birthday in a year that is not leap ''' import math #total number of people in room N=23 days_in_ye...
06223d6012231936d90c17556361811dfb2965e7
matt-c-knight/python_udemy
/practice5.py
376
3.78125
4
temps = [221, 345, 356, -9999, 230] # if doing if/else, for loop goes at very end new_temps = [temp / 10 for temp in temps if temp != -9999] newer_temps = [temp / 10 if temp != -9999 else 0 for temp in temps] print(new_temps) print(newer_temps) def mean(*args): args = [x.upper() for x in args] return sorted(a...
5934a891c4c61687f6f67bd90ed9dd76bf698a25
marshallhumble/Coding_Challenges
/Code_Eval/Easy/AgeDistrabution/AgeDistrabution.py3
1,826
4.375
4
#!/usr/bin/env python """ AGE DISTRIBUTION CHALLENGE DESCRIPTION: You're responsible for providing a demographic report for your local school district based on age. To do this, you're going determine which 'category' each person fits into based on their age. The person's age will determine which category they should ...
66ea1059dc1c2fd079b3d5d28b106bda9120e506
marshallhumble/Coding_Challenges
/Code_Eval/Easy/SimpleSorting/SimpleSorting.py3
345
3.828125
4
#!/usr/bin/env python from sys import argv in_file = argv[1] def simple_sort(file): with open(file, 'r') as myfile: for line in myfile: slist = (sorted(map(float, line.split(' ')))) answer = ' '.join(map(str, slist)) print(answer.strip()) if __name__ == '__main__': ...
42fc3d94a61072fb9d2c73700e19ccbeeec5a440
marshallhumble/Coding_Challenges
/Project-Euler/python/13.py
520
3.625
4
#!/usr/bin/env python """ Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. (Numbers in text file) """ # import time # filename = '13_numbers_to_sum.txt' # def get_sol(): # total = sum([int(s.strip()) for s in open(filename).readlines()]) # return int(str(total)[:10]) ...
64e6e4bebd37e5b7c7c35c4c81c23c16f468ca30
marshallhumble/Coding_Challenges
/Code_Eval/Easy/HexToDecimal/HexToDecimal.py3
376
3.5625
4
#!/usr/bin/env python from sys import argv in_file = argv[1] def hex_to_decimal(file): with open(file, 'r') as f: for line in nonblank_lines(f): x = int(line, 16) print(x) def nonblank_lines(f): for l in f: line = l.rstrip() if line: yield line ...
93efba2731b0c2321227be978a5c1970c2f68e20
marshallhumble/Coding_Challenges
/CheckIO/Elementary/7_Solve_Digit_Multiplication.py
667
4.25
4
#!/usr/bin/env python """ You are given a positive integer. Your function should calculate the product of the digits excluding any zeroes. For example: The number given is 123405. The result will be 1*2*3*4*5=120 (don't forget to exclude zeroes). Input: A positive integer. Output: The product of the digits as an in...
ca7283a889c48fe7af20b6553f70af0a32b4f55d
marshallhumble/Coding_Challenges
/Code_Eval/Easy/BitPositions/BitPositions.py3
445
3.546875
4
#!/usr/bin/env python from sys import argv def open_file(file): with open(file, 'r') as f: test_cases = f.read().strip().splitlines() for line in test_cases: n, p1, p2 = [int(num) for num in line.split(',')] print(check(n, p1, p2)) def check(n, p1, p2): n_binary = bin(n) if ...
6cc11bceba00287d687bad6d8d82842be251f3bf
marshallhumble/Coding_Challenges
/Code_Eval/Moderate/MinimumCoins/MinimumCoins.py3
593
3.96875
4
#!/usr/bin/env python from sys import argv coin_values = [1, 3, 5] with open(argv[1], 'r') as f: test_cases = f.read().strip().splitlines() def count_coins(): for test in test_cases: test = test.rstrip() value = int(test) total_coin_count = 0 for coin_value in reversed(coi...
7ea50ebc1ab0d1379cd3dcda5c13e1135c5b9c44
marshallhumble/Coding_Challenges
/Coding_Bat/Python/Warmup_1/pos_neg.py
1,449
4.3125
4
#!/usr/bin/env python """ Given 2 int values, return True if one is negative and one is positive. Except if the parameter "negative" is True, then return True only if both are negative. pos_neg(1, -1, False) == True pos_neg(-1, 1, False) == True pos_neg(-4, -5, True) == True """ def pos_neg(a, b, negative): if ...
5f74789b4df233c252dcb09cbb91cbdc746b776b
marshallhumble/Coding_Challenges
/Code_Eval/Easy/LowerCase Words/lowercase.py3
353
3.78125
4
#!/usr/bin/env python from sys import argv in_file = argv[1] def make_lower(file): with open(file, mode='r') as f: for line in nonblank_lines(f): print(line.lower()) def nonblank_lines(f): for l in f: line = l.rstrip() if line: yield line if __name__ == '__...
5644602b1da736494b3064dfb260465451a46828
marshallhumble/Coding_Challenges
/Code_Eval/Easy/SetIntersection/SetIntersection.py3
851
4.28125
4
#!/usr/bin/env python from sys import argv """ SET INTERSECTION CHALLENGE DESCRIPTION: You are given two sorted list of numbers (ascending order). The lists themselves are comma delimited and the two lists are semicolon delimited. Print out the intersection of these two sets. INPUT SAMPLE: File containing two lis...
908ee4b3d2e5da930dfba2ab68bbd78186dc6afc
marshallhumble/Coding_Challenges
/Code_Eval/Moderate/LetterToColumns/LetterToColums.py3
1,271
4.875
5
#!/usr/bin/env python """ COLUMN NAMES SPONSORING COMPANY: CHALLENGE DESCRIPTION: Microsoft Excel uses a special convention to name its column headers. The first 26 columns use the letters 'A' to 'Z'. Then, Excel names its column headers using two letters, so that the 27th and 28th column are 'AA' and 'AB'. After ...
fc691bac28143884a97bf52d719e72dcff98c0cb
Dragfy11/python_morpion
/morpion.py
6,729
3.703125
4
import sys class morpion: def __init__(self): self.jeu = ["", "1", "2", "3", "4", "5", "6", "7", "8", "9"] self.joueur = "" self.ordi = "" print("\n\t Jeu Morpion") print("\t--------------------") print("\n\n") def choix_pion(self): print("Choisis...
9f9ef2f8c4eda4a1f1249f00ad156fef4052adbd
mehmetkaya4036/word-occurance-counter
/WordOccuranceCounter.py
3,706
3.78125
4
import pandas as pd import string import matplotlib.pyplot as plt import numpy as np def readSubtitleToList(filepath): """this function reads file and returns as list of sentances splited line by line""" with open(filepath, encoding="cp437") as file: return file.read().splitlines() def eliminateNumE...
83f8be2917005c79c45b4a993d66821908757dfe
JuanesLamilla/ChessGame
/pieces.py
2,607
4.125
4
class Piece: """A chess piece located on the chess board. === Public Attributes === colour: The colour of the chess piece. Can either be 'B' or 'W'. """ colour: str def __init__(self, colour: str) -> None: """Initialize a new Piece with a given colour....
2b52877f48e274a6f78a772e7e07d33c50eee01b
calebm01/PythonPortfolio
/War/games.py
1,920
4.03125
4
#Caleb Mouritsen #2/13/19 #Games import Card def ask_yes_no(question): #Recallable yes or no question function, will be used on every yes or no question response = None while response not in ("y", "yes", "no", "n"): response = input(question).lower() return response def ask_num(question, low,...
df6c09cb637bd26cd6330d554743143d02b9345b
lolegoogle1/asyncio_learning
/syncfunc_in_eloop.py
823
3.953125
4
# loop.run_in_executor, start in the separate thread import asyncio from urllib.request import urlopen # a synchronous function def sync_get_url(url): return urlopen(url).read() # func for processing sync_function in the thread pool executor async def load_url(url, loop=None): if loop is None: rais...
e34deba69a469b1e4335160e1fecbfd03a2a26ec
dinuionica08/Projects.py
/Basics/instructions.py
493
4.3125
4
#in python we don't must put ; before an instruction #if -> a conditional instruction if 3 > 2 : print(" 3 > 2") elif 3 == 3 : print("3 == 3") else : print(" 2 < 3") #for -> a repetitive instruction with a known numbers of steps for x in range(0,5): print(x) #while -> a repetitive instruction with...
39eeb7583ad0d2baecd92bbd20b5e31dcc99466f
cyanidecupcake/learningPython
/dice.py
769
4.0625
4
#!/usr/bin/python ##Open in Terminal to play this game of chance. import random import time def dice() : ##Function player = random.randint(1,6) ai = random.randint(1,6) print("You rolled " + str(player) ) time.sleep(5) print("The computer rolled " + str(ai) ) time.sleep(3) if player > ai : print("Y...
1e32e9a09ed255adf8c34834cd359cef4047f45e
Programacion-Algoritmos-18-2/2bim-clase-01-daburneo1
/ejercicio-desarrollo-clases/paquete_modelo/mimodelo.py
994
3.640625
4
class Persona(object): def __init__(self, n, n1, n2, n3): self.nombre = n self.nota1 = float(n1) self.nota2 = float(n2) self.nota3 = float(n3) self.promedio = 0.0 def agregar_nombre(self, n): self.nombre = n def obtener_nombre(self): return self.nom...
1133ca4fe96bd9ec51709f16ce24e669cfce9c9b
anshoomehra/ud120-projects
/naive_bayes/nb_author_id.py
1,400
3.609375
4
#!/usr/bin/python """ This is the code to accompany the Lesson 1 (Naive Bayes) mini-project. Use a Naive Bayes Classifier to identify emails by their authors authors and labels: Sara has label 0 Chris has label 1 """ import sys from time import time sys.path.append("../tools/") from em...
219eecc444f66c76ca1ea6fbd7ea78b4070d9903
Vaibhav/Useful-Scripts
/BST/node.py
1,064
4
4
#Each node of the BST class Node(object): def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right class BST(object): def __init__(self): self.root = None self.size = 0 def add(self, item): self.size = self.s...
07be741c57cfa2987a070a6bc56f31a2e1a94894
ses10/practice-review
/cracking the code interview/data-structures/queue-using-2-stacks.py
942
4.34375
4
### Problem #Implement a MyQueue class which implements a queue using two stacks. ### Solution #We have 2 stacks old and new. When we want to enqueue an item, push it to new. #When we want to dequeue an item first if old is empty then for each item in new pop it #and push it to old. Now the first item that was enqueue...
952c4d4e6fc805552c88567544d495ff1c5cc4dc
ses10/practice-review
/data-structures/trie.py
1,194
3.9375
4
#Implmenation of Trie using keys containing only the lowercase alphabet class Node: def __init__(self): self.children = [None] * 26 self.isLeaf = False self.data = None class Trie: def __init__(self): self.root = Node() def insert(self, key, value): cur = self.root for char in key: index = ord(ch...
9b0ed284456d2fba9e61e325fe91177e65e9c72b
ses10/practice-review
/LeetCode/binary-tree-level-order-traversal.py
1,510
4.09375
4
#Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, #level by level). # # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): ...
b5186d855cf96fe6a90b54f995e76c87e443cde6
hfkaraduman/Python
/Döngüler/atm_makinesi.py
715
3.796875
4
print(""" ************************** ATM Makenesine Hoşgeldiniz İşlemler; 1.Bakiye Sorgulama 2.Para Yatırma 3.Para Çekme Programdan Çıkmak İçin 'q' ya basın ************************** """) bakiye=1000 while True: islem=input("İşlemi Seçiniz:") if (islem=="q"): print("Hoşçakalın...") brea...
4c8814fa8463e152c6b52ae19348975bf8c5e92a
hfkaraduman/Python
/Fonksiyonlar/ekok.py
1,194
4.09375
4
print(""" ************************************* Bu program kullanıcının girdiği 2 tane tamsayının ekokunu geriye döndürür Çıkmak için 'q' ya basınız ************************************** """) def ekok(sayı1,sayı2): sayı1=int(sayı1) sayı2=int(sayı2) tambölen_sayı1=[] tambölen_sayı2=[] ekok=[] ...
8a16a803f39a86aee8f585c4a476aab5efadc8a8
hfkaraduman/Python
/Koşullu Durumlar/beden_kitke_indeksi_hesaplama.py
525
3.5625
4
# coding=utf-8 print("""****************** BEDEN KİTLE İNDEKSİ HESAPLAMA ****************** """ ) boy=float(raw_input("Boyunuzu Giriniz:")) kilo=float(raw_input("Kilonuzu Giriniz")) beden_kitle_indeksi=kilo/(boy*boy) print("Beden kitle indeksiniz:{:.2f}".format(beden_kitle_indeksi)) if beden_kitle_indeksi<18.5: p...
a7795b2a005f2f41893136eaae0f47790fc82de4
hfkaraduman/Python
/Fonksiyonlar/ebob.py
1,117
4
4
print(""" ************************************* Bu program kullanıcının girdiği 2 tane tamsayının ebobunu geriye döndürür Çıkmak için 'q' ya basınız ************************************** """) def tam_bolenler(sayı): liste = [] for i in range(1, sayı + 1): if (sayı % i == 0): liste.append...
20d83f7097f1e702d7b76a848090aa2e5c7b2b86
christopherhui/ICPC-Practice
/2017 GCPC (Codeforces)/POF draft.py
787
3.5625
4
aList = [int(x) for x in input().split()] n = aList[0] m = aList[1] graph = {} visited = {} for _ in range(n): statement = input().split() worseCountry = statement[0] betterCountry = statement[len(statement) - 1] if betterCountry not in graph: graph[betterCountry] = [worseCountry] else: ...
8a74ffec703056b547806e07c7b8ffe45c554328
christopherhui/ICPC-Practice
/Codeforces Round #570 (Div. 3)/Nearest Interesting Number.py
165
3.59375
4
def hmm(n: int) -> int: a = 0 while (n != 0): a += n % 10 n //= 10 return a n = int(input()) while hmm(n) % 4 != 0: n += 1 print(n)
9941401b360baa406634214ebc893b0906ed7ac2
JonatanWang/regex_proj
/regex_strip_method.py
842
4.4375
4
""" Write a function that takes a string and does the same thing as the strip() string method. If no other arguments are passed other than the string to strip, then whitespace characters will be removed from the beginning and end of the string. Otherwise, the characters specified in the second argu- ...
d12f9adaed5a0c3bc7df9b4f18b4dd8176bf37da
roccminton/Diploid_Model_Two_Loci
/ContinuousModel/evolve.py
49,808
3.75
4
"""Evolve a given population according to the standard model of adaptive dynamics, called BPDL (Boker, Pacala, Diekmann and Law), with or without mutation and death due to natural reasons or due to competition. The scripts expects that a model name is passed as an argument. The model name must correspond to a file ca...
92d3eb04abe1c4e2fba66ea56483041aaada0544
kajal1301/Data-Structures-and-algorithms
/heaps.py
700
4.03125
4
#Heaps in Python: # Heap is a tree Data structure where each parent node is less than or equal to its child node. This is called Min Heap. # If each parent node is greater than or equal to child node then it is called Max Heap. # Creating a Heap: It is created by inbuild functon in python "heapq". import heapq H...
665e3ca7d340d10517666f524ac9dae308da2dad
cknduru/Baysic
/bayesian.py
3,347
3.671875
4
# inspired by https://monkeylearn.com/blog/practical-explanation-naive-bayes-classifier/ import sys text_p1 = ('the weather is lovely today', 'sunny') text_p2 = ('the weather is sunny and the skies are clear', 'sunny') text_p3 = ('the sun is out and it is hot', 'sunny') text_n1 = ('it is raining today', 'not_sunny') ...
03f2aa72cf2d95dad4e5ef1c6989f7cda8f02727
Manishthakur1297/Python-Examples
/Tiling Problem/tilingDP.py
262
3.640625
4
def tiling(n,m): tile = [0]*(n+2) for i in range(1,n+1): if i<m: tile[i] = 1 elif i==m: tile[i] = 2 else: tile[i] = tile[i-1] + tile[i-m] return tile[n] n = 7 m = 4 print(tiling(n,m))
7c08b5d75cfff7e8f039bd9f6c7628ceaa13ac35
Manishthakur1297/Python-Examples
/fibonacci/fibonaccirecursive.py
153
3.96875
4
def fibonac(n): if n==0: return 0 if n==1: return 1 else: return fibonac(n-1)+fibonac(n-2) n = 9 print(fibonac(n))
50b4b3a04ff024abd7eac2f0711fe796a02720b7
Manishthakur1297/Python-Examples
/dp/uglyNumbersLoop.py
344
3.671875
4
def divide(n,a): while(n%a==0): n = n//a return n def isUgly(n): n = divide(n,2) n = divide(n,3) n = divide(n,5) return 1 if n==1 else 0 def getUnglyNo(num): count = 0 i = 1 while(count<num): if isUgly(i): count+=1 i+=1 return i-1 n = 150...
389cb9ee0217f6815e61ca99473a05c3dd0633d1
QuwsarOhi/CodeTree
/temp/test.py
1,104
3.75
4
def check_overlap(self, area, obj_type): ''' checks if ano object (obj_type) is in the area area is given as = ((upperLeft_x, upperLeft_y), (lowerRight_x, lowerRight_y)) ''' def generate_house(self, house_size): ''' the functio...
6c664ada27960b886503afa9bea1dfe0a561ea55
QuwsarOhi/CodeTree
/language/python/hackerrank 30day/loops.py
128
3.515625
4
#!/bin/python3 n = int(input().strip()) # table of input number for x in range(1, 11): print("%d x %d = %d" %(n, x, x*n))
80f96566d44fd107f1f1781f8b2f0e3e0a7a1f01
QuwsarOhi/CodeTree
/solved_probs/UVA/10469.py
670
3.65625
4
# UVa # 10469 - To Carry or not to Carry # Bitwise from sys import stdin, stdout def printf(x): stdout.write(str(x) + '\n') def bit(x): for i in range(31, -1, -1): if x & 1<<i: print(1, end="") else: print(0, end="") print() def main(): X = stdin.readlines() #print(X) for x in X: a, b = map(int,...
0dc5f07a724a8e045db37b0ba19bd57dfeec09c9
Tarzan1009/PSI
/zad6-7.py
244
3.765625
4
lista = list(range(1,11)) print(lista) lista2 = lista[5:] lista = lista[:5] print(lista) print(lista2) lista = lista + lista2 print(lista) lista.insert(0, 0) print(lista) lista_kopia = lista lista_kopia.sort(reverse=True) print(lista_kopia)
1f12c03ac6eaff1d36de7a5c266f17e50bd95ddd
AlexSerdyuk83/python-project-lvl1
/brain_games/is_correct_answer.py
256
3.96875
4
def is_correct_answer(function, num, string): """The function checks the user's response and returns True if it is correct, and False if it is not""" result = function(num) return result and string == 'yes' or not result and string == 'no'
134da06ce92d7d1440fdb9d6c67d2a9d45567c11
vinymanya/python-fundamentals
/13.stars.py
653
4.21875
4
# Create a function that takes in a list of numbers and prints out stars. # Part 1 def draw_star(num_list): print num_list for x in num_list: print "*"* x draw_star([ 4, 6, 1, 3, 5, 7, 25 ]) # Part 2 # Modify the function above to accept mixed list, if the list item is an integer print stars # If it's a string...
266abc351bb446264912911ca16edbf10a5b7dca
vinymanya/python-fundamentals
/10.fun_with_functions.py
1,061
4.1875
4
# Odd/Even def odd_even(): for i in range(1, 2001): if i % 2 == 0: print "Numer is {}. This is an even number.".format(i) else: print "Numer is {}. This is an odd number.".format(i) # odd_even() # Multiply # Multiply each element in the list by the specified interger. def multiply(array, num): for x in ra...
b56e78743fd0fc83954548828a3da9a42b5c89a7
ADHARSHVAISHAG/c-programmer
/BEGINNER LEVEL/fac.py
197
4
4
a =int(input()) fl = 1 if a < 0: print("Sorry") elif a == 0: print("The factorial of 0 is 1") else: for i in range(1,a + 1): fl = fl*i print("The factorial of",a,"is",factorial)
f6dde37aefabdbfd263cf3e742a43b87944e48ca
greeshmagopinath/GiftCard
/find_price.py
1,601
4.0625
4
#!/usr/bin/env python import sys import argparse import utility def find_price(arr, target): ''' prints 2 items whose prices sum up to target :param arr: an array containing tuples(item,value) :param target: integer :return: ''' if len(arr) < 2: print("Not possible") return ...
0eab9063014da31df1a3442c5bbece13144b5125
YuryHerasimau/Gerasimov-git
/test_2.py
457
3.578125
4
#!/usr/bin/env python3 # 2. Составить алгоритм: если введенное имя совпадает с Вячеслав, то вывести “Привет, Вячеслав”, если нет, то вывести "Нет такого имени" import os name = input('Введите имя: ') if name == 'Вячеслав': print('Привет, ' + name) else: print('Нет такого имени') os.system("pause")
36fbc5e567280497a767d835aae1637139606fa9
djmorton42/code-advent-2016
/puzzle20/part2/range.py
1,306
3.90625
4
class Range: def __init__(self, start, end): self.start = start self.end = end def union(self, other_range): if other_range.start >= self.start and other_range.end > self.end: self.end = other_range.end elif other_range.start < self.start and other_range.end <= self....
7ccb18b562a6f84bb4ebcd7a74d8a038d858d60a
djmorton42/code-advent-2016
/puzzle22/part2/puzzle22_part2.py
4,210
3.578125
4
import re from node import Node from world import World from Queue import PriorityQueue #All nodes except the middle row (size around 500T) can fit #in the empty node. Once we get to the state where we have #the empty node to the left of the goal, we have a fixed number #of steps based on the number of columns. We c...
57b05f8fdc1e1e5407200e93daa63a1d3eecc79c
djmorton42/code-advent-2016
/puzzle21/part2/rotate_command.py
762
3.625
4
class RotateCommand: def __init__(self, direction, steps): self.direction = direction self.steps = steps def process(self, input): output = input for _ in range(self.steps): if self.direction == 'right': output = output[-1] + output[0:-1] ...
6527e8ad57e35cfe2d57c3f9d4c200dd6c599549
bitaan/Tic_tac_toe-game
/Mini_Project-2 - Tic Tac Toe Proj/board_draw.py
716
4.6875
5
def draw(row = 3, col = 3): print('_'*3*row) for i in range(0,row): #print('\n') #for j in range(0,col): print('| '*(col+1)) #print(' ') #print('\n') print('_'*3*row) c = draw(3,3) #Used only when we want to print a arbitrary board '''while True: t...
4da5e9da3843228e66cecfa40a8921ab542b29ae
Abdelaziz-pixel/Project-SIMON
/Player.py
725
4.0625
4
"""class""" class Player: """Constructive method containing two attributes""" def __init__(self): self.name = None self.score = 0 """method to request the player's name""" def PlayerName(self): name = input("Quel est votre nom ? ") while self.ControlName(name) is False: ...
63cd28c1c4492e9680e5edfcd404230aa7752f07
Henrique-Potter/differential-privacy-federated-learning
/torch_nn_1foward.py
917
3.765625
4
from torch import nn from util import load_mnist_traindataset # --- NN specialized for the MNIST using nn sequential --- # A sequential container. Modules will be added to it in the order they are passed to the constructor. # https://pytorch.org/docs/stable/generated/torch.nn.Sequential.html model = nn.Sequential(n...
46c9cf8021c97f65aef37fbd3622d712d4bd9fa9
John-Goya/Python-46
/John Goya - Drill - Range Function.py
163
3.890625
4
for i in range(4): print(i) # range(4) == [0, 4, 1] for j in range (3, -1, -1): print(j, end=' ') print() for k in range (8, 0, -2): print(k, end=' ')
fb87adf6fd48d2cc3e4effccd2d8a046c79ad649
Vi23nay/snake_game
/main.py
1,385
3.609375
4
from turtle import Screen from snake import Snake import time from food import Food from score_board import Scoreboard screen=Screen() screen.setup(width=600, height=600) screen.bgcolor("black") screen.title("My Snake Game") screen.tracer(0) snake=Snake() food = Food() scorecount=Scoreboard() screen.listen() scree...
e11a511dcf76002a4e665a6046bbbb9f0d7820d8
tomaziniale/randomPy
/pythonChallenge/ocr.py
227
3.53125
4
# Level 2 # OCR # http://www.pythonchallenge.com/pc/def/ocr.html text = open('texto.txt', 'r').read() o = {} for c in text: if c in o: continue o[c] = text.count(c) if o[c] < 10: print(c) print(o)
254d76d3c005b5d4313f24ddc59920e3de55f75b
Linlin9192/hkust_machine_learning
/hw/dendogram/distance.py
1,741
3.65625
4
import numpy from numpy import dot, sqrt def binarize_vector(u): return u > 0 def cosine_distance(u, v, binary=False): """Return the cosine distance between two vectors.""" if binary: return cosine_distance_binary(u, v) return 1.0 - dot(u, v) / (sqrt(dot(u, u)) * sqrt(dot(v, v))) def cosi...
b2d87e1f57505018beef4b8e61dfb42acfb556b7
mimica/Udacity-PythonIntro
/create_circle_from_square.py
421
3.734375
4
import turtle def draw_square(aTurtle): for i in range(1, 5): aTurtle.forward(100) aTurtle.right(90) def draw_art(): turtle.setup(1024, 768) window = turtle.Screen() window.bgcolor("lightgreen") window.title("Hello little baby") toto = turtle.Turtle() toto.shape("turtle") toto.shapesize(3, 3, 3) toto.co...
156d32920b90f5daecba485a37ad919b8a21da84
adrian-aleks/codility_training_tasks
/CountDiv.py
318
3.578125
4
def smallestDiv(A,B,K): for i in range(A, A+K+1): if i%K == 0: return K return None def solution(A, B, K): a = smallestDiv(A,B,K) if a == None: return 0 else: total_div = B//K min_div = (a-1)//K return total_div-min_div print(solution(10,54,1))
d3bee942286912adbf60b37241128358dc581671
JordanTallon/Codewars
/Python - Medium Level/GeneratePhoneNumber.py
493
4.15625
4
# Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number. # Example: # createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890" # The returned format must be correct in order to complete this challenge. # Do...
b14d1b274f4a473a1bc000373afe224f402f498f
Sebas2587/Practica_python
/Calculadora.py
983
4
4
def suma(a, b): return int(a) + int(b) def resta(a, b): return int(a) - int(b) def multiplicacion(a, b): return int(a) * int(b) def division(a, b): return int(a) / int(b) print('calculadora') print('selecciona una opcion...') print('selecciona: 1,2,2,3,4') choice = input() ...
d043a0b95b05e64bb4b6c6b55a4e6ce0274a0043
Sebas2587/Practica_python
/suma_promedio.py
380
3.890625
4
# Realizar un programa que lea cuatro valores numéricos e informar su suma y promedio. a,b,c,d = int(input('numero1:\n')),int(input('numero2:\n')),int(input('numero3:\n')),int(input('numero4:\n')) #calculamos la suma suma = a + b + c + d #calculamos el promedio promedio = round((suma) / 4) print('la suma de...
bf3b4d0567ea07d3d332a5929cbb1ccac6d8d22e
EdricChan03/computing-pt
/computing_pt_v2.py
4,114
3.84375
4
""" Task: 1. Input via spreadsheet 2. Compile data into list in a list 3. Ask how should the names be sorted 4. Algorithm to sort names (e.g. by low/medium/high ability or mixed) EXTRAS 1. Sort by gender on top of the 2 original listings (e.g. 1 female in every grp) """ """ # import random from tkinter import ttk, Tk, ...
7ca1be7e92ea95ab49abc09ab9c90f69fc33f734
snehitvaddi/Tic-Tac-Toe-Python-code
/Game Code.py
2,430
3.65625
4
import os os.system("cls") class Board(): def __init__(self): self.cells=["","","","","","","","","",""] def display(self): print(" {} | {} | {} ".format(self.cells[1],self.cells[2],self.cells[3])) print(" {} | {} | {} ".format(self.cells[4],self.cells[5],self.cells[6])) pr...
ea6281d6bc7c2c9c1ead61f5adc2df8e11fc7ae5
Clempops/algorithms
/queueTwoStack.py
314
3.78125
4
class MyQueue: def __init__(self): self.A = [] self.B = [] self.enqueued = False def enqueue(self, item): if not self.enqueued while A != []: B.append(A.pop()) A.append(item) self.enqueued = True def dequeue(self): if enqueued: A.append(B.pop()) enqueued = False return A.pop()
0a6cea73ce49c9dcb13ffe551eb9273174fc86cf
EgorPopelyaev/pystudy
/py_ex19.py
635
3.59375
4
def cheeseAndCrackers(cheeseCount, boxesOfCrackers): print "You have %d cheeses!" % cheeseCount print "You have %d boxes of crackers!" % boxesOfCrackers print "Man that's enough for a party!" print "Get a blanket. \n" print "We can give the function numbersdirectly:" cheeseAndCrackers(20, 30) print "Or, we can u...
c27418b297eff0b4366fb8f780e2d9bb98aa2fd5
dvsrk/LearnPython
/StringManipulation/find_all_permutations_of_a_string.py
434
3.53125
4
def permutation(str): if len(str) == 0: return [] if len(str) == 1: return([str]) l = [] for i in range(len(str)): first = str[i] rem_lst = str[:i] + str[i+1:] for p in permutation(rem_lst): l.append([first] + p) return l ...
da1893cd58dc2ea3faab91eab405a5439973bc9c
dvsrk/LearnPython
/Array_Sequences/01_Lists.py
1,819
3.953125
4
import timeit num = 10000 def method1(): l = [] for n in range(num): l = l + [n] print(l[0]) def method2(): l = [] for n in range(num): l.append(n) print(l[0]) def method3(): l = [n for n in range(num)] print(l[0]) def method4(): l = range(num) print(l[0]) d...
000be3ece07c02f744103adbde17cac0ad6ece04
callluis/Vigenere_Cypher_Python
/python_format_files/vigenere.py
1,513
4.0625
4
from helpers import rotate_character def encrypt(text, akey): alphabet = "abcdefghijklmnopqrstuvwxyz" string_text_key = creating_string_with_keyword(text, akey) encrypted = "" for index_value in range(len(text)): each_char = text[index_value] if each_char == " ": encrypted ...
22dffc99c02989af530d625f7e694a043277c770
GaloisInc/amase-code-generator
/concept/auto_generated/afrl/cmasi/AltitudeType.py
466
3.71875
4
#! /usr/bin/python class AltitudeType: AGL = 0 MSL = 1 def get_AltitudeType_str(str): """ Returns a numerical value from a string """ if str == "AGL": return AltitudeType.AGL if str == "MSL": return AltitudeType.MSL def get_AltitudeType_int(val): """ Returns a string represent...
06de7cb8aeb976cc70daebef6bc215bd90d84020
cormacdoyle/Rental-Car-Inventory-Tracker
/functionality.py
6,475
3.84375
4
import userinterface ''' given the list of all vehicles in the inventory, this function displays all of them, it contains a counter so that the information is easy to read ''' def displayAllInfo(car_inventory): counter = 0 for vehicle in car_inventory: counter += 1 print("\nVehicle ", str(count...
927eb6d8b274bd2bcc181e21f1b5f5d8839545fd
DorchuckSa/18.821-Project-1
/fib.py
10,304
4.09375
4
## Hacky script so far ## Goals: ## 1. Convert fibonacci number base to decimal base ## 2. Convert decimal base to fibonacci number base ## 3. Code up Addition algorithm once ## fib_dict = {0: 0, 1: 1, 2: 1, } ## Fibonacci number format (for now): ## Simply a string: "10110" = a_1 + a_2 + a_4 def from_fib_dict...
29e6246d313e7c983f38ffc9052e03b4e5b7ebaf
kmdbah/TEDS
/INFOSYS/neural network.py
11,277
3.84375
4
# The training data file name has to be provided in line 172, validation data in 176 # Dependent variable should be named "binary".Text data, when present, should be the last column, and named "text" # The confusion matrix will be in the output file nn_validation_confusion.png and validation data probabilities in Valid...
557ef28b49372321b3186245388ac5304d3609ff
5different/beakjoon_Algorithm
/2750_수정렬하기.py
145
3.5
4
range_num= int(input()) num_list = [] for i in range(range_num): num_list.append(int(input())) for i in (sorted(num_list)): print(i)
65fee536dcad47cdfce9a76d6ed6a0416fe8cf30
ccai1/mangosteens
/util/routes.py
2,187
3.546875
4
import json from urllib import request, parse # api authentication with open("data/keys.json") as f: api_keys = json.load(f) KEY = api_keys["routes_key"] ''' Getting json data from mapquest api (directions api) route_type can be either fastest, shortest, pedestrian, or bicycle ''' def getDirectionsInfo(start, end, ...
a1cde60ed5ac3b8093d684070e0165b9fb28ac15
RobbertSinclair/Chess
/main.py
9,019
3.5625
4
import pygame import time from piece import * pygame.init() #create the window screen = pygame.display.set_mode((800,800)) #Set up colours WHITE = (255, 255, 255) BLACK = (40,40,40) GREEN = (0,128,0) ORANGE = (255, 69, 0) board = [[0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0...
ab1de2c8d1420a23edc5fa72ee1562447ec4ac3f
vanikk06/Data-structures-and-Algorithms
/week_04/Test Quick sort_In place.py
1,220
4.0625
4
def quick_sort_temp(list, left, right): if left >= right: return list key = list[left] left_point = left right_point = right while left_point < right_point: #在left_point < right_point情況下進行,不用擔心相遇 while left_point < right_point and key <= list[right_point]: #從右向...
96f3f41d1c966a870ad8c217afb24c5cb27da55b
vanikk06/Data-structures-and-Algorithms
/week_07/Design merge sort.py
2,120
3.5
4
class Solution(object): def _divide(self, list, n:int): """ 分堆 """ if n <= 1: #迴圈出口:如果長度<=1就跳出 return list #分成兩堆 left = [] #左邊 right = [] ...
5d581438f20ab3fa41b93067d5ce495b21641b01
vikramanantha/Line-Plot
/linegraph.py
1,524
4.0625
4
print("LINE GRAPH") sc = 0 ft = 0 hc = 0 bs = 0 bk = 0 tn = 0 sw = 0 rn = 0 lc = 0 rg = 0 o = 0 input ("What sports do your friends like? This code will see how many like certain sports by creating it into a line graph.") input("Remember: Type \n 'SOCCER' for Soccer/Football \n 'FOOTBALL' for American Foot...
f580ec68e26b3502021d5b57b71793b7d95580ab
bacdoxuan/awesome-jobs
/getjobs.py
1,356
3.609375
4
""" Create jobs.db for website """ import sqlite3 from urllib.parse import urlencode import requests def init_jobs_db(): """get jobs information from https://github.com/awesome-jobs/vietnam/issues and store them in a sqlite3 database named jobs.db """ url_base = 'https://api.github.com/repos/awesome-j...
90404ca714962af685ad3e2cd5db59e08f6feb7b
Xirtsit/learning-python
/20.03.2021/ex4.py
1,698
4.1875
4
# dictionaries games = { "Doom": "1993", "Portal": "2007", "Guild Wars 2": "2012", "Super Mario Bros": "1985" } choice = None while choice != "0": print( """ Games 0 - exit 1 - find game 2 - add a new game 3 - modify game ...
02c5f3f0a8d13e37482cb1ed3efdcaa4653b1ce1
Xirtsit/learning-python
/16.03.2021/ex2.py
955
4.15625
4
# list's methods scores = [] choice = None while choice != "0": print( """ Scores 0 - exit 1 - show score 2 - add score 3 - delete score 4 - sort scores """ ) choice = input("Choice: ") print() if choice == "0"...
b2bf2e19a2eae4113cf04b250f48e2e76aa0c1d7
Xirtsit/learning-python
/16.03.2021/ex1.py
1,177
3.984375
4
# lists inventory = () # empty tuple if not inventory: # if inv is empty print("\nYour inventory is empty") input("\nContinue...") inventory = ["sword", "armor", "shield", "healing potion"] print("List of your equipment:") for item in inventory: print(...
89dfb307edb8602d9ce6c5f2864419a3af15b7e8
sarahfossheim/adventofcode17
/day-03/day03.py
1,017
3.859375
4
# Taxicab distance formula: # d = |x2 - x1| + |y2 - y1| # 17 16 15 14 13 # 18 5 4 3 12 # 19 6 1 2 11 # 20 7 8 9 10 # 21 22 23 24 25 # Data from square 1 is carried 0 steps, since it's at the access port. # Data from square 12 is carried 3 steps, such as: down, left, left. # Data from squa...