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
22b7b2b479501be16f1f9a5e7c416ad930ab616e
pankrac88/jarowinkler
/jaro.py
1,811
3.640625
4
def main(): string1 = 'DWAYNE' string2 = 'DUANE' print('Jaro Winkler distance between {} and {} is: {}'.format(string1, string2, jaro_winkler_distance(string1, string2))) def jaro_winkler_distance(string1, string2): jaro = jaro_distance(string1, string2) prefix = 0 for index, char in enumerate...
1352e5b2dfc41ea64f3377886a59b7212b6fe19c
basant88/workshop
/atmsolution/atm.py
564
3.71875
4
money=450 request=800 if(request>money): request=money if(request<=0): print"Please enter right request" while request>0: if(request>=100 ): print "give 100" request=request-100 elif(request>=50): print "give 50" request=request-50 elif(request>=10): ...
711de50425119b20d1d9f4235689895dd250332c
joydas65/GeeksforGeeks
/Check_If_Two_Strings_Are_K_Anagrams_Or_Not.py
303
3.5
4
from collections import Counter def areKAnagrams(str1, str2, k): # Code here n,m = len(str1),len(str2) if n != m: return False diff = Counter(str1) - Counter(str2) if sum(diff.values()) > k: return False return True
d718154c1e137b75120f98a6d69e7b68543c1a36
joydas65/GeeksforGeeks
/Remove_duplicate_elements_from_sorted_array.py
251
3.515625
4
def remove_duplicate(n, arr): #Code here i,j = 0,1 while j < n: if arr[i] != arr[j]: i += 1 arr[i] = arr[j] j += 1 return i + 1
74714d6f271872cd968f90bcfedae438293b9e5e
ignatiusmb/algorithms
/codeforces/736A.py
134
3.734375
4
n = int(input()) if n == 2: print(1) else: res = 0 while n > 1: n /= 2 res += 1 print(res)
f55fec35f55466baad3f0bb42940f95d783c5bb3
tushgaurav/SpeechSynth
/main.py
500
3.578125
4
import branding import pyttsx3 branding.welcome() speaker = pyttsx3.init() choice = 'Y' yes = choice.upper() while choice == yes: text = str(input("What do you want me to say?")) speaker.say(text) speaker.runAndWait() choice = str(input("Try again? (Y/N)")).upper() if choice == 'n'.upper(): pri...
09ffd49011960c69936b0e5a522471ea6aa5f4d0
ishaansathaye/python
/essentials/files.py
912
4.03125
4
## 6/25/19 ## ########### Creating, Reading, Writing Files ############ testFile = open("Test.txt", 'w') # overwrite/write into the file testFile.write("Python is an interpreted, high-level, general-purpose programming language\n") testFile.write("Created by Guido van Rossum and first released in 1991\n") testFile.wr...
0066e31adfc13218b909be728f275dc2809a3a88
bmanandhar/final_online_coding
/subsets.py
443
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Mar 24 14:09:36 2018 @author: bijayamanandhar """ def subsets(s): if s == []: return [s] sets = [s] for i in range(len(s)): temp_subsets = subsets(s[:i] + s[i+1:]) for subset in temp_subsets: if subset ...
55894d2ab1f45b597e5d13dd3a3ff25a5db7681f
danimtk/distance-similarity-measures
/5_cosine_similarity.py
1,682
3.796875
4
# #Desenvolvido por Andre H. Costa Silva baseado no codigo fonte #de Rodrigo Mendes (implementado em javascript): https://github.com/rdgms/hello_cosine_similarity # import math import string def calculate_frequence(word): result = {} for char in string.ascii_lowercase: if char not in result: ...
cdec4625a7ff92699a60fd2e15121161ba50dad9
Lemmy-21/Es_Scuola
/c.[ 10 - 12 ]/2scheda.py
544
3.78125
4
''' [es 2 - scheda] Scrivi una programma che data in ingresso una lista A contenente n parole, restituisca in output una lista B di interi che rappresentano la lunghezza delle parole contenute in A. ''' num_parole = int(input("quante parole vuoi inserire?\n")) parole = [] numeri = [] for i in range(num_parole): ...
28ff656b10ad06b6c5e79f3eb948a20f8ff685ce
Lemmy-21/Es_Scuola
/e.[ 20 - 01 ]/2p201.py
799
3.78125
4
''' [es 2 - pag 201] Data la parabola y = ax² + bx + c, definisci due funzioni per calcolarne i punti significativi: vertice e fuoco. Le due funzioni ricevono come parametri a, b, c e restituiscono il valore calcolato ''' def fuoco(a, b ,c, delta): x_fuoco = -b/2*a y_fuoco = (1-delta)/(4*a) return x_fuo...
8660e5a159f3228293182dc2b163c6c2af6321a1
Lemmy-21/Es_Scuola
/b.[ 03 - 12 ]/28p73.py
909
3.734375
4
''' [es 28 - pag 73] Dato un elenco di studenti partecipanti a una gara sportiva di lancio del peso (nome studente, lancio), visualizza il valore del lancio del vincitore (valore massimo). ''' studenti = [] lanci = [] vincitori = [] start = int(input("quanti studenti vuoi immettere?\n\n")) for i in range(start): ...
d21ef77fe0a38294473fa75eaebf7064544a2acd
trokas/optimal_polygon
/optimal_polygon.py
5,076
3.5625
4
import numpy as np def _angle(u, v, w, d='+'): """ Measures angle between points u, v and w in positive or negative direction Args: u (list): x and y coordinates v (list): x and y coordinates w (list): x and y coordinates d (str, optional): direction of angle '+' = counter...
2368073e9f1c7eb84b753d111c1d0826cc1f8796
Bastlwastl42/advent_of_code
/common/word_jitter.py
581
3.609375
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- """ Created on 25/12/2020 18:48 @author: Sebastian Lehrack word_jitter.py is a script for.... """ from itertools import permutations import duden if __name__ == "__main__": print("Welcome to word_jitter.py") letters = ['a', 'e', 't', 'i', 'p', 's', 'r'] for...
902525dacd2a677ed65b4f1bf530e268c225c4ae
Bastlwastl42/advent_of_code
/10/jotage_adpaters.py
1,808
3.625
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- """ Created on 10/12/2020 08:11 @author: Sebastian jotage_adpaters.py is a script for advent of code day 10 """ import math import os from typing import List from common import load_input_file def find_next_drei(counter: int, list_of_diffs: List[int]): for next_cou...
cf57371e6b6dd439dec168da65702c4e210f1688
Bastlwastl42/advent_of_code
/09/XMAS_decipher.py
1,742
3.796875
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- """ Created on 09/12/2020 08:02 @author: Sebastian XMAS_decipher.py is a script for advent of code day 9 """ import os from typing import List from common import load_input_file SUBSET_LENGTH = 25 def find_sum_of_two(number: int, subset: List[int]): if len(subset)...
3a21120c6e8e9814b6dad06431ec73beaeee9ff2
Roha123611/activity-sheet2
/prog15.py
366
4.1875
4
#prog15 #t.taken from fractions import Fraction def addfraction(st_value,it_value): sum=0 for i in range(st_value,it_value): sum=sum+Fraction(1,i) print('the sum of fractions is:',sum) return st_value=int(input('input starting value of series:')) it_value=int(input('enter ending value ...
506e8e1db70f0189b7968120eb48790a65da4f77
Roha123611/activity-sheet2
/PROG14.py
581
3.796875
4
#PROGRAM14 #T.TAKEN def area(l1,l2,b1,b2): area1=l1*b1 print('area of 1st rectangle is:',area1,'cm\u00b2') area2=l2*b2 print('area of 2nd rectangle is:',area2,'cm\u00b2') if l1>l2 or b1>b2: q=area1-area2 print('the remaining area is:',q,'cm\u00b2') else: q=area...
32fcf90d6429304258bd4bc490c989c49de69209
faneyer101/bootcamp-python-day01
/ex03/matrix.py
11,544
3.65625
4
from numbers import Real class Vector: def create_list_with_size(self, size): i = 0.0 liste = [] if size > 0: while i < size: liste.append(float(i)) i += 1 return liste else: print("Need size > 0") quit...
4a917541eaf35c7e398ec8a4bb6acd1774541c9e
helgurd/Easy-solve-and-Learn-python-
/differBetw_ARR_LIST.py
978
4.4375
4
# first of all before we get into Python lists are not arrays, arrays are two separate things and it is a common mistakes that people think that lists are the same arrays. #in array if we append different data type will return typeerror which that is not case in the list. # ARRAY!=LIST ###example 1 python list import...
bfa347e6247121c5cd10b86b7769eb368d5ae487
helgurd/Easy-solve-and-Learn-python-
/open_and_read _string.py
1,310
4.6875
5
#write a program in python to read from file and used more than method. # read from file -------------------------------------------------------------------- #write a program in python to read from file and used more than method. # method1 # f=open('str_print.txt','r') # f.close() #--------- # method2 called con...
110009318a4996746d53867b54bf38c1d7505d90
helgurd/Easy-solve-and-Learn-python-
/test_ideas/test1.py
11,330
3.6875
4
# forels # nums= [2,3,4,5, 25] # for num in nums: # if num %6 ==0: # print (num) # break # else: # print("not found!") ##Iterable and Itrator # Class Itrations # class MyRange: # def __init__(self, start, end): # self.value=start # self.end= end # def __iter__(self): # ...
f3951834abe42483c298e731ba41af7bc8324249
helgurd/Easy-solve-and-Learn-python-
/tempCodeRunnerFile.py
418
3.953125
4
s = input("Input a string") d=0 l=0 for c in s: if c.isdigit(): #check whether the character is Digit or not. If true, digits value will be incremented d=d+1 elif c.isalpha():#check whether the character is alphabet f true, alphabets value will be incremented l=l+1 else: # if not digi...
0497b119d6b793597533e3c40e51d05f1f51e451
veekaybee/dailyprogrammer
/abundant.py
672
3.5625
4
#Reddit Daily Programmer Challenge 243 : Abundant and Deficient Numbers #https://www.reddit.com/r/dailyprogrammer/comments/3uuhdk/20151130_challenge_243_easy_abundant_and/ #Python 2.7 locally from __future__ import division def factors(n): divisors = [] for i in xrange(1, n+1): if n % i == 0: divisors.appe...
2eae3f58e756b2a3204b1a4a8758b5540a4d2fc6
elenatsvayberg/sandbox
/hout11_ex4.py
3,993
3.6875
4
class InventoryItem(object): def __init__(self,title, description, price, store_id): self.title = title self.description = description self.price = price self.store_id = store_id def __str__(self): return self.title def __eq__(self, other): if self.store_id ...
f336514c918accb4cf14a2990353cb9fb341bc80
elenatsvayberg/sandbox
/hour9_pr.py
235
4
4
students = {} while True: name = input("Enter student name otherwise input q: ") if name =='q': break else: grade = (input("Enter letter grade:")).capitalize() students[name] = grade print(students)
fe2798b7f063cae4f4e4320d95fb68b26ead1ef1
elenatsvayberg/sandbox
/hour13.py
285
3.625
4
import this print(this) from random import randint for i in range(10): print(randint(1, 10)) frequency = {} for i in range (1000): num = randint(1, 10) if num in frequency: frequency[num] = frequency[num] + 1 else: frequency[num] = 1 print(frequency)
f00bb3fb5cc3f5b5c8f867fb37363c604fcbb525
xrysa13/Hello-Git
/FizzBuzz.py
310
3.796875
4
def FizzBuzz(n): for i in range (1, n+1): if (int(i/3)==(i/3)) and (int(i/5)==(i/5)) : print ('FizzBuzz') elif int(i/3)==(i/3): print ('Fizz') elif int(i/5)==(i/5): print ('Buzz') else: print (i) FizzBuzz(50)
eec230933cd3a5f53c910851b1672bfbbc630895
sdenisen/python
/euler-problems/euler-problem-96/unittests_2.py
1,733
3.53125
4
import unittest from sudoku import Sudoku __author__ = 'Sergey' class Test(unittest.TestCase): def setUp(self): str_sudoku = """003020600 900305001 001806400 008102900 700000008 0067...
f8e98dae7cba7a462bdb84c56f8ebf24f70c6e00
Tan2Pi/tictactoe
/game.py
2,840
3.84375
4
from board import Board from minimax import * from copy import deepcopy from math import inf class Game: def computerPlayer(self, player): move = alphabeta(deepcopy(self.board.board), self.board.depth(), -inf, +inf, player) self.board.makeMove(Board.conversion[(move['i'],move['j'])]) def h...
d745c39b69365e6b78fdc10d11888edd82cb45b6
PDXDevCampJuly/ChelsDevCamp_July27-1
/Cheapblackjack.py
1,932
4.09375
4
class Deck: """ Class for handling a deck of cards. """ def __init__(self, cards_in_deck, num_decks=4): self.num_decks = num_decks self.cards_in_deck = [] # self._build_deck() pass def deal(self, num_cards=1): """ input: num_cards returns: list of card(s) """ pass def _build_deck(self, cards)...
c19c60767e32be95a053a19b4e1f30dfffef86e2
PDXDevCampJuly/ChelsDevCamp_July27-1
/angrydice_testable/test_check_stage.py
4,319
3.765625
4
__author__ = 'Chelsea' import unittest from angry_dice import Angry_dice class CheckStageTest(unittest.TestCase): """Tests if current stage changes if given different die values""" def setUp(self): self.angry_game = Angry_dice() def tearDown(self): del self.angry_game #Both dies ar...
59568bceca27a4b6af2299750e2aca0374a19d94
thiagohoh/Compiladores-
/syntatic/arvore.py
604
3.90625
4
# Class responsible for creating a tree class Arvore: def __init__(self, type, children=None, leaf=''): """ :param type: :param children: Child :param leaf: leaf """ self.type = type if children: self.children = children else: self.children = [] self.leaf = leaf def __str__(self): return ...
00f17d3bdc290dbea3da6ff3688143f7bd5ca929
FelixOpolka/Statistical-Learning-Algorithms
/decision tree/DecisionTree.py
20,040
3.59375
4
"""A C4.5 Decision Tree learner for classification problems""" import math def increment_counter(dictionary, key): """Increments the counter for a given key in the given dictionary or sets the counter to 1 if it does not yet exist.""" if key in dictionary: dictionary[key] += 1 else: d...
0f07f871dd65bed0be5f75b169d979ac5cddf761
niusuyun/python_study_2
/Lesosn03/1_fib.py
199
3.921875
4
#作业1:编写一个函数,用递归的方法输出斐波那契额数列第n项 def fib(lim,a=1,b=0,lev=1): if lev == lim:return a+b return fib(lim,b,a+b,lev+1) n=10 print(n,fib(n))
9a4999999cab00a3913b7faab78be296e284e01d
stephaniecanales/Programacion-ISemestre
/Python/Recursion de pila/main2.py
205
3.53125
4
def suma (x): if isinstance (x, int) and x >= 1: return suma_aux(x) else: return "error" def suma_aux (x): if x == 0: return 0 else: return (x + 5 *((x*x)**2)) + suma_aux (x-1)
4910502d44791ee4bbe6e34b53ef3bd8a3b5a1fe
stephaniecanales/Programacion-ISemestre
/Python/Recursion de cola/scanales_true false.py
324
3.578125
4
def true_false (num): if isinstance (num, int) and (num >= 0): return true_false_aux (num) else: return "Error" def true_false_aux (num): if num == 0: return True elif ((num % 10) >= 0) and ((num % 10) <= 4): return true_false_aux(num // 10) else: return Fal...
919369682856b3cb8b256ca76180c1cdadc82abf
bradleymailbox/hangman
/Hangman/printmodule.py
1,129
3.859375
4
# list of messages that can be displayed msgs = ['### W E L C O M E T O H A N G M A N ###\n' '-----------------------------------------', #0 'Please enter a letter you wish to guess:', #1 'You have already guessed that letter', #2 'Validating the letter entered',...
5bf6484ef615dcfa7bccc4809cf09eb79c3dee75
Zhangjt9317/SOM_GUI
/code_snippets/listbox.py
4,249
3.890625
4
# load a Tkinter listbox with data lines from a file, # sort data lines, select a data line, display the data line, # edit the data line, update listbox with the edited data line # add/delete a data line, save the updated listbox to a data file # used a more modern import to give Tkinter items a namespace # tested with...
d1693ef6fcc1b6ba1fef6099fcd59649e92a69ec
bugagashenki666/test_python_at_the_lessons
/use_if.py
333
3.96875
4
""" bla-bla-bla """ # a = int(input()) # if a < -10: # print("Left") # elif a > 10: # print("Right") # else: # print("Center") a = float(input()) b = float(input()) if a > b: print(str(a) + " greater than " + str(b)) print("something again") else: print(str(b) + " greater than ...
889360e9b574c5380347bf7285c3aeb003032936
psarkozy/HWTester
/MIHF/RouteSearch/solution.py
4,655
3.890625
4
import math import time # This class represents a node class Node: # Initialize the class def __init__(self, id, location): self.id = id self.location = location self.neighbours = [] self.parent = None self.g = 0 # Distance to start node self.h = 0 # Distance t...
a7389c1a3072d7e807073d81d23add6e89d0456d
Drawell/DialogGraphRedactor
/acts_system/character_emotion.py
196
3.5
4
from enum import Enum class CharacterEmotion(Enum): NEUTRAL = 0 SAD = 1 ANGRY = 2 HAPPY = 3 FRIGHTENED = 4 SURPRISED = 5 def __str__(self): return self.name
75964cfe90c20dbed87347908b79b899f45b593a
sachi-jain15/python-project-1
/main.py
1,206
4.1875
4
# MAIN FILE def output(): #Function to take user's choice print "\nWhich script you want to run??\n Press 1 for students_to_teacher\n Press 2 for battleship\n Press 3 for exam_stats" choice=int(raw_input('Your choice: ')) # To take users input of their choice if (choice==1): print "\n STUDENTS_...
9df2e9950b56a4680da5b5c54bfbc2b94dcbe51f
kjk402/PythonWork
/programmers/7.py
271
3.8125
4
def solution(numbers, hand): answer = '' for i in numbers: if i == 1 or i==4 or i==7: answer += 'L' elif i == 3 or i==6 or i ==9: answer +='R' return answer num = [1, 3, 4, 5, 8, 2, 1, 4, 5, 9, 5] print(solution(num))
dc3ada013dea708c0e056a4178615fb425fcf83a
kjk402/PythonWork
/leetCode/easy/PalindromeNumber.py
662
3.765625
4
# Palindrome Number # https://leetcode.com/problems/palindrome-number/ class Solution: def isPalindrome(self, x: int) -> bool: number = str(x) length = len(number) is_even = False if x < 0: return False if length == 0: return False if length %...
0d6f051635628848a510784ac928422460f7bfb3
kjk402/PythonWork
/codeup100/codeup_28~46.py
1,340
3.71875
4
# #28 # var = int(input()) # print(var) # # #29 # integer = float(input()) # print(round(integer, 11)) #30 # var = int(input()) # print(var) # #31 # octal = int(input()) # print(oct(octal)[2:]) #8진수 함수 스면 뒤 두자리만 출력 # 32,33 # hexa = int(input()) # print((hex(hexa)[2:]).upper()) # # 34 8진수 10진수 # octal = '0o' +inpu...
e0beda07eaee8330ca4e94dfaa8d39785f1f41ae
kjk402/PythonWork
/leetCode/easy/RomanToInteger.py
500
3.6875
4
# Roman to Integer # https://leetcode.com/problems/roman-to-integer/ class Solution: def romanToInt(self, s: str) -> int: dic = {"M": 1000, "D": 500, "C": 100, "L": 50, "X": 10, "V": 5, "I": 1} result = 0 for i in range(len(s) - 1): num = dic[s[i]] nextNum = dic[s[i ...
eb6a972179c098e29ddbfc9c5f53bc518ff21960
kjk402/PythonWork
/pythonrogic/sentence.py
489
3.59375
4
#문자열 from random import * sentence = '나는 바보입니다.' print(sentence) sentence3 = """ 이렇게 출력하면 줄바꿈도 출력가능 """ print(sentence3) python = "Python is Amazing" print(python) print(python.lower()) print(python.upper()) print(python[0].isupper()) print(python.replace("is", "are")) print(python) index1 = python.index("i") print...
2056443ceb165c88e23cfe66b0ca1aae7292965f
kjk402/PythonWork
/pythonrogic/5quiz4.py
414
3.5625
4
from random import * # lst = [1,2,3,4,5] # print(lst) # shuffle(lst) # print(lst) lst = range(1,21) #1부터 20까지 숫자 생성 print(type(lst)) lst = list(lst) print(type(lst)) print(lst) shuffle(lst) print(lst) winners = sample(lst, 4) #4명 뽑고 print("==당첨자==") print("치킨 당첨자 : {0}".format(winners[0])) print("커피 당첨자 : {0}".form...
f106f22e459c9f0ed31faf7d16efd1006adc4e53
kjk402/PythonWork
/programmers/level1/7.py
436
3.515625
4
# 7번 2016년 def solution(a, b): answer = ["THU", "FRI", "SAT", "SUN", "MON", "TUE", "WED"] month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] day = sum(month[:a - 1]) + b if a > 1 else b return answer[day % 7] import datetime def getDayName(a,b): t = 'MON TUE WED THU FRI SAT SUN'.split() ...
cb82d87fb4935da995f022f73c44b9b1b46947e7
kjk402/PythonWork
/programmers/level1/24.py
364
3.609375
4
# 로또의 최고 순위와 최저 순위 # https://programmers.co.kr/learn/courses/30/lessons/77484 def solution(lottos, win_nums): answer = [0, 0] count = 0 rank = [6, 6, 5, 4, 3, 2, 1] for i in lottos: if i in win_nums: count +=1 answer[0] = rank[count + lottos.count(0)] answer[1] = rank[count...
099e12e55711c7ae9b88239219a6c1626a2e06e5
kjk402/PythonWork
/programmers/level1/11.py
304
3.625
4
# 11번 나누어떨어지는 숫자 배열 def solution(arr, divisor): answer = [] for x in arr: if x%divisor ==0: answer.append(x) answer.sort() if len(answer) ==0: answer.append(-1) return answer arr= [5,9,7,10] divi =5 print(solution(arr,divi))
716da44f088937e4759bc8c0a7e2f3af60190b5b
kjk402/PythonWork
/programmers/level1/25.py
518
3.625
4
# 숫자 문자열과 영단어 # https://programmers.co.kr/learn/courses/30/lessons/81301 def solution(s): answer = '' dic = {'zero': '0', 'one': '1', 'two': '2', 'three': '3', 'four': '4', "five": "5", "six": "6", "seven": "7", "eight": "8", "nine": "9"} tmp = '' for a in s: if a.isdigit(...
7deaa37b29bcf3288701d1bb8b5792b808a8c6db
kjk402/PythonWork
/programmers/level1/18.py
190
3.53125
4
# 18 소수찾기 def solution(n): answer =[] for i in range(2, n+1): for j in range(2,i): if i %j !=0: answer.append(i) return len(answer)
a634ebbf7dfe6a69968c2e7e0423a95cdeaff9fe
kjk402/PythonWork
/pythonrogic/oprator.py
501
3.890625
4
print(1+1) print(2**3) print(3**4) print(5%3) print(10//3) # == 같은지 비교 age =3 print( 3 == age ) print(not(1!= age)) print((3>0) and (3>5)) print((3>0) & (3>5)) print((3>0) or (3>5)) print((3>5) | (3>5)) number = 2 number+=2 print(number) number/=2 print(number) print(abs(-5)) #절댓값 print(pow(5,3)) #5를 세제곱 prin...
e05f2c66c41337248faa49ee5f336f2e8dbcdb7d
kjk402/PythonWork
/programmers/level1/10.py
297
3.59375
4
#10 같은 숫자는 싫어 """ """ def solution(arr): answer = [] if len(arr) ==1: return arr answer.append(arr[0]) for i in range(1, len(arr)): if arr[i] != arr[i-1]: answer.append(arr[i]) return answer arr =[4,4,4,3,3] print(solution(arr))
dfc6af52e6e4a5b06a42bdeb592a9e2ff627feed
kjk402/PythonWork
/pythonrogic/practice.py
425
3.546875
4
import random doc = { "names" : ["준기","승기","길동", "알고", "메튜"]} with open("info.txt", "w" ) as file : for i in range(5): name = random.choice(doc["names"]) weight = random.randrange(40, 100) height = random.randrange(150, 190) file.write("{}, {}, {}\n".format(name, weight, height)) ...
634c0129a79fd2449e0a0d515ed6fbb7edb7ee54
chriskirkpatrick/hello-world
/scratch.py
160
3.984375
4
#!/usr/bin/python squares = [v ** 3 for v in range(1,3)] #for v in range(1,25): # square = v ** 3 # squares.append(square) #print(squares) print(squares)
1d981238086ff220a2b80856dd013d6c1deabfc0
chriskirkpatrick/hello-world
/6-7_people.py
575
4.09375
4
#!/usr/bin/python people = { 'x' : { 'first_name': 'x', 'last_name': 'x', 'age': 'x', 'city': 'x', }, 'x' : { 'first_name': 'x', 'last_name': 'x', 'age': 'x', 'city': 'x', }, 'will' : { 'first_name': 'William', 'last_name': 'Nylander', 'age': '20', 'city': 'Toronto', }, } for pe...
c78062c13a9017b487ceb39ef66291d43c2718ef
Quetzalcoaltl/Cobra_2
/neu_net_1.py
1,575
4
4
"""video aula sobre criação de redes neurais link: https://www.youtube.com/watch?v=kft1AJ9WVDk&t=502s a filosofia eh a seguinte: 1- criamos um vetor com msm numero de pesos das entradas, por exmplo se as entradas necessitam 6 digitps, ciramos um vetor aleatorio com 6 digitos, não importa quantos exemplos diferentes ...
25246d0e0e2cb0ed366a2e778d1b3385fb1bd2db
Quetzalcoaltl/Cobra_2
/OOP_P3.py
2,735
4.53125
5
""" aula 2 de orientação ao objeto, Professor Corey Schafer Tema Aula: Python OOP Tutorial 2: Class Variables https://www.youtube.com/watch?v=BJ-VvGyQxho """ class Empregado: aumento_salario= 1.04 numero_empregado=0 def __init__(self, primeiro_nome, ultimo_nome, pagamento): sel...
b73271d0733f80bee1751919642d73408ddc03a7
Quetzalcoaltl/Cobra_2
/teste6.py
5,515
4.1875
4
#criando meu primeiro jogo em python 2 #cirando uma tela # usando turtle mod #/usr/bin/python #!coding=utf-8 import turtle import os import math #criar tela wn = turtle.Screen() #cria a tela e chama de wn #wn.screensize(700,700) wn.bgcolor("black") # definindo cor do backgroun wn.title("space invaders") #titulo #de...
441c5fbd97781cc617059c8a86e5a531c1f2dc16
PavanRaga/Exercism_python
/kindergarten-garden/kindergarten_garden.py
1,080
3.78125
4
given_students = [ "Alice", "Bob", "Charlie", "David", "Eve", "Fred", "Ginny", "Harriet", "Ileana", "Joseph", "Kincaid", "Larry"] class Garden(object): def __init__(self, diagram, students=given_students): diagram = diagram.splitlines() self.row1 = di...
ce994466bee4c527a4ccde92dc89072694303ea1
shibarak/lotterypicks
/main.py
3,318
3.546875
4
import requests from bs4 import BeautifulSoup import pandas as pd from draftdict import clean_draft_dict # cleaned up the data from wikipedia so all player names # match names on Basketball Reference. # -------------- Code for scraping draft data from Wikipedia, making the dra...
5b7a8b24ec0006ebf93cd86a56cea5eb0928151e
rafaelmgr12/UNIVESP-AlgeProg2
/code/main.py
3,052
3.84375
4
############################################################################################################# # Esse código foi feito Por Rafael Ribeiro, Facilitador da disciplina Algoritmos e Programação de # Computadores II # # # Aqui terá esritas funções que, serão usadas durante os exercícios durante a semana. # ...
8ee31252af6fde4115d0e1d8b2619b90c8b0ed9a
luoxuesnowy91/ANLY560
/Assignment 3.py
2,358
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 13 20:08:15 2018 @author: luoxue """ ### ASSIGNMENT 3 # import codes to plot histogram import sys sys.path.append("/Users/luoxue/Desktop/HU/ANLY 545 Analytical Methods II/ThinkStats2-master/code/") import thinkstats2 import thinkplot import matp...
277e1ecf426326cf0d0f3e2b75079bf3260fa92a
mnmnc/master
/arrtools/arrtools.py
343
3.734375
4
def select_from_data(data, attributes): """ CREATES AN ARRAY FROM DATA DICTIONARY BY SELECTING GIVEN ATTRIBUTES """ results = [] for row in data: results_row = [] for attribute in attributes: results_row.append(row[attribute]) results.append(results_row) return results def main(): pass if __name__...
d2b55e23830c44c2879fed624800a0d962bcee59
naveeharn/pythonDataStructure
/01_LinkedList/1_SinglyLinkedList/py07_detectloop.py
5,886
4.09375
4
class Node: def __init__(self, data) -> None: self.data = data self.next = None class LinkedListSst: def __init__(self) -> None: self.head = None def push(self, new_data): new_node = Node(new_data) new_node.next = self.head self.head = new_node def chec...
56c244057251f0af753805ce0fb7fb6971413ec9
AfiNaufal97/LatihanPython
/medium/dictionary.py
351
3.875
4
# type data dictionary # key dan value {key:value} Negara = {"Indonesia":"Jakarta", "Jepang":"Tokyo", "Korea Selatan":"Soul"} Negara2 = {"Indonesia":"Jakarta", "Jepang":"Tokyo", "Korea Selatan":"Soul"} print(Negara["Indonesia"]) # mencetak semua keys print(Negara.keys()) print(Negara.items()) dataNegara = {1:Negara2,...
cb03f24e19740da57b47df815ce4bbbc8751194d
AfiNaufal97/LatihanPython
/hard/constructorClass.py
375
3.65625
4
class Mahasiswa3(): nama = "nama default" nim = 123 alamat = "Alamat default" # constructor def __init__(self, nama, nim, alamat): self.nama = nama self.nim = nim self.alamat = alamat def perkenalan(self): print("perkenalan nama saya adalah ", self.nama) nama3...
d4e04c7132876544fe0317e7a2934837c8ddd178
SherMM/coursera-ucsd-algorithms-datastructures
/AlgorithmicToolBox/Week4/inversions/inversions.py
1,078
3.5625
4
# Uses python3 import sys def get_number_of_inversions(a, b, left, right): number_of_inversions = 0 if right - left <= 1: return number_of_inversions ave = (left + right) // 2 number_of_inversions += get_number_of_inversions(a, b, left, ave) number_of_inversions += get_number_of_inversions...
5d8e50b504b44217ae42a99fc5e54588c5dc94ef
SherMM/coursera-ucsd-algorithms-datastructures
/AlgorithmicToolBox/Week3/change/change.py
554
3.859375
4
# Uses python3 import sys def get_change(n): ''' Returns minimum number of 1, 5, 10 denomination coins to make change for n ''' assert (1 <= n <= 10**3) total = n count = 0 while total != 0: if total >= 10: count += total // 10 total %= 10 elif to...
ee0e90e321aea5f39832d3c2db8d57eaebff3e08
SherMM/coursera-ucsd-algorithms-datastructures
/AlgorithmicToolBox/Week3/fractional_knapsack/fractional_knapsack.py
915
3.546875
4
# Uses python3 import sys def get_optimal_value(capacity, weights, values): value = 0 # value of items in bag weight = 0 # weight of items in bag items = {v/w: (v,w) for v,w in zip(values, weights)} while weight != capacity and items: best = max(items) item_weight = items[best][1] ...
059e6f213598e015e91edced9ad356f65f1bb616
SherMM/coursera-ucsd-algorithms-datastructures
/Graphs/Week1/connected_components/connected_components.py
767
3.65625
4
#Uses python3 import sys def number_of_components(graph): result = 0 seen = set() for vertex in graph: if vertex not in seen: stack = [vertex] result += 1 while stack: curr = stack.pop() if curr not in seen: s...
fabac6cb359e78a61802b1945a07a3170efd3ba2
petrivo/movierate
/movierate/algo.py
801
3.875
4
class Node(): def __init__(self, data=None): self.left = None self.right = None self.data = data def insert(self, data): if self.data: if data > self.data: if self.right is None: self.right = Node(data) else: ...
0bb60add2d02d615fa8866ded083faf1bdef142a
li3939108/max_bandwidth
/uf.py
393
3.71875
4
def union(x, y): xRoot = find(x) yRoot = find(y) if xRoot.rank > yRoot.rank: yRoot.parent = xRoot elif xRoot.rank < yRoot.rank: xRoot.parent = yRoot elif xRoot != yRoot: # Unless x and y are already in same set, merge them yRoot.parent = xRoot xRoot.rank = xRoot.rank + 1 def find(x): if x.paren...
1757fffc67fc9d547b27b831e7117bde0d1ade59
shahsanjana/Bioinformatics-Algorithms-
/PERM.py
185
3.53125
4
from itertools import permutations n=5 num = list(permutations(range(1, n+1))) permutation=[' '.join(map(str, i)) for i in num] print len(num) for item in permutation: print item
71a177252d41da4e48114a3a295144ad63fd5818
last-partizan/pytils
/doc/examples/numeral.in_words.py
1,104
3.84375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from pytils import numeral # in_words нужен для представления цифр словами print(numeral.in_words(12)) #-> двенадцать # вторым параметром можно задать пол: # мужской=numeral.MALE, женский=numeral.FEMALE, срелний=numeral.NEUTER (по умолчанию -- мужской) print(numeral.in_...
06e309b8d414ee29ac1106201cedbf347263d4b2
mariagt267/python-maria-texcahua
/examen-parcial11/numeros.py
362
3.953125
4
while True: numero = input("INTRODUZCA UN NUMERO: ") try: val = int(numero) if val == 0: print('CERO') break elif val > 0: print('POSITIVO') break elif val < 0: print('NEGATIVO') break except ValueEr...
4e26bc2cf936c772f95409b95b10d1951d342023
5ANTI-726/Juego-pintado
/paint.py
3,009
4.09375
4
"""Paint, for drawing shapes. Exercises 1. Add a color. 2. Complete circle. 3. Complete rectangle. 4. Complete triangle. 5. Add width parameter. """ # A01701879 María José Díaz Sánchez # A00829556 Santiago Gonzalez Irigoyen # Este código funciona permite dibujar líneas, cuadrados, círculos y triángulos de diferente...
58ab7f3e468ef3bd196541d62baf529cd46072ef
DevanTurtle7/geneticAlgorithm
/tests/global_tests.py
1,773
4.03125
4
""" Tests the global functions to make sure it they are functioning properly. author: Devan Kavalchek """ import globals def test_change_string_first(): """ Tests the change_string_first() function by giving it a standard input and checking that the expected string is being returned """ # Setup ...
6790bffe8af91d0f2331df30d3015b27accf17ba
dennomwas/Room-Allocation
/Model/Amity.py
16,898
3.765625
4
import pickle import sqlite3 from os import remove from os import path from sqlite3 import Error from random import choice from Model.People import Staff, Fellow from Model.Rooms import Office, LivingSpace class Amity(object): all_rooms = {"office": [], "livingspace": []} all_persons = [] unallocated_of...
e5a60154e307e131ee18b128b52df7f644062d00
Nehanavgurukul/Dictionary
/exist_key.py
155
4.3125
4
dic={"name1": "radha","name2":"neha","name3":"rinki"} if "name3" in dic: print("yes it is exist in dic ") else: print("no it is not exist in dic")
3551578a46aade10996419ba4d96bea70637cd5a
Nehanavgurukul/Dictionary
/dic_value_sum_for.py
87
3.578125
4
dic={"A":56,"B":97,"C":57,"D":28} sum=0 for x in dic.values(): sum=sum+x print(sum)
d471482237922835ff1802c479b4c520269ccd50
Nehanavgurukul/Dictionary
/update_dict1.py
65
3.578125
4
person= {'1': 'RAM', '2': 17,} person['3'] = 'male' print(person)
4a91036001115a0a01ecf9ce0be221744219ba73
jaebradley/project_euler
/problems/pe23.py
4,092
4.09375
4
""" A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it i...
bb3f60122c2ecc63b78c98572cb05cffa6c4f72e
jaebradley/project_euler
/problems/pe44.py
1,410
4.25
4
""" Find the pair of pentagonal numbers for which their sum and difference are pentagonal """ import time def is_pentagonal(number): #inverse function for pentagonal number return not (1 + (1 + 24 * number) ** 0.5)/6 % 1 def return_pentagonal(n): return n * (3 * n - 1) / 2 def is_sum_and_difference_of...
1821384382ef0685f647dbc5f28b11250aa1f6c9
jaebradley/project_euler
/problems/pe56.py
1,237
3.8125
4
""" https://projecteuler.net/problem=56 A googol (10 ** 100) is a massive number: one followed by one-hundred zeros; 100 ** 100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1. Considering natural numbers of the form, a ** b, where a,...
63976b2ace691b640cd1b20c51bcc16f8b85826c
jaebradley/project_euler
/problems/pe26.py
711
3.546875
4
""" Find the value d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part do the division, get the remainder use the remainder, do the division, get the remainder repeat you can only know it's a cycle if you see the same pattern exactly twice where pattern length is <= d - 1 """ recur...
dd316af927b9ba95a75e71e60f4177b621e56bc3
jaebradley/project_euler
/problems/pe6.py
1,368
4.09375
4
# coding=utf-8 """ The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 55^2 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 302...
0da5f819770b018f53bd13a4abb57d7b68fb77f8
jaebradley/project_euler
/problems/pe58.py
3,039
4.03125
4
# coding=utf-8 from utils import project_euler_helpers as pe __author__ = 'jaebradley' ''' Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed. 37 36 35 34 33 32 31 38 17 16 15 14 13 30 39 18 5 4 3 12 29 40 19 6 1 2 11 28 41 20 7 8 9 10 27 42 21 22 ...
59a01e62964c23e5f7d5d8f2da93996a5b3e8ea8
jaredrobertson21/GamePredictor
/gamepredictor/games/game.py
2,543
3.78125
4
class Game: """ Game objects encapsulate game data from the past or future """ def __init__(self, game_date=None, away_team=None, away_team_score=None, home_team=None, home_team_score=None, game_id=None, overtime=None, attendance=None): self.game_date = game_date self.aw...
ab4b14981a3ecff06b03e9a39a2d4523cc612967
decorouz/Google-IT-Automation-with-Python
/using-python-to-interact-with-operating-sys/week3_regex/playground.py
20,913
4.125
4
# # Regular Expressions import re # # Regular expressions allow us to search a text for strings matching a specific pattern. # # Besides Python and other programming languages we can also use command line tools that know how to apply regexs, like grep, sed, or awk. log = "July 31 07:51:48 mycomputer bad_process[12345...
91e7da83b03fe16d65782809e07e397a41aabb72
TheNathanHernandez/PythonStatements
/Unit 2 - Introductory Python/A1/Comments_Outputs_Errors.py
1,379
4.65625
5
print('Welcome to Python!') # Output: Welcome to Python # Why: String says "Welcome to Python print(1+1) # Output: 2 # Why: Math sum / 1 + 1 = 2 # print(This will produce an error) # Output: This will produce an Error # Why: The text doesn't have a string, it's invalid print(5+5-2) # Output: 8 # Why: 5 + 5 - 2 prin...
bbed8da2e0837f77df6ae36a03ef73ac25e172fd
TheNathanHernandez/PythonStatements
/Unit 2 - Introductory Python/A4 - Conditional Expressions/programOne.py
403
4.15625
4
# Program One - Write a number that asks the user to enter a number between 1 and 5. The program should output the number in words. # Code: Nathan Hernandez from ess import ask number = ask("Choose a number between 1 and 5.") if number == 1: print("One.") if number == 2: print("Two.") if number == 3: ...
568a008e308b0ec562b9dbdb99b2edd5d67a2e7b
TheNathanHernandez/PythonStatements
/Unit 2 - Introductory Python/A2 - Make Math Easy!/VolumeOfACylinder.py
137
4.15625
4
# Volume of a Cylinder, Nathan Hernandez import math h = 8 pi = 3.14 r = math.pow(3, 2) v = h * pi * r print('The volume of the cylinder is',v)
158499a0dbf4b618b191cb64e35a00b16df1b9f5
eizin6389/The-Self-Taught-Programmer
/Chapter6/Challenge6.py
83
3.796875
4
word ="A screaming comes across the sky." word = word.replace("s","$") print(word)
70f8c0bf95e89b5b795aac2f7e69f0273b58fec0
eizin6389/The-Self-Taught-Programmer
/Chapter12/Challenge2.py
185
3.78125
4
import math class Circle: def __init__(self, width): self.width = width def area(self): print(self.width*self.width*math.pi) circle = Circle(3) circle.area()
f47da891c0c808231dab94c9d0559bf434d41326
darshan527/Practical-DSA-with-Python-Flask-API
/hash_table.py
2,074
3.859375
4
class Node: def __init__(self, data): self.data = data self.next = None class Data: def __init__(self, key, value): self.key = key self.value = value class HashTable: def __init__(self, table_size: int): self.table_size = table_size self.hash_table = [None...
23c70016339c5b3e283b1824f3c03f46cb23359f
satishgunjal/ml_proj_template
/src/cross_validation.py
6,410
3.625
4
import pandas as pd from sklearn import model_selection class CrossValidation: def __init__( self, df, target_cols, shuffle, problem_type = 'binary_classification', multilabel_delimiter = ',', num_folds = 5, random_state = 42 ): ...