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
00b062fe411ebec0630d2e6283cc2adbc30253e2
sunjiyun26/pythonstep
/collectionSunjy/MyIterators.py
292
3.53125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- __author__ = 'sunjiyun' import itertools natural = itertools.count(1) for n in natural: # print n pass nchar = itertools.cycle("abc") for n in nchar: # print n pass nrepeat = itertools.repeat("a",10) for n in nrepeat: print n
e4b174e4142dba7c0d1e88fd16f457a6399684d0
HHOSSAIN/COMP10001
/Toy_world/Shortest_path.py
4,152
4.03125
4
import math def shortest_path(data, start, end, has_sword): # TODO implement this function. # node = start(initially), symbols:'W'=dragon, 't'=sword unexplored = [start] # my queue explored = set() steps = 0 rows = data["size"] columns = data["size"] if une...
c13da31deb04f6148a1e8aebb6ac842b23a291e7
unorthodox-character/Desktop_repo
/everything_python/python_practice/continue.py
164
4.03125
4
'''program demonstrating continue statement ''' list1 = ['tomato', 'potato', 'onion', 'biscuits'] for i in list1: if i == 'onion': continue print(i)
d48f7fe7caa442087dd7bbcda1fcd03364e211ce
etopiacn/PyProject
/Day1/chinese_zodiac_v2.py
972
3.6875
4
#序列:字符串、列表、元组 # 根据年份判断生肖 chinese_zodiac = '猴鸡狗猪鼠牛虎兔龙蛇马羊' #取余不是从鼠开始的,偷懒做法 #year = int(input('请用户输入出生年份:')) #print(year%12) #print(chinese_zodiac[year%12]) #if (chinese_zodiac[year%12]) == '狗': # print('狗年运势如何?') # for cz in chinese_zodiac: # print(cz) # # for i in range(13): # print(i) # # for year in range...
541dcd66126791a784c2265ce35c1800e277f301
aludkiewicz/comparativefunc
/python_examples/TailRecursion.py
228
3.734375
4
## Tail recursion in Python. Tail call optimization is not implemented though! def call_1000_times(count): if count == 1000: return True else: return call_1000_times(count + 1) call_1000_times(10000)
556032950c50dec1881145df8da4ccef3de2ceb5
David-boo/Rosalind
/Rosalind_GC.py
923
3.515625
4
# Code on Python 3.7.4 # Working @ Dec, 2020 # david-boo.github.io # In this code I'll use SeqIO, the standard sequence input/output interface for BioPython. You can find more information about BioPython on david-boo.github.io, be sure to check it out. # Using Bio.SeqUtils package aswell, which contains a G...
53181c9a84603d0180042085c01f488eef574d07
ralinc/learning-python
/plural.py
969
3.546875
4
import re def build_match_and_apply_functions(pattern, search, replace): def matches_rule(word): return re.search(pattern, word) def apply_rule(word): return re.sub(search, replace, word) return (matches_rule, apply_rule) patterns = \ ( ('[sxz]$', '$', 'es'), ('[^a...
45383257608d2cbeb76cffff05ec0e909a7e145a
ArturoBarrios9000/CYPEnriqueBC
/libro/problemas_resueltos/capitulo1/problema1_8.py
229
3.765625
4
X1=float(input("Ingrese X1:")) Y1=float(input("Ingrese Y1:")) X2=float(input("Ingrese X2:")) Y2=float(input("Ingrese Y2:")) D=((X1-X2)**2+(Y1-Y2)**2)**0.5 print(f"La distancia entre los puntos ({X1},{Y1}) y ({X2},{Y2}) es: {D}")
4a5d6a229b82007877b6f0225115c3fdf7f4f8a7
ArturoBarrios9000/CYPEnriqueBC
/libro/ejemplo3_2.py
164
3.828125
4
NOMINA=0 for i in range (1,11,1): SUE=float(input("Ingrese el sueldo:")) NOMINA += SUE # NOMINA = NOMINA + SUE print("La nomina de la empresa es:", NOMINA)
e6229545b1936b0d9c9b542508bd30847c83d1f4
ArturoBarrios9000/CYPEnriqueBC
/libro/ejemplo2_8.py
317
3.78125
4
CAT=int(input("Introdusca la categoria del trabajador (1-4):")) SUE=float(input("Introdusca el sueldo del trabajador:")) NSUE=0 if CAT ==1: NSUE=SUE*1.15 elif CAT==2: NSUE=SUE*1.10 elif CAT==3: NSUE=SUE*1.08 elif CAT==4: NSUE=SUE*1.07 print(f"El sueldo con categoria {CAT} con el aumento es: {NSUE}")
75e2df6d2e22a1c80dbb30403f8e48665c271b8d
ArturoBarrios9000/CYPEnriqueBC
/libro/problemas_resueltos/Capitulo2/Problema2_6.py
201
4.03125
4
A=int(input("Ingrese un numero entero para A:")) if A==0: print(f"El numero es nulo {A}") elif (-1**A)>0: print(f"El numero {A} es par") else: print(f"El numero {A} es impar") print("Fin")
a0641334cc478b267c205e47b475129a8e42fcaa
tanuj87/Deep_Learning
/Tensorflow_basic_using_Keras.py
5,352
3.53125
4
# coding: utf-8 # # TensorFlow basics # In[1]: import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns # In[2]: df = pd.read_csv('TensorFlow_FILES/DATA/fake_reg.csv') # In[3]: df.head() # In[4]: # very simple dataset # we will treat it as a regression problem, feature 1...
1d80ed6d34f0034acdf6268151663be23a105f64
devanshmanu/tetris
/a1.py
492
3.671875
4
BRICK = "o" CHK = "x" SPACE = " " NEWLINE = "\n" LEVEL = 1 GV=0 L=1 R="r" var_fill=0 total=0 def percentage(numerator, denominator): temp1 = float(numerator)*100 temp2 = float(denominator) fin = temp1/temp2 fin2 = math.ceil(fin*100) return fin2/100 def brickfunction(jk): matrixvar = 50 ...
d3eb57ca3377dcb7462afd86e43997a1f220e940
shivanshutyagi/python-works
/primeFactors.py
566
4.3125
4
def printPrimeFactors(num): ''' prints primeFactors of num :argument: number whose prime factors need to be printed :return: ''' for i in range(2, num+1): if isPrime(i) and num%i==0: print(i) def isPrime(num): ''' Checks if num is prime or not :param num: :r...
5070036543d29c4130456e7ded0ae21f694c7849
tsh/edx_algs201x_data_structures_fundamentals
/1-1_check_brackets_in_the_code.py
968
4.03125
4
from collections import namedtuple Bracket = namedtuple("Bracket", ["char", "position"]) def are_matching(left, right): return (left + right) in ["()", "[]", "{}"] def find_mismatch(text): stack = [] for i, char in enumerate(text, start=1): if char in "([{": stack.append((char, i)) ...
319e1c14b1b90d04c1202466eaf6a397a952e7c3
roberg11/is-206-2013
/ex45-workingGame/ex45scenes.py
9,959
3.828125
4
class Scene(object): # Empty dictionaries of hints and dialogs hints = {} dialogs = {} def enter(self, game): print "This scene is not yet configured. Subclass it and implement enter()." exit(1) # Action handling def actions(self, actions): actionText = { ...
a89ba3ea381c392845379d369981fca1a0a16d1b
roberg11/is-206-2013
/Assignment 2/ex13.py
1,150
4.4375
4
from sys import argv script, first, second, third = argv print "The script is called:", script print "Your first variable is:", first print "Your second variable is:", second print "Your third variable is:", third ## Combine raw_input with argv to make a script that gets more input ## from a user. fruit = raw_inpu...
c232410e848da610102a0a08b4077aa2295847b0
roberg11/is-206-2013
/Assignment 2/ex20.py
1,803
4.53125
5
from sys import argv script, input_file = argv # Definition that reads a file given to the parameter def print_all(f): print f.read() # Definition that 'seeks' to the start of the file (in bytes) given to parameter # The method seek() sets the file's current position at the # offset. The whence argument is optio...
f7bb2a3679f2f4c8d7d10ee151b68b802a1db3a2
roberg11/is-206-2013
/Assignment 2/ex4.py
2,001
4
4
# Number of cars available cars = 100 #Space available in each car space_in_car = 4.0 # Number of drivers for the cars drivers = 30 # Number of passengers in need to be transferred passengers = 90 # Number of cars which doesn't have any drivers cars_not_driven = cars - drivers # number of cars that has a driver cars_dr...
24f28e133e1af2d1490751fbae7a0065babcac13
roberg11/is-206-2013
/Assignment 2/ex10.py
1,453
3.96875
4
tabby_cat = "\tI'm tabbed in." persian_cat = "I'm split\non a line." backslash_cat = "I'm \\ a \\ cat." fat_cat = """ I'll do a list: \t* Cat food \t* Fishies \t* Catnip\n\t* Grass """ look = "Look over \"here\"." print tabby_cat print persian_cat print backslash_cat print fat_cat print look ##while True: ## fo...
3a0c72e28348bf2aa4d2c79038acb2ae0b95378f
bo-wambui/AssignmentOne
/reverseNames.py
161
4.21875
4
first_name = input("Please input your first name: ") last_name = input("Please input your last name: ") print("Hello "+last_name+" "+first_name+ ".How are you?")
91a675b7a124ef6eaae2c5fb17b4020c21371151
HoodCat/python_practice02
/prob05.py
688
3.59375
4
import random # 난수 생성. random 모듈에 random()함수 [0, 1) while(True): print("수를 결정하였습니다. 맞추어 보세요") correct = round(random.random()*99 + 1) higher = 1 lower = 100 answer = -1 count = 1 while(answer != correct): print(higher, '-', lower, sep='') answer = int(input(str(count)+'>>')...
571cee9a294a0a6ebed12944b4375728a16faf53
stephenstraymond/MEM611-Project
/read_table.py
6,941
4.15625
4
import argparse table_var_types = ['T','h','Pr','u','vr','s0'] def tableA17(search_var,known_var,known_value,units=True): """ tableA17(search_var,known_var,known_value,units=0): Function accepts 3 required inputs and 1 optional input and uses it to return data from the "Ideal-gas properties of...
c6926ba2b5c71b69c3811f3074d42fa4b81b8dae
IanCarreras/hash-tables-sprint
/hashtables/ex1/ex1.py
898
3.703125
4
def get_indices_of_item_weights(weights, length, limit): """ YOUR CODE HERE """ # Your code here # iterate over the given weights # for each weight as key store value limit - weight # iterate through hashtable # if key + value = limit && value is in hashtable # return indeces of the...
b19ad1363c219ef770d43730dc7e1a0ab228ee0f
eeTeam2015/MovieRecommendationSystem
/spider/Step1_GetMovieList/getMovieList.py
4,839
3.578125
4
# 从每个分类的每个评分段的页面保存为 html 文件,存放在 ./html import time from selenium import webdriver def Categorys(category: [], links): # 生成要爬取的链接列表 for ca in category: a = 100 b = 90 while b >= 0: links.append(ca + str(a) + ':' + str(b) + '&action=') a = a - 10 b = b - ...
f2632cac7b73b66147e19d6d91b03e1f4981e001
alunsong/learngit
/text.py
607
3.5625
4
import time def f(n): #time.clock() if n == 1: return 1 if n ==2: return 2 if n > 2: return f(n - 1) + f(n - 2) s1 = f(100) print("s1=",s1) def f(n): res = [0 for i in range(n+1)] res[1] = 1 res[2] = 2 for i in range(3, n+1): res[i] = res[i - 1] + res...
bac15d0dff5ead8ffef7b9d21699a31fc9ee8040
Botany-Downs-Secondary-College/mathsquiz-KevenNguyen
/mathsquiz6.5.py
6,576
3.765625
4
from tkinter import* from random import* class MathsQuiz: def __init__(self,parent): self.HomeFrame = Frame(parent) self.HomeFrame.grid(row=0, column=0) #Title of Home Frame. self.TitleLable = Label(self.HomeFrame, text = "Welcome to Maths Quiz", bg = "black", fg =...
8fc8f999fb37d659d75dea6710c4bd128d5218af
heejukim-developer/python-workspace
/2.py
714
3.984375
4
try: print("나누기 전용 계산기 입니다.") num1=int(input("첫번째 숫자를 입력하세요 : ")) num2=int(input("두번째 숫자를 입력하세요 : ")) print("{0}/{1}={2}".format(num1,num2, int(num1/num2))) except ValueError: print("에러입니다. 잘못된 값을 입력하였습니다.") try: print("한자리 숫자 나누기 전용 계산기입니다.") num1=int(input("첫번째 숫자를 입력하시오 : ")) num2=in...
01856fd211ccab5c354258010641a00dc658c759
heejukim-developer/python-workspace
/ 함수어려워.py
793
4
4
print("<나야나>") def std_weight(height,gender,std_weight): print("키 {0}cm {1}의 표준체중은 {2}kg입니다.".format(height,gender,std_weight)) std_weight(175,"남자",round(175*175*0.0022)) def std_weight(height,gender,std_weight): print("키 {0}cm {1}의 표준체중은 {2}kg입니다.".format(height,gender,std_weight)) std_weight(170,"여자",round...
676817b23e15e5368746b750f48e518427c937ae
onerbs/w2
/structures/w2.py
1,914
4.28125
4
from abc import ABC, abstractmethod from typing import Iterable from structures.linked_list_extra import LinkedList class _Linear(ABC): """Abstract linear data structure.""" def __init__(self, items: Iterable = None): self._items = LinkedList(items) def push(self, item): """Adds one item...
caa378a73cb04f342d31f9ba4dcf5e4f79d99b05
akiharapeco/ALGO
/trie_tree.py
1,639
3.71875
4
import sys input = sys.stdin.readline class Node: child = {} def __init__(self): self.child = {"" : None} def setChild(node, c): node.child[c] = Node() class TrieTree: node = Node def __init__(self): self.node = Node() def insert(self, key): node = s...
35316e103f8a17573e683063cc8d8c8f88349c02
akiharapeco/ALGO
/dictorder.py
163
3.6875
4
A = input() ans = [] for char in A: ans.append('a') if ans[:-1]: print(''.join(ans[:-1])) elif A[0] > 'a': print(ans[0]) else: print(-1)
1eec5250193255117f0b9fa0524c3a4b2c5cbfb1
akiharapeco/ALGO
/binary_search.py
482
3.578125
4
import sys input = sys.stdin.readline def binarySearch(S, N, t): N = N // 2 if S[N] == None: return 0 else: return binarySearch(S[:N], N, t) + binarySearch(S[N+1:], N, t) return N = int(input()) S = input().strip().split() # Sの始端と終端に番兵を追加 S.prepend(None) S.append(None) ...
fe313f72bfe399bdcdfdb20ddcfbf2ac2066530c
akiharapeco/ALGO
/LEETCODE/Python/binary_tree_level_order_traversal.py
856
3.78125
4
from typing import List # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None def appendOnSameLevel(t, level, depth): if t == None: return if len(level) < depth: level.appe...
1f61e69415255fe326fa30914706d09009b47940
nishaagrawal16/Datastructure
/Problems/check_ith_bit_is_set_or_not.py
10,441
4.40625
4
############################################################################ # BITWISE OPERATORS ############################################################################ # youtube.com/watch?v=PXlzn60mRKI&list=PLfQN-EvRGF39Vz4UO18BtA1ocnUhGkvk5&index=7 # Lecture 02 - Check a number is e...
7f7b411883c7f6985a354f163a11da1a879b0cac
nishaagrawal16/Datastructure
/Python/decorator_for_even_odd.py
1,363
4.21875
4
# Write a decorator for a function which returns a number between 1 to 100 # check whether the returned number is even or odd in decorator function. import random def decoCheckNumber(func): print ('Inside the decorator') def xyz(): print('*************** Inside xyz *********************') num =...
aa5bc400ed332b046f45db6233975294afa48494
nishaagrawal16/Datastructure
/Linklist/partition_a_link_list_by_a_given_number.py
2,555
4.125
4
#!/usr/bin/python # Date: 2018-09-17 # # Description: # There is a linked list given and a value x, partition a linked list such that # all element less x appear before all elements greater than x. # X should be on right partition. # # Like, if linked list is: # 3->5->8->5->10->2->1 and x = 5 # # Resultant linked list...
e24a154400dca8e0dc9b7cd24280e2aec5dc1464
nishaagrawal16/Datastructure
/leetcode/medium/153_find_minimum_in_rotated_sorted_array.py
639
3.671875
4
""" https://leetcode.com/problems/find-minimum-in-rotated-sorted-array Complexity ---------- O(logn) """ class Solution: def findMin(self, nums): l = 0 h = len(nums) - 1 while l < h: m = (l + h)//2 if nums[m] <= nums[h]: h = m else: # nums[m] > nums[h] l = m + 1 retu...
e26b77c4af32814a2608c3663b7a88dc400a6c46
nishaagrawal16/Datastructure
/Python/mro.py
2,019
3.953125
4
# Method Resolution Order(MRO) # https://makina-corpus.com/python/python-tutorial-understanding-python-mro-class-search-path # 1) Old style: when object is not the parent class as we are using python2. # We follow the DLR or depth-first left to right In which we first go # to the parent and ...
bf13df5bf072797b535624bca57f87f5f5c7b39c
nishaagrawal16/Datastructure
/sorting/bubble_sort.py
1,314
4.6875
5
# Date: 20-Jan-2020 # https://www.geeksforgeeks.org/python-program-for-bubble-sort/ # Bubble Sort is the simplest sorting algorithm that works by # repeatedly swapping the adjacent elements if they are in wrong order. # Once the first pass completed last element will be sorted. # On next pass, we need to compare till l...
8f1113231b2ad1f5c15bad8b5b704cee8c3f6514
nishaagrawal16/Datastructure
/Problems/reverse_a_number.py
1,014
3.609375
4
# **************************************************** # Reverse a number either positive or negative # O(n) # **************************************************** class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ if x > 2**31 - 1 or x <= -2**31...
da785b4c17fbed0a35787f7db82ee578ffaf07bf
nishaagrawal16/Datastructure
/Python/overriding.py
2,643
4.46875
4
# Python program to demonstrate error if we # forget to invoke __init__() of parent. class A(object): a = 1 def __init__(self, n = 'Rahul'): print('A') self.name = n class B(A): def __init__(self, roll): print('B') self.roll = roll ...
d651dd92ee3af966ab5321977ea4aa14f51ba543
nishaagrawal16/Datastructure
/leetcode/medium/2_add_two_numbers.py
1,822
3.8125
4
""" https://leetcode.com/problems/add-two-numbers/ Complexity ---------- O(max(m, n)) time and space """ # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class LinkList: def __init__(self): self.start = None def create_list(self, li): if...
3d12f27d6af0de12094419503b0009622250f7ac
nishaagrawal16/Datastructure
/Linklist/is_palindrome_using_stack.py
1,490
3.71875
4
# We solve this problem by using stack in which slow and fast two pointer point # to the start of the node. Then move slow pointer once and store slow.info in # the stack and fast pointer 2 times. class Node: def __init__(self, value): self.info = value self.next = None class SingleLinkList: def __init__(...
3778577e21146124a2fa652c248b92d987ffe074
nishaagrawal16/Datastructure
/Linklist/kth_node_from_last_in_one_traversal.py
1,749
3.8125
4
#!/usr/bin/python # Date: 2019-06-22 # # Description: # Find kth element from last in a singly linked list. # # Approach: # Take 2 pointers p1 and p2, move p1 to kth node from beginning and p2 at head. # Now iterate over linked list until p1 reaches end. When p1 reaches end p2 # will be k nodes behind which is kth fro...
9fb1a9a1a2619d67091e7e9a446dfbe7aad2271b
nishaagrawal16/Datastructure
/Python/decorator.py
1,722
3.59375
4
def decoWrapper1(func): def xyz(): print('start') func() return xyz @decoWrapper1 def print_hello1(): print('Hello') print('***************** decorator with function only ********************') print_hello1() # Output: # ------ # ***************** decorator with function only ***********...
e537579c394d862f7cb109983580cc4ea7055674
nishaagrawal16/Datastructure
/Problems/roman_to_integer.py
953
3.546875
4
class Solution: def romanToInt(self, s: str) -> int: if not s: return 0 switcher = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 } switcherSubs = { 'IV': 4...
e9258219764c0c6f0ce2dfc09285004a26c7effe
nishaagrawal16/Datastructure
/Python/partial_function.py
229
3.640625
4
from functools import partial def power(base, expo): print('{} base to the power of {}'.format(base, expo)) return base ** expo square = partial(power, expo=2) cube = partial(power, expo=3) print(square(3)) print(cube(3))
a49d1aba49b4e36f13e4eb077ddc5c569777df83
nishaagrawal16/Datastructure
/Python/shallow_and_deep_copy.py
1,422
4.0625
4
import copy # Shallow copy # https://docs.python.org/2/library/copy.html # A shallow copy constructs a new compound object and then (to the extent # possible) inserts references into it to the objects found in the original. # Means insert refernces of the inner objects also. l1 = [[1,2], 3, 4, [5, 6, 7]] l2 = copy.cop...
fee51facfda5df96e5aa73eaf6f7d3962df39c2c
cherkesky/urbanplanner
/city.py
762
4.59375
5
''' In the previous Urban Planner exercise, you practices defining custom types to represent buildings. Now you need to create a type to represent your city. Here are the requirements for the class. You define the properties and methods. Name of the city. The mayor of the city. Year the city was established. A collect...
bfd67d8551dff5d216bd92b1eeaacc42877860f6
coachmarino/web-caesar
/caesar.py
1,016
3.8125
4
def alphabet_position(letter): alphabet = 'abcdefghijklmnopqrstuvwxyz' alphabet2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' if letter.isupper(): position = alphabet2.index(letter) else: position = alphabet.index(letter) return(position) def rotate_char(char, rot): alphabet = 'abcdefghijklm...
be3e04c41570b44477a192c89071a42feb295c8d
SEIR-7-06/python-oop-demo-code
/main.py
2,448
3.890625
4
my_dictionary = { "some_key": "some value" } my_dictionary['some_key'] class User: def __init__(self, name): self.name = name def greet(self): print(f'Hi my name is {self.name}') me = User('Michael') bob = User('Bob') sally = User('Sally') me.greet() print(me) print(me.name) ##########...
2c5266d8513a64d2d4639d0bac5e1c0f1aff8cd9
kohyt/cpy5p1
/q6_find_ascii_char.py
683
4
4
# q6_find_ascii_char.py # get input ASCII = input("Please enter ASCII value: ") # check if ASCII.isnumeric(): if int(ASCII) > 0 and int(ASCII) < 127: input_ASCII = int(ASCII) print("The character is", chr(input_ASCII), ".") # output result else: print("Invalid option!") ASCII ...
c1f6b1f89881acf3db059195eaa52868156d2188
kr255/IS601_Project_One
/Operations/Mean.py
1,295
3.953125
4
import Addition # # def addemup(s1, s2, s3=[]): # print("s1 ", s1) # print("s2 ", s2) # s3.append(Addition.addition(s1[0], s2[0])) # return s3 # # def meanCalulation(listofnum): # n = len(listofnum) # #print("length of list", len(listofnum)) # if n < 2: # return # else: # ...
f15fa27d83f849e344e4c1e91672ed6debf43901
burunduknina/HW
/lec_3/hw2.py
319
3.53125
4
def is_armstrong(number): return sum(list(map(lambda i: i ** len(str(number)), [ int(elem) for elem in str(number)]))) == number if __name__ == '__main__': assert is_armstrong(153) is True, 'Число Армстронга' assert is_armstrong(10) is False, 'Не число Армстронга'
0361c59522f505f1b3555077ab4696d4dd95a655
darthkenobi5319/ICP-HW
/HW2/hw5.py
3,144
4.625
5
# Homework #5 # In all the exercises that follow, insert your code directly in this file # and immediately after each question. # # IMPORTANT NOTES: # # 1) THIS IS A PROGRAMMING COURSE. :-) THIS MEANS THAT THE ANSWERS TO THESE QUESTIONS # ARE MEANT TO BE DONE IN CODE AS MUCH AS POSSIBLE. E.G., WHEN A QUESTION SAYS "C...
8d17c04cda49436b3398588791a27acddb2c4acb
darthkenobi5319/ICP-HW
/Phonebook.py
7,544
4.15625
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 22 15:39:02 2019 @author: Harry Zhenghan Zhang """ class phoneBook: def __init__(self): self.phonebook = dict() # This function adds a contact with one name a one number # @param: contactName: A String specifying the contact name # co...
04170fea196f8c50f94e38a65335d08e51461ea7
jhlin2337/T-Rex-Runner-AI
/neural_network.py
4,146
3.703125
4
import numpy as np import tensorflow as tf import constants from tensorflow.python.framework import ops # Uses a xavier initializer to create the starting weights for the neural network and initialize # all biases to zero. Return the weights and biases in a dictionary def initialize_parameters(): # Initialize wei...
8d708e849f0ab71dd8d5d6940faf9d63eea84e3a
JuliaMowrey/AI-CSC481-Spring21
/astar-8puzzle-JuliaMowrey/eightpuzzle.py
4,168
3.984375
4
import copy import time from collections import deque class Puzzle: """A sliding-block puzzle.""" def __init__(self, grid): """Instances differ by their number configurations.""" self.grid = copy.deepcopy(grid) # No aliasing! def display(self): """Print the puzzle.""" ...
374d14cd58da240f5b779102ae6f1fdf41f1cd23
mousecpn/MMYZ_score_analysis
/Score_Analysis/Sort_by_id.py
563
3.765625
4
""" @ author:片片 @ 功能: 按照学号排序 @ 输入:DataFrame类型的大考数据,格式为【'班别','座号','语文','数学','英语','生物','化学','物理','总分'】 @ 输出:DataFrame类型,综合了四次大考的成绩,格式为【'班别','座号','语文','数学','英语','生物','化学','物理','id'】 """ import pandas as pd def Sort_by_id(dat): id = dat[['班别']].values*100 + dat[['座号']].values dat[['id']] = pd.DataFrame(id,columns=...
a958216fed11a0d41aaf7d974ddbef8d0dccee09
Serrones/tutorial_fastapi
/enums.py
220
3.515625
4
""" Module for storage enum classes """ from enum import Enum class ItemOption(str, Enum): """ This class represents all options available """ office = 'office' home = 'home' travel = 'travel'
8da1b3e55c7d3c0f941d28d2395c1e1d353be217
spikeyball/MITx---6.00.1x
/Week 1 - Problem 3.py
1,002
4.125
4
# Problem 3 # 15.0/15.0 points (graded) # Assume s is a string of lower case characters. # # Write a program that prints the longest substring of s in which the letters # occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your # program should print # # Longest substring in alphabetical order is: ...
7af6cfd6cca4d6d94e40da38f9fb7898e9570f0d
spikeyball/MITx---6.00.1x
/Week 2 - Exercise - Polysum.py
585
4.03125
4
# Grader # 10.0/10.0 points (ungraded) # A regular polygon has n number of sides. Each side has length s. # # The area of a regular polygon is: # The perimeter of a polygon is: length of the boundary of the polygon # Write a function called polysum that takes 2 arguments, n and s. This # function should sum the area an...
776a2822e9a89368babe21c0289fa93e4f1b6e55
CaptainMich/Python_Project
/StartWithPython/StartWithPython/Theory/OOP/Class.py
2,994
4.25
4
# ------------------------------------------------------------------------------------------------- # CLASS # ------------------------------------------------------------------------------------------------- print('\n\t\tCLASS\n') class Enemy: # define a class; ...
02b83cdcc2728b8fc27447483c069526f4766cd7
dcreekp/learn-C-the-hard-way
/ex17/ex17stack.py
574
3.875
4
#! /usr/bin/env python class Stack(list): def push(self, item): self.append(item) print(self) def pop(self): try: super().pop() print(self) except IndexError: print("stack is empty") def peek(self): try: print(se...
dd67e11094912546608dcf08689781b1ccb9fc80
lhwisdom07/ball_Filler
/ball_filler.py
391
3.796875
4
import math numberofB =int(input ("How many bowling balls will be manufactured? ")) ballD = float(input ("What is the diameter of each ball in inches? ")) ballR = float(ballD / 2) coreV = int(input("What is the core volume in inches cubed? ")) fillerA = (4/3) * (math.pi * (ballR ** 3))- coreV print("You will need",fil...
10ada69b7cf038032a55f0d71d1afce1054bd98a
blprottoy9/Hangman-game
/hangman.py
2,713
3.875
4
import random with open('d.txt','r') as f: store=f.read() store=store.split(" ") #print(store) word_store=('choose','convert','glory','MIGHTY','NATION') choose_word=random.choice(word_store) choose_word=choose_word.lower() length_choose=len(choose_word) show_word={} index={} for i in range(length_choose): ...
8b0b50e4d55d1f3258fb3f62d4f451254805f28e
pikez/Data-Structures
/tree/binary.py
2,420
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- nodes = [6, 4, 2, 3, '#', '#', '#', '#', 5, 1, '#', '#', 7, '#', '#'] avlnodes = [6, 4, 2, '#', '#', '#', 5, 1, '#', '#', 7, '#', '#'] class Node(object): def __init__(self, data, left=None, right=None): self.root = data self.left = left self.r...
fc3da55af0a89264a92cbd952792c952512a5d2a
pikez/Data-Structures
/sorting/selection.py
471
3.9375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def selection(array): length = len(array) for i in xrange(length): min_index = i for j in xrange(i+1, length): if array[j] < array[min_index]: min_index = j array[i], array[min_index] = array[min_index], array[i]...
ac7b07c69a07c42f03162712abfc6e3e4a422002
781-Algorithm/JangSeHyun
/week6/[BOJ] 1197 최소 스패닝 트리.py
647
3.671875
4
# 1197 - 최소 스패닝 트리 import sys input = sys.stdin.readline def find_parent(x): if parent[x] != x: parent[x] = find_parent(parent[x]) return parent[x] def union_parent(x,y): x = find_parent(x) y = find_parent(y) if x < y: parent[y] = x else: parent[x] = y v, e = map(int, ...
438eef065677d2a5907e66249d5c57b7b3870623
781-Algorithm/JangSeHyun
/week8/[BOJ] 11758 CCW.py
445
3.578125
4
# 11758 CCW 벡터의 외적 이용 points = [] for _ in range(3): points.append(list(map(int,input().split()))) def size(vector): return (vector[0]**2+vector[1]**2)**(1/2) vec1 = [points[1][0]-points[0][0],points[1][1]-points[0][1]] vec2 = [points[2][0]-points[1][0],points[2][1]-points[1][1]] func = (vec1[0]*vec2[1]-vec1[...
c4f448421cc18ec05b4cbb13e1a0dee5d8a38340
781-Algorithm/JangSeHyun
/week1/[PGS] 위장.py
279
3.703125
4
from collections import defaultdict as ddict def solution(clothes): answer = 1 look = ddict(list) for cloth in clothes: look[cloth[1]].append(cloth[0]) for category in look.keys(): answer *= (1+len(look[category])) return answer-1
cd93e32cb678128dc23f3d0fca0733f4ff0b50dd
yancostrishevsky/ASD
/Sorting algorithms/linked list structure.py
1,377
3.734375
4
#1. Zdefiniować klasę w Pythonie realizującą listę jednokierunkową. class Node: def __init__(self): self.value = None self.next = None def display(head): if head is not None: print(head.value, end=' ') display(head.next) #2. Zaimplementować wstawianie do posortowanej listy. ...
9a7024054f899d3e920735a797468c4d82f45634
beetisushruth/Python-projects
/AiRit/Passenger.py
889
3.703125
4
""" file: Passenger.py description: class to represent passenger language: python3 author: Abhijay Nair, an1147@rit.edu author: Sushruth Beeti, sb3112@rit.edu """ class Passenger: __slots__ = "name", "ticket_number", "has_carry_on" def __init__(self, name, ticket_number, has_carry_on): ...
f61e1501b64bb58aac7b0f10a83e2a74a025aee2
beetisushruth/Python-projects
/AiRit/Aircraft.py
2,937
3.6875
4
from Gate import Gate from MyStack import MyStack from Passenger import Passenger """ file: Aircraft.py description: Class to represent aircraft language: python3 author: Abhijay Nair, an1147@rit.edu author: Sushruth Beeti, sb3112@rit.edu """ class Aircraft: __slots__ = "passengers_with_carry...
bdef580de8d6b07376fca1738eb61cf2ed7323c6
tobin/contest
/codejam/2013/round1b/diamonds.py
5,490
3.703125
4
#!/usr/bin/python # Google Code Jam # Round 1B # # 2013-05-04 # # This program is an insane overkill approach to the problem. As one # might expect, the result of piling up a bunch of diamonds all # dropped from the same X position is a big triangular heap of # diamonds. The only uncertainty is how many diamonds are...
9f4ba3a66e8c23af39c7a1bc291232bc5ac25a2a
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/Conditional Statements - Exercise/Metric Converter.py
270
3.65625
4
num =float(input()) metric = str(input()) output_metric =str(input()) if metric == 'mm': num = num / 1000 elif metric == 'cm' : num = num /100 if output_metric == 'mm': num = num * 1000 elif output_metric == 'cm': num = num * 100 print(f'{num:.3f}')
f53bafc7419db675a259ba47d7d1e6d242f77c14
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/demo/demo.py
396
3.546875
4
import math count_people = int(input()) tax = float(input()) price_chaise_lounge = float(input()) price_for_umbrella = float(input()) total_taxes = count_people * tax using_umbrella = math.ceil(count_people / 2) * price_for_umbrella using_chaise_lounge = math.ceil(count_people * 0.75) * price_chaise_lounge total = t...
59218d18af7cd37b208211db3c1e68b3fe38319e
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/Loops - Exercise/Divide Without Remainder.py
447
3.546875
4
n = int(input()) p1_count = 0 p2_count = 0 p3_count = 0 for i in range(n): maimuna=int(input()) if maimuna % 2 == 0 : p1_count += 1 if maimuna % 3 == 0 : p2_count += 1 if maimuna % 4 == 0 : p3_count += 1 percentage_p1 = p1_count / n * 100 percentage_p2 = p2_count / n * 100 pe...
41c3cf50e396d276788761b849e6b76b6b7a49b2
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/1/04. Cruise Games.py
1,002
3.75
4
import math name = input() games = int(input()) sum_points = 0 volleyball_point = 0 v_games = 0 tennis_point = 0 t_games = 0 bardminton = 0 b_games = 0 for i in range(games): game_name = input() points = int(input()) if game_name == "volleyball": points *= 1.07 sum_points += points ...
de353ae4c821d56d3a6c6ed274c1e9e0b433cdb4
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/Conditional Statements - Exercise/Time + 15 Minutes.py
375
3.859375
4
start_hour = int(input()) start_minutes = int(input()) time_in_minutes = start_hour * 60 + start_minutes time_plus_15_min = time_in_minutes + 15 final_hour = time_plus_15_min // 60 final_min = time_plus_15_min % 60 if final_hour > 23: final_hour = final_hour - 24 if final_min < 10: print(f'{final_hour}:0{fi...
f54b1babee9082eef704f11cbbc8898d89ad7fc3
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/Simple-Operations-and-Calculations/Yard Greening.py
246
3.859375
4
meters = float(input()) total_price = meters * 7.61 discount = total_price * 0.18 total_price_with_discount = total_price - discount print(f'The final price is: {total_price_with_discount:.2f} lv.') print(f'The discount is: {discount:.2f} lv.')
6e453fc9e069e1039540bef271b37ce8b1b46a8b
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/Loops - Part 2 - Lab/10. Moving.py
394
3.875
4
width = int(input()) length = int(input()) height = int(input()) packet = 0 space = width * length * height new = input() while new != 'Done': pack = int(new) packet += pack if space < packet: break new = input() if space < packet: print(f'No more free space! You need {packet - space} Cu...
0a27a27ce4b4d243298eb238153dbd041b2c1d30
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/Nested Loops - Exercise2/02. Equal Sums Even Odd Position.py
376
3.875
4
start = int(input()) end = int(input()) for num in range(start, end + 1): num_as_string = str(num) even_sum = 0 odd_sum = 0 for i in range(len(num_as_string)): digit = int(num_as_string[i]) if (i + 1) % 2 == 0: even_sum += digit else: odd_sum += digit ...
635c54c51dffa81d2db4c35f4be86924b1afb3c0
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/Loops - Part 2 - Exercise/demoo.py
369
3.78125
4
import sys goal = 10000 goal_for_day = False while goal > 0: steps = input() if steps != 'Going home': goal -= int(steps) else: goal -= int(input()) if goal> 0 : goal_for_day = False sys.exit() if goal_for_day == False: print(f'{(goal)} more steps to reach g...
225068ae9d4fb3c932fce4b360361df5dfa2fed1
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/Simple-Operations-and-Calculations/Pet Shop.py
288
3.609375
4
dogs_count = int(input()) other_animals_count = int(input()) price_per_dog = 2.5 price_per_animal = 4 dogs_total_price =dogs_count * price_per_dog animal_total_price =other_animals_count*price_per_animal total_price= dogs_total_price + animal_total_price print(f'{total_price:.2f} lv.')
ea3e1ef85941dedae2c43079e5e59cac31e1c645
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/Loops - Lab/06. Vowels Sum.py
312
3.796875
4
word = input() word_len = len(word) sum = 0 for i in range(0, word_len): letter = word[i] if letter == 'a': sum += 1 elif letter == 'e': sum += 2 elif letter == 'i': sum += 3 elif letter == 'o': sum += 4 elif letter == 'u': sum += 5 print(sum)
19f8719fcb135da11f9745c324a6da5683761126
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/1/Exam Preparation.py
265
3.625
4
income = float(input()) count_mouth = int(input()) costs = float(input()) another_costs = income * 0.3 saving = income - costs - another_costs total_saving = count_mouth * saving print(f"She can save {(saving / income) * 100:.2f}%") print(f"{total_saving:.2f}")
4514ae4a7ca56012a5bf5e8a645d44249b0ffb21
zdravkob98/Programming-Basics-with-Python-March-2020
/Programing Basics March2020/Programming Basics Online Exam - 28 and 29 March 2020/04. Food for Pets.py
576
3.984375
4
count_days = int(input()) count_food = float(input()) cookies = 0 total_food = 0 dog_food = 0 cat_food = 0 for i in range(1, count_days +1): dog = int(input()) cat = int(input()) if i % 3 == 0: cookies += (dog + cat) * 0.10 total_food += dog + cat dog_food += dog cat_food += cat pri...
0dcd71b94bc6644c99522c34a0f3e2ba539aa055
msdansie/phys2300_labs
/lab5/michael_dansie_hw5_task1234.py
6,852
3.5625
4
#from vpython import * from math import cos, sin, radians import argparse from matplotlib import pyplot as plt def set_scene(data): """ Set Vpython Scene :param:data-dictionary of collected data """ scene.title = "Assignment 5: Projectile motion" scene.width = 800 scene.heigth = 600 sce...
fbd69540d6ecb9b6d4c3cc1e472d6e09f2053fbb
henaege/class-rpg
/skeleton.py
1,015
3.609375
4
from random import randint class Skeleton(object): def __init__(self): self.health = 13 self.power = 6 self.armor_class = 13 self.name = "Skeleton" self.xp_value = 8 def __repr__(self): return self.name def is_alive(self): if self.health > 0: ...
702bcebc5eaab5cf93b141e802d4ce2679c39b7d
ks93/ComputationalPhysicsProjects
/Project1/src/utils/gauss_elim.py
1,934
3.90625
4
""" Implementations of Gaussian elimination. """ import numpy as np def gaussian_elimination(A, b): """General Gaussian elimination. Solve Av = b, for `v`. `A` is a square matrix with dimensions (n,n) and `b` has dim (n,) Parameters ---------- A : np.ndarray (n,n) matrix b : np.ndarr...
ba7c65a7484d8eb81ba071864c60651ca6b97af2
christianparizeau/DailyCodeProblems
/daily3.py
467
3.890625
4
# Given an array of integers, find the missing positive integer in constant space. In other words, find the lowest positive integer that does not exist in the array. # The array can contain duplicates and negative numbers as well. #Should return 3. Question asks to do this in linear time, but that is beyond me array =...
94e48d810d2d77f72580bcefd39776cfe16d0ca2
Rupali0311/CNN
/CNN_adjusted.py
1,924
3.6875
4
import multiprocessing as mp from multiprocessing import Process import sys from CNN import CNN class CNN_adjusted: """ This class can be substituted by the CNN class in the code whenever the used GPU card has enough memory to save multiple instances of the data. If not (in our case for example a...
014dfab260bca2ad832bffed3def9f4d6504eca8
TheRealDarkWolf/Amazoff
/readTables.py
851
3.59375
4
import sqlite3 conn = sqlite3.connect("Online_Shopping.db") cur = conn.cursor() ''' prodID = "PID0000003" cur.execute("SELECT category FROM product where prodID = ? ", (prodID,)) print(cur.fetchall()[0][0]) # cur.execute("SELECT prodID FROM product WHERE sellID = {}".format(sellID)) ''' cur.execute("SELEC...
8a62c17fa130f29883a0e16d113711c7531e436a
JaxWLee/CodingDojoAssignments
/Python/Python_1/Intro/coin_tosses.py
508
3.640625
4
def coin_tosses(): import random heads = 0 tails = 0 for i in range(0,5000): x = random.random() x = round(x) if x == 1: heads += 1 print "Attempt #"+str(i+1)+" Coin is tossed.... Its a heads.... Got "+str(heads)+" heads and "+str(tails)+" tails so far" ...
d8f4104a62515dea59d865ccc527764df35054b6
JaxWLee/CodingDojoAssignments
/Python/Python_1/Intro/scores_grades.py
487
3.875
4
def scores_grades(num): print "Scores and Grades:" import random for i in range(0,num): x = random.random()*40+60 x = round(x,0) if x < 70: print "Score: "+str(x)+"; Your grade is D" elif x < 80: print "Score: "+str(x)+"; Your grade is C" elif ...
cb95a6ac5fdb278dfafbddad2d363fe72ff932a3
JaxWLee/CodingDojoAssignments
/Python/Python_1/Intro/finding_characters.py
442
3.84375
4
def find_characters(str_list,char): x = len(str_list) new_list = [] for count in range(0,x): y = str_list[count] z = len(y) zz = count for count in range(0,z): if y[count] == char: new_list.append(str_list[zz]) break pr...
10df4aff647a659adfd4adcee91974a0967771cd
JaxWLee/CodingDojoAssignments
/Python/Python_1/Intro/compairing_lists.py
1,018
3.875
4
def compare_List(list_one,list_two): x = len(list_one) y = len(list_two) z = 0 if x != y: print "The lists are not the same" elif x==y: for count in range (0,x): if list_one[count] == list_two[count]: z = z + 1 elif list_one[count]!= l...
9c00dde9e8736299e0579063547ff7e4d956e75b
s15011/algorythm_design_pattern
/algorythm/sort.py
4,104
3.609375
4
#!/usr/bin/python3 LIST_COUNT = 1000 LOOP_COUNT = 1000 MAX_NUM = 10000 def data_generate(): import random return [random.randint(1, MAX_NUM) for _ in range(LIST_COUNT)] def selection_sort(data): for i in range(len(data) - 1): minimum = i for t in range(i + 1, len(data)): if ...