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
250f55cf55e04ed9fba1c403afe8cd35801bf609
Shohrab-Hossain/Tic-Tac-Toe
/src/lib.py
6,085
4.09375
4
def game_type_selection(): print('\n' + '--------------------------------\n' + 'How do you want to play:\n' + '\t[1] with another PLAYER\n' + '\t[2] with COMPUTER\n') while(True): command = input('select an option (1/2): ') if(command == '...
32ecb9b4cfe42fc63007e72ac3c8778fa8121ad5
huang-zp/pyoffer
/my_queue.py
646
4.125
4
class MyQueue: def __init__(self): """ Initialize your data structure here. """ self.stack_in = [] self.stack_out = [] def push(self, x: int) -> None: """ Push element x to the back of queue. """ self.stack_in.append(x) def pop(self)...
cf577d9269a70a97e92b02ca391cc0fc20be05bc
AnushaBilakanti/Anagrams-of-string
/anagram.py
625
3.609375
4
''' Created on December 17, 2016 @author: Anusha Bilakanti ''' def permuteString(lst): if(len(lst) == 0): return [] elif(len(lst)== 1): return [lst] else: l=[] for i in range(len(lst)): x = lst[i]; xs = lst[:i] + lst[i+1:] for ...
bf6add7af0f5f213334b708cc45917ef515225ce
greenfox-zerda-lasers/SzaboRichard
/week-03/day-2/proleage3.py
379
4
4
# Sort # Implement bubble sort method. def bubble_sort(sort_it): for num in range(len(sort_it)-1,0,-1): for i in range(num): if sort_it[i] > sort_it[i+1]: temp = sort_it[i] sort_it[i] = sort_it[i+1] sort_it[i+1] = temp return sort_it print(bu...
6584e59f83adad99fb73028db42bff3f0ae72eb5
greenfox-zerda-lasers/SzaboRichard
/week-04/day-1/01_io/crypto_2revlines.py
463
3.828125
4
# Create a method that decrypts texts/reversed_zen_lines.txt def decrypt(file_name): f = open(file_name) result = f.readlines() eredm = "" index=[] for line in result: line = line.rstrip() for string in reversed(list(line)): eredm += string eredm += "\n" f.clo...
ba433a7a91f0006902c356bce5f32629de47fc83
greenfox-zerda-lasers/SzaboRichard
/week-05/day-3/f02.py
421
4.09375
4
# write a function that takes a filename and returns the number of lines the # file consists. It should return zero if the file not exists. def file_reader(filename): try: f = open(filename) readlines = f.readlines() linestemp = 0 for lines in readlines: linestemp += 1 ...
17b4f40e31faff4d85a0e56a7a4b328bdc9a20b3
greenfox-zerda-lasers/SzaboRichard
/week-04/day-3/01.py
352
3.90625
4
from tkinter import * # create a 300x300 black canvas. # draw a red horizontal line to its middle. # draw a green vertical line to its middle. root = Tk() canvas = Canvas(root, width="300", height="300") canvas.pack() line1 = canvas.create_line(0,150, 300, 150, fill="green") line2 = canvas.create_line(150, 0, 150, 30...
08704ccd57400104139746601791164ff1a663f0
greenfox-zerda-lasers/SzaboRichard
/week-05/day-4/model_elevator.py
990
3.78125
4
# Create an "elevator" class # The class should track the following things: # - elevator position # - elevator direction # - people in the elevator # - add people # - remove people # # Please remeber that negative amount of people would be troubling class Elevator_model: def __init__(self): # self.ctr...
073ec02fbeb896a779f42457c0510b6e20bbadc4
shanjiang1994/The_complete_guide_in_Python_for_DA-DS
/py_files/2.Object operation.py
11,227
4.625
5
#!/usr/bin/env python # coding: utf-8 # # Data type operation # <div class="alert alert-block alert-info" style="margin: 20px"> # # # * **Operators** are used to perform operations on variables and values. # * **Iterator** is an object that contains a countable number of values # * **Generators** are used to crea...
6bd58b86451728beaef84af47d9004576097ec8d
mathurapurv/python-data-analytics
/test-NumPy.py
1,939
3.78125
4
import numpy as np; print('-- Start --') # a large array , perform operation on all elements without looping large_int_array = np.arange(1000) print(large_int_array) large_int_array_multiply_2 = np.array( [ x for x in large_int_array]) print(large_int_array_multiply_2) print('-- cast int array to float -- ') ...
aee36a7523ad8fc3de06ef7b047aff60fa3ab0d6
ADmcbryde/Collatz
/Python/recursive/coll.py
2,842
4.25
4
# CSC330 # Assignment 3 - Collatz Conjecture # # Author: Devin McBryde # # # def collatzStep(a): counter = 0 if (a == 1): return counter elif ( (a%2) == 1) : counter = collatzStep(a*3+1) else: counter = collatzStep(a/2) counter = counter + 1 return counter #The program is programmed as a function sinc...
65f5ae7a36cd30dce92655eea3ef31509c25bf13
pkvinhu/algorithm-dict
/leetcode/python/containerWithMostWater.py
1,087
3.921875
4
## CONTAINER WITH MOST WATER # Given n non-negative integers a1, a2, ..., an , # where each represents a point at coordinate (i, ai). # n vertical lines are drawn such that the two endpoints # of line i is at (i, ai) and (i, 0). # Find two lines, which together with x-axis forms a container, # such that the conta...
0d075a750c9745eb97a2577db4b7c7cf2407d903
ergarrity/coding-challenges
/missing-number/missing.py
1,009
4.21875
4
"""Given a list of numbers 1...max_num, find which one is missing in a list.""" def missing_number(nums, max_num): """Given a list of numbers 1...max_num, find which one is missing. *nums*: list of numbers 1..[max_num]; exactly one digit will be missing. *max_num*: Largest potential number in list >...
ad57db626e0cf1accc7a27fd48dd86d7e8a609cd
SuguruChhaya/snake_game_tkinter
/prototypes/movingendtofront.py
9,588
3.75
4
from tkinter import * import random import keyboard ''' In this version, i am going to use the strategy of moving the end block to the front instead of moving everything. I am going to use tags to check which is the head. ''' class Snake(): def __init__(self): self.root = Tk() Snake.my_canvas = C...
a49f76f673232ca339e9a5bc1595a97b12847047
mihir-manoriya/hotelScript
/newtask.py
2,155
4.0625
4
import csv print("Select state :- Karnataka, Tamilnadu, Maharashtra") print("select any one option :- Cost or Rating") print("Operation:- highest/average/cheapest/lowest(for rating)") state=input("What is the state:- ") cr=input("Cost or Rating:- ") op=input("Operation :- ") def cst(): with open('hotel...
939f3410a8a9a98620cb74fea87c521f2292e847
Wanlingj/LeetCode
/Google/Array and Strings/Intersection of Arrays.py
722
3.53125
4
#faster method: #!cannot connect to internet #Slower solution: class Solution: """ @param arrs: the arrays @return: the number of the intersection of the arrays """ def intersectionOfArrays(self, arrs): # write your code here m = {} n = len(arrs) result=0 ...
ab8725f560f61d502de720041bce5496964e43c9
Wanlingj/LeetCode
/Google/DynamicProgramming/Sentence Screen Fitting.py
1,013
4
4
class Solution: """ @param sentence: a list of string @param rows: an integer @param cols: an integer @return: return an integer, denote times the given sentence can be fitted on the screen """ def wordsTyping(self, sentence, rows, cols): # Write your code here r=0 c=...
0e933f830a347cf575dc2e6f52f0cca82894f1f7
Wanlingj/LeetCode
/Google/Sorting and searching/Pacific Atlantic Water Flow.py
1,596
3.859375
4
class Solution: """ @param matrix: the given matrix @return: The list of grid coordinates """ def pacificAtlantic(self, matrix): # write your code here r=[] m = len(matrix) if m == 0: return r n = len(matrix[0]) if n == 0: retur...
8b1b4b45cab09adfbf48314ccea02b1ef678b7a4
Wanlingj/LeetCode
/Google/Array and Strings/Intersection of Two Arrays.py
490
3.71875
4
class Solution: """ @param nums1: an integer array @param nums2: an integer array @return: an integer array """ def intersection(self, nums1, nums2): # write your code here if len(nums1)>len(nums2): nums1,nums2=nums2,nums1 m={} for i in set(nums1): ...
c6d7fe760599dd963841966fd862deb1808525f3
Wanlingj/LeetCode
/Google/Array and Strings/Game of Life.py
808
3.640625
4
class Solution: def gameOfLife(self, board): m,n = len(board), len(board[0]) for i in range(m): for j in range(n): count = 0 for I in range(max(i-1,0),min(i+2,m)): for J in range(max(j-1,0),min(j+2,n)): count +=b...
ba030808829b45d238399cb7d05265bc3a2f0b28
Wanlingj/LeetCode
/Google/Array and Strings/Valid Parentheses.py
726
3.984375
4
class Solution: """ @param s: A string @return: whether the string is a valid parentheses """ def isValidParentheses(self, s): # write your code here stack=[] for c in s: if c=='(': stack.append('(') if c=='{': stack.appe...
8717208247c2d4f9eb24522c1b54ec33ce41789c
kwozz48/Test_Projects
/is_num_prime.py
613
4.1875
4
#Asks the user for a number and determines if the number is prime or not number_list = [] def get_integer(number = 'Please enter a number: '): return int(input(number)) def is_number_prime(): user_num = get_integer() number_list = list(range(2, user_num)) print (number_list) i = 0 a = 0 ...
8f6f138c46a7fd5e3521d9fadcf7fd456dff1bb6
upinderawat/Advanced-Problem-Solving
/Assignment-3/Q3/heap_min.py
1,591
3.625
4
import random class HeapMin(object): def __init__(self, heap_arr=None): self.__heap_arr = [0] if heap_arr is not None: self.__heap_arr.extend(heap_arr) else: self.__heap_arr = [0] self.build_heap() def __str__(self): return "heap_arr:{}\n".format(self.__heap_arr) def __repr__(self): return "<...
3b4ee6e6db5ea027f23ae3ebfa4b89fc005074e0
michaelrevans/football-app
/venv/src/football.py
13,152
3.625
4
""" The below is a way to document football leagues, results and tables. The premier league is my example, but it would be applicable to any league with any number of teams. """ class FootballTeam: def __init__(self, name): self.name = name self.points_home = 0 self.points_away = 0 ...
55e30b073da3bcb2c16a6994c6c8f0ab9a5eafea
cacavelli/python_projects
/calculator.py
3,426
4.40625
4
# Calculadora em Python '''A ideia é ter uma calculadora básica que realize: 1 - Soma; 2 - Subtração; 3 - Multiplicação; 4 - Divisão; 5 - Potência O usuário seleciona o que deseja fazer digitando a opção e depois os dois números para realizar a operação matemática. Caso digite algo fora das 5 opções, a ca...
8f57bfe92df87002e10053f4de7bcd8968e29ab4
MinsangKoo/atm-controller
/atm.py
4,681
4.21875
4
#import APIs class ATM: def __init__(self): self.card_number = None self.bank_card = None self.account_type = None #1 for savings, 2 for checking self.transaction_type = None self.balance = 7000 def readCard(self): #Case where card is incompatible with ATM. Let us assume any card number starting with 0 ...
787f73eafc1b83462ae96a685045b9ba47ec2985
Blessan-Alex/Guess-the-number
/guessthenumb.py
1,045
3.921875
4
import random def condition(a,b,actual): guess = int(input(f"Guess a number b/w {a} and {b}: ")) c=1 while guess!= actual: if guess<actual: c+=1 guess = int(input(f"Too loww.\nGuess a number b/w {a} and {b}: ")) else : c+=1 guess = int(in...
a9e57ec3b6852d4a53140c2afaa9f8a3d822109f
michelleNunes/Python_List
/exercicio-strings-and-numbers/Extras/Strings/fn_descendent_Equipe2.py
533
4
4
# Equipe-02 # Scrum master: Matheus Serrão Uchôa # Devs: # Paulo Henrique Munhoz # Ana Beatriz Pimentel # Kariny Oliveira # print the word in ascendent def fn_descendent(str_word): str_word = str_word.replace(" ", "") # replace the blank spaces str_word = sorted(str_word, reverse=True) # sort ...
d7f4fc22eebc4622b26246f5d1362956756329e4
michelleNunes/Python_List
/exercicio-strings-and-numbers/Extras/Strings/fn_reverse_Equipe2.py
399
4.09375
4
# Equipe-02 # Scrum master: Matheus Serrão Uchôa # Devs: # Paulo Henrique Munhoz # Ana Beatriz Pimentel # Kariny Oliveira # reverse string # function that check the word def fn_reverse(str_word): str_reverse = str_word[::-1] # reverse the word print(str_reverse) # print # main function s...
8390b5fa589a2464e80224c346a4c774055301bb
MarijnJABoer/AwesomePythonFeatures_Marvel
/marvel_universe.py
3,962
3.703125
4
class MarvelCharacter: """ Creates a character from the Marvel universe """ # class atribute location = "Earth" def __init__(self, name: str, birthyear: int, sex: str): self._name = name self.birthyear = birthyear self.sex = sex def __repr__(self): return f...
3896fefefb2808356b2ba0c0affe818d65b2ec26
orangepips/coding-the-matrix
/chapter/3/problem_3_8_4.py
714
3.9375
4
from resources.vec import Vec from chapter3.quiz_3_1_7 import lin_comb def problem_3_8_4(vlist, clist): ''' a & b are real numbers z = ax + by ax + by - z = 0 Prove there are 2 3-vectors v1 & v2 such that points [x, y, z] satisfying the equation is exactly the set of linear combinations of v1 &...
3eef990a99c03d4e94e829d69a77eaa954545ad3
orangepips/coding-the-matrix
/chapter/2/quiz_2_9_15_errata.py
1,577
3.71875
4
# submitted to info@codingthematrix.com # 2.9.4 quiz def list_dot(u, v): return sum([a * b for (a, b) in zip(u, v)]) # 2.9.15 quiz book answer def dot_product_list(needle, haystack): s = len(needle) return [list_dot(needle, haystack[i:i+s]) for i in range(len(haystack) - s)] # 2.9.15 correcte...
e2d570e108116f3b5af924982928fe7768003b13
agiang96/CS550
/CS550Assignment1/driver.py
1,762
3.625
4
''' file: driver.py author: Alex Giang class: CS550 Artificial Intelligence ''' from boardtypes import TileBoard up = [-1,0] down = [1,0] left = [0,-1] right = [0,1] none = [0,0] tileBoard = TileBoard(8); tileBoard.get_actions() # need this for location of empty tile print("Tile Game Start: ") print("To move...
896b25de9da60c38fcc57423a3840243bcb7de4c
Cprocc/Week_test
/Leetcode/easy/111.py
1,545
3.796875
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def minDepth(self, root): """ :type root: TreeNode :rtype: int """ if root is None:return 0 min_deep = 1 pice_st...
664f71c332c2f7d6df026640655866f1681d4641
Cprocc/Week_test
/Leetcode/easy/605.py
791
3.875
4
def canPlaceFlowers(flowerbed, n): """ :type flowerbed: List[int] :type n: int :rtype: bool """ for i in range(len(flowerbed)): if flowerbed[i] == 1: if i - 1 >= 0: flowerbed[i - 1] = -1 if i + 1 <= len(flowerbed) - 1: flowerbed[i +...
79903ac404f5d00c6f5019aa04f013a2b4d37673
Cprocc/Week_test
/2019-04-08携程/1.py
229
3.546875
4
if __name__ == '__main__': m = list(map(str, input().strip().split(','))) a = {} flag = 0 for item in m: if item not in a: a[item] = 1 else: flag = 1 print(flag != 0)
b806e4964af0046cfd17eaf586c25e111314a100
Cprocc/Week_test
/DyP/动态规划好好规一规/斐波那契数列的效率问题.py
628
3.578125
4
import time # 递归的效率如何 def fib_re(i): if i == 1: return 1 elif i == 0: return 0 else: return fib_re(i-1) + fib_re(i-2) # 不用递归 def fib_no_re(j): per0 = 0 per1 = 1 res = 0 if j == 0: return 0 if j == 1: return per0 for cur in range(2, j+1): ...
6a8bf65af91dfbde662cdaa8fa7ed491202130f7
Cprocc/Week_test
/2019-04-28/2.py
1,012
3.640625
4
def colorBorder(grid, r0, c0, color): m, n = len(grid), len(grid[0]) # bfs存放搜索到的元素下标 # component已经遍历过的连通分量 # border存放连通分量的边界 bfs, component, border = [[r0, c0]], set([(r0, c0)]), set() for r0, c0 in bfs: # 下标的四种移动方式 for i, j in [[0, 1], [1, 0], [-1, 0], [0, -1]]: r, ...
c2fa6036228e30c0aee173966b2659dab85c1b46
Cprocc/Week_test
/DyP/最大子数组的和.py
225
3.640625
4
A = [-1, 0, -8, 7, 5, -4, 3, 2, 10, -9, -11] def max_sum(A): sum = 0 subsum = 0 for i in range(len(A)): subsum = max(A[i], subsum + A[i]) sum = max(sum, subsum) return sum print(max_sum(A))
562c29a364f29a7be9bb4e5d8b83ffc446d7bc45
Cprocc/Week_test
/2019-04-28/3.py
809
3.6875
4
def numMovesStones(a, b, c): """ :type a: int :type b: int :type c: int :rtype: List[int] """ list1 = [a, b, c] list1.sort() print(list1) max_change = (list1[2]-list1[1]-1)+list1[1]-list1[0]-1 if max_change == 0: return [0, 0] a, b, c = list1 min_times = 0 ...
1c3aa72b697bcec3e809b38f675d4ce1b3944c49
Cprocc/Week_test
/2019-04-07/2.py
1,075
3.765625
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def sumRootToLeaf(self, root): res = self.sumRoot(root) r = 0 for x in res: r += int(x, 2) return r def sumRoot(self, root: Tr...
b12e81974714c62d12917c7b4fd7bf0ea70e58d8
Cprocc/Week_test
/Leetcode/easy/941.py
459
3.6875
4
def validMountainArray(A): """ :type A: List[int] :rtype: bool """ m = 0 for i in range(1, len(A)): if A[i] > A[i-1]: pass else: m = i-1 break if m == 0 or m == len(A)-1: return False for i in range(m, len(A)-1): if A...
5c9fd6331af7d30eb9c53bb601182659c197907c
Cprocc/Week_test
/Leetcode/medium/39.py
776
3.5
4
def combinationSum(candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] """ res = [] li = [] candidates.sort() if len(candidates) == 0: return res combinationSumHelp(res, li, candidates, target, 0) return res def combinati...
7894342b123922104be715fb57db796fcd39a1c7
Cprocc/Week_test
/Leetcode/easy/496.py
659
3.78125
4
def nextGreaterElement(nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ cache, st = {}, [] for x in nums2: if len(st) == 0: st.append(x) elif x <= st[-1]: st.append(x) else: while st and st[-1] ...
f102044fbb86a6a49354b619fb7490a52ebc6fc2
Cprocc/Week_test
/2019-04-30小米四月常规赛/1.py
452
3.8125
4
def count_factors(num_intput): if num_intput == 1: return 1 num_facotrs = 2 search = int(num_intput / 2) i = 2 while (i <= search): if (num_intput % i == 0): if (num_intput / i > i): num_facotrs += 2 elif (num_intput / i == i): ...
0b6fa2872145df6960a83acde49b7ef0c9082fa1
project113114/cs-practical
/fibico_serise.py
128
3.671875
4
n = int(input("enter the range ")) last= 0 new =1 for i in range(1,n+1): sum = last + new last = new new = sum print(sum)
ed887bb2d3d1f1ebacc75eda5b2800f475516377
kitizl/pyEuler
/name_scores/names.py
829
3.734375
4
#! python3 import time start_time = time.time() def value_name(name): mapper = {n:i+1 for (i,n) in enumerate(list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"))} return sum([mapper[x] for x in name]) def sort_names(names): # using quicksort if names == []: return [] pivot = names[0] l = sort_names([...
1bd6d66b418e3d2d45a8031c8df02ed554fa6769
ogurin/PythonStudy
/Chap3/leap_year1.py
337
3.78125
4
import calendar year = int(input("年を入力してください: ")) if calendar.isleap(year): print("うるう年です") else: print("うるう年でない") if ((year % 4 == 0) and (year % 100 != 0)) or (year % 400 == 0): print("うるうどしです") else: print("うるうどしでないです")
2be9967962f94d409aae32b9dfd8d0c7c94887ff
rebecafbraga/19-02-exercicio1
/exercicio1_aula3.py
467
3.734375
4
import datetime dia_hoje = datetime.date.today()#(year=2020, month=2, day=20) ano = int (input('Digite o ano de seu nascimento:')) mes = int (input('Digite o mes de seu nascimento:')) dia = int (input('Digite o dia de seu nascimento:')) dia_nascimento = datetime.date (year= ano, month= mes,day = dia) def dias_vida (d...
078e65f8e39036527233b9f90a8a41a80ce3c6be
byteknacker/euler
/problem2.py
2,680
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Solution to Project Euler's Problem 2: Even Fibonacci Numbers Classes: Fibo(base1, base2): base1: the first base number of the Fibonacci series base2: the second base number of the Fibonacci series Methods of Fibo: createFibolist(index_limit): ...
3fd637fc7c34e0b5eda75717bf42c525fa9a77cd
Inaguma1110/ProgTech2018
/as6/ans/p2.py
98
3.78125
4
s = input() for i in s: if i == "a": print("YES") break else: print("NO")
2affc8d20a2e4da2bf85cfbd8955ff725682f6ab
Inaguma1110/ProgTech2018
/as8/ans/p6.py
74
3.609375
4
strings = input().split(",", 2) a = [s.lower() for s in strings] print(a)
2da43b7149262dd67b025a3165a2f78610aa3285
Inaguma1110/ProgTech2018
/as5/ans/p6.py
102
3.765625
4
s = input() for x in s: if "f" <= x <= "j": print("A") break else: print("B")
e4e5f204002f490d8883e8d5d8ef3760ac8d0986
Inaguma1110/ProgTech2018
/as12/ans/p5.py
359
3.6875
4
class Integer: def __init__(self, value): self.__value = value def value(self): return self.__value class String: def __init__(self, word): self.word = word def repeat_words(self, i): print(self.word * i.value()) a = input() b = int(input()) str_a = String(a) int_b ...
81354e2affe2a3499c2d4f7f15a46d0885044147
Inaguma1110/ProgTech2018
/as11/ans_/p1.py
218
3.546875
4
def to_matrix(s): matrix = [] for i in s.split(";"): line = [] for j in i.split(): line.append(int(j)) matrix.append(line) return matrix a = input() print(to_matrix(a))
6ac8326759284340a345fc62000e558d5e640370
Inaguma1110/ProgTech2018
/as12/ans/p6.py
312
3.8125
4
class Trapezoid: def __init__(self, u, l, h): self.u = u self.l = l self.h = h def area(self): return (self.u + self.l) * self.h // 2 class Square(Trapezoid): def __init__(self, w): super().__init__(w, w, w) a = int(input()) s = Square(a) print(s.area())
56e08749e2a4b57657e88b9a1fb0e90179352373
Inaguma1110/ProgTech2018
/as10/ans/p2.py
121
3.8125
4
s = input() n = int(input()) def concat_and_print(x, y=3): print(x * y) concat_and_print(s) concat_and_print(s, n)
c3ebd306b9c9b1c90110f46a3f14a66b921c7b05
robcreel/squares
/board_presenter.py
664
3.5
4
class BoardPresenter(object): def print_board(self, tiles, nrows, ncols): for index in range(1, ncols * nrows + 1, ncols): self.print_row_border(index, index + ncols) self.print_row(tiles, index, index + ncols) self.print_row_border(0, ncols) def print_row(self, tiles, ...
8998b9633916604a7c7d3cea429dbed3b6ba5a1d
opritchard/OPScoreandGrades
/ScoresandGrades.py
665
4.09375
4
def enterScore(): response = input("Please enter a score") return response def evalutateScore(value): if int(value) in range(59,70): print "Score: " + str(value) + "; Your grade is D" elif int(value) in range(69, 80): print "Score: " + str(value) + "; Your grade is C" elif int(valu...
452d51ad68b1c4a3f98db1067de8edb51bb22376
JohnJBarrett22/Dojo-Academy
/python+django_TDD/exercise_01.py
1,180
4.09375
4
import unittest def min(l): # Should find and return minimum value in a given list min = l[0] for val in l: if val < min: min = val return min def sum_list(l): # Should return total value of all list items total = 0 for val in l: total += val return total d...
dba31b5887c45624fbfbbe23fc8560f2925c8f31
fullywave/py-project
/cc (1).py
225
3.890625
4
def median(numbers): sorted(numbers) size=len(numbers) if(size%2==0): med=(numbers[size//2-1]+numbers[size//2])/2 else: med =numbers[size//2] return med n=[1,2,3,4,5,6] print(median(n))
7773b9d8a68c78b18424bd0aa58c68675beddf43
sheepweevil/modulus-master
/sumoku/sumokucli.py
4,162
3.9375
4
#!/usr/bin/env python """ A CLI interface to play sumoku """ import argparse import sumoku.game import sumoku.gamestate class IllegalCommandException(Exception): """ Exception raised for badly formatted commands """ pass def parse_args(): """ Parse command line arguments """ parser = argparse.Argume...
cabf316b0dbb60d5222cfd2d9946687dc899fa8d
Plasmoxy/DevMemories
/Python/scripts042014/tkinter/test3.py
700
3.6875
4
# -*- coding: utf-8 -*- from Tkinter import * frameWidth = input("Enter your window Width..."); frameHeight = input("Enter yout window Height..."); root = Tk() def key(event): print "pressed", repr(event.char) def callback(event): frame.focus_set() print "clicked at", event.x, event.y ruller1.p...
1f7045c57eebae8af528e968ecaa3af2cd2d1360
Plasmoxy/DevMemories
/Python/district0/thread_queue_test.py
841
3.6875
4
import Queue import threading import time queue = Queue.Queue(); LOCKER = threading.Lock(); class counter(threading.Thread): def __init__(self, queue): threading.Thread.__init__(self); self.queue = queue; def run(self): a = 1; while True: a = a * 2 LOCKER.acquire(); #self.queue.queue.clear(); s...
04de8c8ba7a723eeb6c3e21b3dbc88123c7fec9e
Plasmoxy/DevMemories
/Python/scripts122014/object/sandbox1/mod/module0.py
305
3.734375
4
#python class Human: def __init__(self, name, age): self.name = name; self.age = age; def greet(self): print("%s : Hello, my name is %s and I am %d years old." % (self.name, self.name, self.age) ); def say(self, stringToSay): print("%s : %s" % (self.name, stringToSay) ); #end defs #end class
02f18c8cc701ad38c3999660fd7c4671dd2a101f
Plasmoxy/DevMemories
/Python/scripts042014/tkinter/test6.py
386
3.75
4
from Tkinter import * global xpos global ypos xpos = 30 ypos = 0 root = Tk() root.minsize(200, 200) text = Label(root, text="CUS") text.pack() def key(event) : global ypos global ypos if event.keysym == 's': ypos = ypos + 3 if event.keysym == 'w': ypos = ypos - 3 #end #end root.bi...
2aba1d6e99cfb601e2a9f660f5f4542dc20513b4
axeloh/fashion_MNIST
/classifier.py
7,504
4.09375
4
#!/usr/bin/env python # coding: utf-8 # This guide trains a neural network model to classify images of clothing, like sneakers and shirts. # This guide uses the Fashion MNIST dataset which contains 70,000 grayscale images in 10 categories. The images show individual articles of clothing at low resolution (28 by 28 pi...
9752b8f4aaae804ca9de024a3c5f834beb6831b9
snailfury/Object-detection-with-deep-learning-and-sliding-window
/renameImages.py
646
3.546875
4
import os from argparse import ArgumentParser def renameFiles(args): i = 0 fileList = [] for imageFile in os.listdir(args.folderName): if imageFile.endswith('.jpeg') or imageFile.endswith('.jpg') or imageFile.endswith('.png'): os.rename(imageFile, args.label + str(i) + '.jpeg') ...
86ce048e546df32db8e88452300b366a502eca84
RiyaThakore/Geeks-for-Geeks
/Array/sort-numbers.py
284
3.765625
4
dicts={0:0,1:0,2:0} arr=[0, 2, 1, 2, 0, 0, 1, 2, 2] keys=range(0,2) for u in range(len(arr)): for z in range(len(keys)+1): if z == arr[u]: dicts[z]=dicts[z]+1 print(dicts) sort_arr=[] for m in range(0,3): for n in range(dicts[m]): sort_arr.append(m) print(sort_arr)
aef3a3d307eb5de288cf1c4873637a402c92362c
RiyaThakore/Geeks-for-Geeks
/Linked List/rotate-linked-list.py
857
3.984375
4
class Node: def __init__(self, value): self.data = value self.next = None class LinkedList: def __init__(self): self.head = None def push(self, new_data): new_node = Node(new_data) new_node.next = self.head self.head = new_node def printlist(self): temp = self.head while(temp)...
d8c7d2017f997c265edf3714f381f981981ffd39
RiyaThakore/Geeks-for-Geeks
/String/anagram.py
360
3.75
4
#a = 'geeksforgeeks' #b = 'forgeeksgeeks' a='bd' b='bd' def letter_count(s): d = {} for i in s: d[i] = d.get(i,0)+1 return d def isAnagram(a,b): a1=letter_count(a) b1=letter_count(b) print(a1) print(b1) if a1 == b1: return True #true-false due to the boolean function ...
ce350f993717635999137e4468242ef714884b4a
RiyaThakore/Geeks-for-Geeks
/String/rotated-in-two-places.py
315
3.734375
4
def isRotated(str1, str2): if (len(str1) != len(str2)): return False clock_rot, anticlock_rot = "", "" l = len(str2) anticlock_rot = (anticlock_rot + str2[l - 2:] + str2[0: l - 2]) clock_rot = clock_rot + str2[2:] + str2[0:2] return (str1 == clock_rot or str1 == anticlock_rot)
7b84faec3e2daad6d731610e6d4967f1e3859537
yucheno8/newPython6.0
/Day01/p_07输出和格式字符串一起使用.py
479
4.125
4
''' 格式 化字符串并输出 ''' # 占位符形式的字符串 # 1 a = 10 print('现在要打印一个数字,值是 %d' % a) # 2 print('name: %s age: %d' % ('Tom', 12)) # 占位符的常用 格式 print('%d' % 1) print('%5d' % 1) print('%05d' % 1) print('%-5d' % 1) print('%3d' % 12345) print('%.2f' % 3.1415926) print('%.3f' % 1) # f-string name = 'Tom' age = 11 print(f'name: {name...
197911efa5cfab50f207f7ee688362dca0ac4ec3
angryjeks/my_study_projects
/iterations.py
1,503
3.71875
4
#import matplotlib.pyplot as plt from math import exp EPS = 0.000001 X0_for_SI = 2 X0_for_Newton = -5 X0_for_Newton_mod = -5 def dfdx(x): return 2*x - exp(-x-1) + 2 def f(x): return exp(-x-1) + x*x + 2*x - 1 def g(x): return -(exp(-x-1) + x*x - 1)/2 def SimpleIterationMethod(x0, func): """ Wor...
df41a80e90ce27ffc64a3fe86f0f3ade7eea249b
phenrique/metodos_numericos
/cap3/eliminacao_gauss/main.py
397
3.5
4
import numpy as np a = np.array([[3, 2, 1, 1], [1, 1, 2, 2], [4, 3, -2, 3]]) print(a, "\n") #m = a[i,k]/ a[k,k] atualiza_linha = lambda linha, lpivo : linha - m * lpivo i = 1 k = 0 while k < 2: while i < 4 : m = a[i,k]/ a[k,k] print(m, "\n") a[i,] = atualiza_l...
04d1d69aa7ccdcfd400bda2838ede271c346cd08
kristoforusbryant/srp-ecological-modelling
/main.py
1,330
3.828125
4
"""Simulating Randomly This script allows the user to obtain the random simulation result of species specific trajectories. The script should be run as: `python main.py --outfile results/out_matrix.pkl –-params params.json` This script requires the packages `numpy`, and `pandas` to be installed within the P...
74808eb3e5cbc12407a3e54e4dbdd9e70e08fb68
sophiecals/TextAdventure
/Kreaturen.py
1,034
3.8125
4
class Kreaturenfriedlich: """mögliche Kreaturen""" moeglicherloot = [Fleischgroß, Fleischklein] class Player: hp = 30 Inventory = [] class dreifueßigesReh: hp = 10 def AusgabeReh(self): print("Du stehst vor einem dreibeinigen Reh. Diese Kreatur ist nicht gut zu Fuß und leicht zu erl...
3c47b56deda38352aa8cd571d65a29c76d40827e
BRTytan/Unipexercicios
/IPE/Listas/ex04-04.py
330
4.15625
4
""" Exercicio 04-04:Escreva um programa que mostre os números de 1 até um numero digitado pelo usuário, mas, apenas os números impares. """ ################################################################################################### n1 = int(input("Digite um número: ")) x = 1 while x <= n1: print(x) x ...
85a5395808d0be9c6167bf26ec20da1042cf52cf
BRTytan/Unipexercicios
/IPE/loops/ex03-09.py
777
4.0625
4
""" Exercicio 03-09:Escreva um programa para aprovar o empréstimo bancário para compra de uma casa. O programa deve perguntar o valor da casa a comprar, o salário e a quantidade de anos a pagar. O valor da prestação mensal não pode ser superior a 30% do salário. Calcule o valor da prestação como sendo o valor da casa a...
8430284f35bd0d5028ab4f7bbd0224cbaaa95d44
BRTytan/Unipexercicios
/IPE/condicionais/ex02-09.py
495
4
4
""" Exercicio 02-09:Escreva um programa que leia a quantidade de dias, horas, minutos e segundos do usuário. Calcule o total em segundos. """ print('digite a baixo os dias, horas, minutos e segundos para receber o total em segundos') dias = int(input('Dias: ')) horas = int(input('Horas: ')) minutos = int(input('Minutos...
f04b4b2d639091ef6d2a21bf0a40604936664cc4
BRTytan/Unipexercicios
/IPE/inicias/ex01-02.py
382
4.34375
4
"""Exercicio 02: Resolva as expressões matematicas manualmente no caderno, apos, converta as seguintes expressões matematicas para que possam ser calculadas usando o interpretador python(confirmando o resultado encontrado)""" a = (10+20)*30 b = (4 ** 2) / 30 c = (9**4+2) * (6-1) print('Resultado de A é: {} \nResultad...
9e78e8f845448ba313457a1e948661f5dfc46a0a
smaje99/PythonGUITkinter
/bucky6.py
272
3.9375
4
from tkinter import * import tkinter.messagebox root=Tk() tkinter.messagebox.showinfo("Window Title","Monkeys can live up 300 years.") answer=tkinter.messagebox.askquestion("Question I","Do you like silly faces?") if answer=='yes': print("8===D~") root.mainloop()
7ffa201b33375467198f4cf42de2ddd9eba8ae87
judithrodriguez/BioinformaticsI
/PythonBioinformatics.py
1,221
3.921875
4
#!/usr/bin/env python #withoutBiopython import os, sys, re def reverse(s): sequence_list = [] for base in s: sequence_list.append(base) reverse_seq_LIST = sequence_list[::-1] reverse_seq = ''.join(reverse_seq_LIST) return reverse_seq def complement(s): sequence_list = [] for base ...
8a7ec731274ead70afe8a2665ba2254abfc64ac8
kylmcgr/Advanced-Machine-Learning
/mountaincar2.py
1,402
3.546875
4
import gym import numpy as np environment = gym.make('MountainCar-v0') def determine_action(observation, weights): weighted_sum = np.dot(observation, weights) action = 0 if weighted_sum < 0 else 2 return action def run_episode(environment, weights): observation = environment.reset() total_reward ...
0eb55829a0aee6d7136f91550e89b9bb738f4e73
Scertskrt/Ch.08_Lists_Strings
/8.1_Months.py
722
4.40625
4
''' MONTHS PROGRAM -------------- Write a user-input statement where a user enters a month number 1-13. Using the starting string below in your program, print the three month abbreviation for the month number that the user enters. Keep repeating this until the user enters 13 to quit. Once the user quits, print "Goodby...
64e674fce1b82165b02eae028e4b8013a1daec9f
nss10/code_with_nvas
/Ep2-Path Sum.py
948
3.84375
4
''' Ep2-Path Sum Problem - https://leetcode.com/problems/path-sum/ Youtube link - https://www.youtube.com/watch?v=-vbAQeUeNec&feature=youtu.be ''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # ...
74cce034a2bd6753cc7ed7a9db169621eaaeb759
chase1745/AdventOfCode2019
/1/day1-1.py
211
3.75
4
def fuelNeeded(mass): return (mass//3) - 2 with open('input1.txt') as file: fuel = 0 for mass in file.readlines(): fuel += fuelNeeded(int(mass)) print("Total fuel needed: {}".format(fuel))
15d6b51fc6f9e900614587417e16ac4eb4aa966b
chase1745/AdventOfCode2019
/1/day1-2.py
318
3.8125
4
def fuelNeeded(mass): return (mass//3) - 2 with open('input1.txt') as file: fuel = 0 for mass in file.readlines(): mass = int(mass) while mass > 0: mass = fuelNeeded(int(mass)) if mass >= 0: fuel += mass print("Total fuel needed: {}".format(fuel))
2310bf8085378a784286cd88c30894499805e45d
Littlebigelow/AtomikPaul_Main
/Python/playersublime.py
127
3.71875
4
player_name = input('What is your name? ') print('Hello, {player_name}. Get ready to start!'.format(player_name = player_name))
211e1e0008a9495a974bb92d74ed34dc435a3782
GemmyTheGeek/Geek-s-Python-Community
/lists.py
2,602
3.5625
4
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> garage = ['toyota', 'honda', 'izuzu'] >>> garage.append('suzuki') >>> print (garage) ['toyota', 'honda', 'izuzu', 'suzuki'] >>> print(garage[2...
2d5393c9956427291c688af389fa7b5ba90e6eb5
Alekceyka-1/algopro21
/part1/Lections/lection-07-08-файлы/ver_2/17.py
288
3.65625
4
with open('input.txt') as file: lines = file.readlines() lines.sort() # строки сортируются в лексико-графическом порядке print(lines) x, y = '100', '99' print(f"{y}\t{x}" if x > y else f"{x}\t{y}") lines.sort(reverse=True) print(lines)
b34464a06002b214176c646d9c5989090b70217d
Alekceyka-1/algopro21
/part1/LabRab/labrab-02/03.py
137
3.90625
4
x = int(input('Введите от 1 до 9 - ')) while x < 1 or x > 9: x = int(input('Введите от 1 до 9 - ')) print(x)
6bf1fca7410ab2c3bfc03f7a88940dbcff65f6c9
Alekceyka-1/algopro21
/part1/Lections/lection-07-08-файлы/ver_1/15.py
416
3.953125
4
# задача - считать строки из файла # там целые числа - отсортировать их # вывести в одну строку через пробел file = open('numbers.txt', 'r') lines = file.readlines() file.close() numbers = map(int, lines) print(numbers) numbers = list(map(int, lines)) print(numbers) numbers.sort() print(numbers) numbers.sort() pri...
5d1b110b22cbd95cf4dab8ac72a4bfabcf8e0e49
javi-cortes/python-utils
/dictsort_by.py
735
4.0625
4
def dictsort_by(d, order, items=False, skip=True): """ Iterate a dict in order. If k from order not found in d yield rest of d elements. :param d: dict to iterate. :param order: List with the keys order. :param items: flag to return k or (k, v) :param skip: only returns d.keys() & order and ...
8b79465db6f51f4631cdb5f8bec4504fef458c14
IsaacYouKorea/dovelet
/step2/even_odd.py
213
3.953125
4
#even_odd a, b = map(int, input().split(" ")) def oddeven(num) : return 'even' if num % 2 == 0 else 'odd' print(f'{oddeven(a)}+{oddeven(b)}={oddeven(a+b)}') print(f'{oddeven(a)}*{oddeven(b)}={oddeven(a*b)}')
37413cf592d71a6e73a7ef1749fcb0ec5aab77bf
IsaacYouKorea/dovelet
/step2/coci_note.py
502
3.890625
4
#coci_note notes = list(map(int, input().split(" "))) isDirection = 0 result = 'mixed' if (notes[0] != 1 and notes[0] != len(notes)): result = 'mixed' else : for i in range(len(notes) - 1): if (notes[i] > notes[i+1]): if (isDirection == -1): result = 'mixed' break isDirection = 1...
4f76681b3b1ba250a5c94b0e3ab478ee2ab8b7e1
RuiSantosdotme/RaspberryPiProject
/Code/Part_0/calculator.py
1,409
3.84375
4
#Part 0 - Python Calculator #latest code updates available at: https://github.com/RuiSantosdotme/RaspberryPiProject #project updates at: https://nostarch.com/RaspberryPiProject running = True welcome_message = '***Welcome to Python Calculator***' print(welcome_message) while running: print('Operations') print(...
50bdb7003099705f8effee400400053237365fb4
Jadamoureen/Andela35
/api/models.py
1,428
3.65625
4
from db import DatabaseConnection import re class Users: def __init__(self, username, email, password): self.username = username self.email = email self.password = password def validate_input(self): if not self.username or self.username.isspace(): return 'Username ...
723c8637c871436a2047e155a3f7513bd11f5401
NoahSaso/DailyCodingProblem
/05-21-2018/code.py
3,363
3.703125
4
# very brute force def justify(words, k): justified = [words[0]] for word in words[1:]: current_line_length = len(justified[-1]) # if room left in current line if current_line_length < k: added = False # if current length + 1 space + length of next word still allowed, add if current_li...
24b8784a3b380a174f6c07447cf753102dc64f4d
niranjan72001/movie-reccomendation
/v1.py
110
3.875
4
x,y=input("enter 2 variables").split() def hey(x,y): if(x==y): print(x) else: print(y) hey(x,y)