blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3945241d765ca9f123408cc6fe6574a1fba9d6e3
aukoyy/sandbox
/python-practice/foundamentals/dictionaries.py
437
4.59375
5
# Initiated with curly braces # Consists of key value pairs student = {'name': 'john', 'age': 25, 'courses': ['Math', 'CompSci']} # These are ways of accessing values by keys print(student['name']) print(student.get('name')) # [] method of access will produce a keyerror if none is found. The {} method returns none # ...
e1b4ed2be7b156677d3254ae159b5a25fd13bc29
crjerry/gitworksm
/python_study/trim.py
188
3.890625
4
def trim(s): if s[0] == " " and s[-1] == " ": return s[1:-1] elif s[0] == " ": return s[1:] elif s[-1] == " ": return s[:-1] else: return s
6c958e04e88cce477eb71a3db4096b3ce1a5629b
josenaldo/python-learning
/exercicios/extras/tartaruga.py
225
3.984375
4
def main(): for numero in [5, 4, 3, 2, 1, 0]: print("Eu tenho", numero, "biscoitos. Vou comer um.") #----------------------------------------------- # a linha a seguir inicia a execução do programa main()
425efcc6df64b16d27e1bc614807f2c287d26b9c
moontasirabtahee/Problem-Solving
/CodeForce/443A. Anton and Letters.py
315
3.890625
4
def anton_and_letters(): inp = input() letters = [l for l in inp[1:len(inp)-1].split(', ') if l] letter_set = set() for letter in letters: if letter not in letter_set: letter_set.add(letter) return len(letter_set) if __name__ == '__main__': print(anton_and_letters())
be2775e0392059585b92de9c7a5f5165481360d2
Piper-Rains/Sandbox
/password_check.py
427
4.15625
4
MIN_LENGTH = 4 print("Please enter a valid password, with a length no less than {}".format(MIN_LENGTH)) password = input("> ") while len(password) < MIN_LENGTH: print("Invalid password length") print("Please enter a valid password, with a length no less than {}".format(MIN_LENGTH)) password = input("> ")...
ff94cd313169a951514c41d3df8ad36bd7b16300
Risoko/Algorithm
/hash_table_open_addressing.py
1,901
3.859375
4
class HashTable: """Hash table using open addressing""" def __init__(self, size): assert type(size) == int, "Must be type int" self.table = [None for _ in range(size)] self.size = size def _hash_function(self, key): """Helpty hash function.""" return k...
54c269ef09a17b57f3c25c169677a0dd50d32acd
matatablack/clyphx-pro_user-actiolns
/template/utils/log_utils.py
1,434
3.5625
4
def _make_member_desc(member_name, member): return '{} <{}>'.format(member_name, type(member).__name__) def dumpobj(obj, show_callables=False): '''A debugging function that prints out the names and values of all the members of the given object. Very useful for inspecting objects in interactive sessi...
02f40516e510fa87f184572e0ba9ced1a30b24ed
TerryLun/Code-Playground
/HackerRank Problems/halloween_sale.py
271
3.640625
4
""" https://www.hackerrank.com/challenges/halloween-sale/problem """ def howManyGames(p, d, m, s): r = 0 while s > 0: s -= p p = max(p - d, m) r += 1 print(s) return r if s == 0 else r - 1 print(howManyGames(20, 3, 6, 80))
343b6f81c4ef10ac84a8efc4c2dc0213b231558c
cdimattina/MPI_Python
/FIBNUM/fibo.py
1,187
3.875
4
""" fibo.py Description: This computes the fibonacci sequence for multiple inputs using a serial process (one core only) Basic fibonacci sequence calculation base case: f(1) = 1 f(2) = 1 recursion: f(n) = f(n-1) + f(n-2) , n > 2 Usage: python3 fibo.py <n1> <n2> ... <nK> """ ...
3fa3ba230b8ee6e97e39e861246e0ae7a9030804
shanwan/python3-course
/firstProgram/attack_basic.py
831
3.75
4
import random class Enemy: hp = 200 def __init__(self, attacklow, attackhigh): self.attacklow = attacklow self.attackhigh = attackhigh def getAttack(self): print("Attack is ",self.attacklow) def getHp(self): print("Hp is", self.hp) enemy1 = Enemy(40, 49) enemy1.get...
2b087280c1da108ad7ce29330362571a61ccdd31
Hamng/hamnguyen-sources
/python/sort_by_column.py
1,766
4.1875
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 25 09:25:10 2019 @author: Ham HackerRanch Challenge: Athele Sort Task You are given a spreadsheet that contains a list of N athletes and their details (such as age, height, weight and so on). You are required to sort the data based on the K-th attribute and...
f0f9ffe06f8c07f1657b93e61a490ff3d8e66e0d
cognosphere/intro-to-python
/Class 6 - Comparison & Boolean Operators/comparison_operators.py
1,803
4.65625
5
#Comparison Operators: ==,!=, >, <, >=, <= print("== Operator") print(2==2) #This will return True print(1==2) #This will return False print("----------") print("!= Operator") print(2!=2) #This will return False print(1!=2) #This will return True print("----------") print("> Operator") print(3>2) #This will return T...
0dcb4d8336183ee6bcb9f0b16990c27c745fbe6d
NizanHulq/Kuliah-Python
/struktur_data/Stack_/InfixPostfix.py
2,405
3.75
4
# ini membuat class stack class Stack: def __init__(self,max): self.top = -1 self.stackSize = max self.datum = [] def isEmpty(self): if self.top == -1: return True else: return False def isFull(self): if self.top == self.stackSize-1 : ...
c533718b58d64be5339e60529d11fbcfb1f2c77b
tailaiwang/Competitive-Programming
/wcipeg/sorting.py
236
3.578125
4
#sorting list1=[] out=[] n=int(input()) for i in range(n): c=int(input()) list1.append(c) for i in range(len(list1)): out1=min(list1) list1.remove(out1) out.append(out1) for i in out: print(i)
b71a067f8b38475a8c493fb13306a2fbcbe37ee9
osnaldy/Python-StartingOut
/chapter2/SalesPrediction.py
167
3.5
4
sales = float(raw_input("Enter the annual sales: ")) print "The Annual sale is ", sales expected_profit = sales * 0.23 print "Expected annual profit ", expected_profit
57c4c89319467a04ef6b11282772f94b5819f318
ieuan-jones/Doodle
/snake.py
4,294
3.90625
4
from doodle import * # A function to add a berry to the screen def add_berry(berries, snake): # First try and place the berry randomly new_berry = [rand(0,31), rand(0,23)] # If it's hitting the snake, or another berry, move it while new_berry in berries or new_berry in snake: new_berry = [...
507e337ed5c1b39d1da53fd1cc8da1f741e491e5
Daehyun-Bigbread/Bigbread-Python
/python_for_everyone/10A-count.py
257
3.8125
4
# while 명령으로 반복해서 숫자를 출력하는 프로그램 print("[1-10]") x = 1 while x <= 10: # x가 10 이하인 동안 반복(1에서 10까지 실행) print(x) x = x + 1 # x에 1을 더해서 저장합니다.
1f8c2b26fa7fdf13dd2ad875557c3b96f99fe79c
kjh03160/Algorithm_Basic
/Kakao_Intern_2021/1.py
465
3.625
4
def solution(s): answer = '' mapping = {'zero': 0, 'one': 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9} temp = '' for string in s: if string.isdigit(): answer += string else: temp += string if temp in mapping: ...
330a013b6d875cb41d27c95594574fe732b7491f
suhassrivats/Data-Structures-And-Algorithms-Implementation
/Problems/Leetcode/49_GroupAnagrams.py
447
3.640625
4
class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: """ Time Complexity: O(n.slog(s)) // n is len of input, s is len of string Space Complexity (auxiliary): O(n.s) // total information content stored in dict """ dict = {} for word ...
1cb336b334bfb92e007ec099a10b9a42a1bf7f63
smzztx/pythonlearn
/4advancedcharacter/split.py
173
3.734375
4
#!/usr/bin/env python L=['michael','sarah','tracy','bob','jack'] print L print L[0:3] print L[:3] print L[1:3] print L[:-2] T=(1,2,3,4,5,6,7,8,9,10) print T print T[:3]
da875fe759f55aaeb229db1d7c07f0402ac6b4d5
walterbeddoe/Batch17python
/operadoresMatematicos.py
599
3.71875
4
#x = 10 #y = 4 #suma = x + y #print(suma) # #resta = x - y #print(resta) # #multiplicacion = x * y #print(multiplicacion) # #division = x / y #print(division) # #division_redondeado = x // y #print(division_redondeado) # #residuo = x % y #print(residuo) # #exponencial = x **2 #print(exponenci...
8b313d62f1a464040aada513feba2157202b1af4
HUGGY1174/MyPython
/Ch05/Lab01.py
408
3.828125
4
frind_list = [] a = input("친구의 이름을입력하시오.") frind_list.append(a) a = input("친구의 이름을입력하시오.") frind_list.append(a) a = input("친구의 이름을입력하시오.") frind_list.append(a) a = input("친구의 이름을입력하시오.") frind_list.append(a) a = input("친구의 이름을입력하시오.") frind_list.append(a) print(frind_list)
9bc0af8efdcdee32c9853fe36fe8bda62ca36e8d
marjan-sz/CodeSignal_Solutions
/removeDuplicateStrings.py
1,179
4.0625
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri Feb 28 22:01:27 2020 @author: marjan Question: Remove all duplicates from an already sorted (in lexicographical order) array of strings. Redefine the question: a) an array of strings is given as input/array is sorted b) remove all duplicates ...
4d3425816630376568f313d146d573b6563d49b7
panpan7/panpan7.github.io
/example/Python/string.py
716
4.09375
4
s = 'string' print(len(s)) print(s[0]) # 输出序列的第一个元素 print(s[-1]) # 输出字符串的最后一个元素 print(s[1:3]) # 输出字符串的第2-3个字符,不包含第4个字符 t = '这是个中文字符串' print(len(t)) # 使用+运算符合并字符串 print(s + t) # 使用*运算符复制字符传 print(s * 3) # 使用字符串对象的内置方法 print(s.find('in')) print(s.replace('g', 'gs')) # 虽然显示字符串已被替换,但实际上是一个新的字符串。 # 字符串类型是不...
7a495dbbd0c56c7398808eb2d1eb79b3f7c3f93d
dictator-x/practise_as
/algorithm/leetCode/0148_sort_list.py
1,146
3.984375
4
""" 148. Sort List """ class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def sortList(self, head: ListNode) -> ListNode: if not head or not head.next: return head def middle(head): slow, fast = head, head ...
3948de62dbd37ba62778521c634812470d3bb29b
Jonathan-aguilar/DAS_Sistemas
/Ago-Dic-2019/Jorge Alberto Hernandez Sanchez/Practicas/Practica1/5.2_More_Conditional_Tests.py
718
3.9375
4
car = "Mercedez" print("Is car == 'Mercedez'? I predict True") print(car == "Mercedez") print("\nIs car == 'Seat'? Ipredict False") print(car == "Seat") print("############################################") car = "Ford" print(car.lower() == "ford") car = "Seat" print(car.lower() == "Seat") print("#################...
dcd7bafbb8ab0ac07083d8fac8a6d9aab4087a48
souravskr/MS-Project
/Experiments/venv/lib/python3.7/site-packages/cnfgen/families/pigeonhole.py
8,948
3.71875
4
#!/usr/bin/env python # -*- coding:utf-8 -*- """Implementation of the pigeonhole principle formulas """ from cnfgen.cnf import CNF from cnfgen.graphs import bipartite_sets from itertools import combinations, product def PigeonholePrinciple(pigeons, holes, functional=False, onto=False): """Pigeonhole Principle C...
f7d7910fbe6829e78b8e8ea76b6d7cc4bc84e6cb
tuinfor/Data-Structure-And-Algorithmns
/Codepath/Linked list/Asignments - Hackerrank/Plus One Linked List.py
1,725
3.65625
4
''' Given a non-negative integer representatted as a non-empty singly linked liswt of digits, add one to the integer. You may assume the integer do not contain any leading zero, except the number 0 itself The digits are stored such as that the most significant dif is at the head of the list Input: 1->2->3 Output: 1-> ...
5061ab5533c712226e72a5f66acab16ea2236f1e
ShannonCanTech/Python-Crash-Course
/ChapterOne/stripping_whitespace.py
451
4.15625
4
email = input("Enter your email: ") #Adds whitespace to the right of the output, then strips it away print("'" + email + '\t' + "'") print("'" + email.rstrip() + "'") # Adds whitespce to the left of the output, then strips it away print("'" + '\t' + email + "'") print("'" + email.lstrip() + "'") # Adds whitespace to...
112748b77d8d9cd6792f9386f94b390e36a23241
gavinbarrett/ScriptObscurer
/obscure.py
500
3.625
4
def hexpad(character): ''' Return a padded hex encoding of an ascii character ''' character = hex(ord(character))[2:] if len(character) == 1: return '0' + character return character def html_entity_encode(string): ''' Encode an ascii string as HTML entities ''' return ''.join([f'&#x{hexpad(c)};' for c in strin...
21d3fcbc8e788472f18c65cb49f447ee51b30583
bormanjo/py-snake
/snake.py
2,496
3.796875
4
import config class FIFOQueue(object): '''A First-in First-out priority Queue of fixed capacity''' def __init__(self, *args, capacity: int): self._data = list(args) self.set_capacity(capacity) def __repr__(self): return self._data.__repr__() def __str__(self): return ...
57b8850414670d4ff065e260aa6b0a089d345d74
Anshum4512501/dsa
/graphs/graph_transpose.py
1,004
3.78125
4
# Graph Transpose # O(V+E) times # O(V2) in if using adjacency matrix from collections import defaultdict class GraphAbstract: def __init__(self,nodes): self.nodes = nodes self.adj_list = defaultdict(list) def addedge(self,u,v): self.adj_list[u].append(v) def printgraph(self): ...
46528dbc058be6bc3d6ed8460e3b623131524718
DokiStar/my-lpthw-lib
/ex7.py
724
4.28125
4
# 输出一个字符串 print("Mary had a little lamb") # 输出一个字符串,将字符串“snow”嵌入前面的字符串 print("Its fleece was white as {}.".format('snow')) # 输出一个字符串 print("And everywhere that Mary went.") # 输出10个句点,使用*运算符重载实现 print("." * 10) # 定义12个(字符型/字符串型)变量 end1 = "c" end2 = "h" end3 = "e" end4 = "e" end5 = "s" end6 = "e" end7 = "b" end8 = "ue" ...
8c9501603728eb82ed2fe923e6d1ed7213289c35
eruns/GUI
/Rules_orig.py
6,399
3.671875
4
from Hand import * from Deck import * from Enums.Rank import * class Rules(object): """Defines the rules of go fish game.""" def __init__(self, deck=None, points=None, books=None): """Creates deck object. Args: deck (deck): all cards. """ self.deck = None ...
1a9f6664c38047941be5acb46f37f67703b684c4
ximuwang/Python_Crash_Course
/Chap8_Functions/Practice/8-8 User Albums.py
1,060
4.03125
4
# 8-8 User albums def make_album(artist, title, tracks = 0): '''Build a dictionary containing the info about an album''' music_album = {'artist': artist.title(), 'title': title.title(), } if tracks: music_album['tracks'] = tracks return music_album ...
0becc906f497decb23e19e73c7f35eba911f5edf
haochi/raspberry-pi-tasks
/time-announcer
167
3.734375
4
#!/usr/bin/python3 from datetime import datetime now = datetime.now() print("It is {} {} {} right now".format(now.hour % 12, now.strftime('%M'), now.strftime('%p')))
3097696dc8fad57e80325bbcbf8f6d58a402b6b7
Vanshika-RJIT/python-programs
/positional arguments or keyword arguments.py
219
3.671875
4
#positional arguments def add(n1,n2): print(n1) print(n2) s=n1+n2 print(s) add(2,3) #keyword arguments def add(n1,n2): print(n1) print(n2) s=n1+n2 print(s) add(n2=2,n1=3)
e1a799cf996ec3b32f171f41fce7db3f9bf9e611
GriffH/school-files
/project_1/hausken_griff_todays_date.py
151
3.984375
4
from datetime import date #importing date module todaydate = date.today() #gets the date print("Today's date is: ", todaydate) #displays date
de6a9b38fee45959803e942bd83ce889563fb518
Telos4/ICFP-Contest-2015
/Texts/freq.py
481
3.5625
4
#!/usr/bin/python from collections import defaultdict from collections import OrderedDict import pickle # words = "apple banana apple strawberry banana lemon" datf = open("others_combined.txt", 'r') words = datf.read() datf.close() # meh # words.decode('utf-8').lower() d = defaultdict(int) for word in words.split...
ccf8b0a1fed04f30463a1102226393041283313b
ZhouNan1212/LeetCode
/DataStructure/Queue.py
908
4.25
4
# -*- coding: utf-8 -*- class Queue(object): # 无限长队列,这里可以设置队列长度 # 初始化队列为空列表 def __init__(self): self.items = [] # 判断队列是否为空,返回布尔值 def is_empty(self): return self.items == [] # 返回队列的大小 def size(self): return len(self.items) # 返回队首的元素 def queue_first(self): ...
435f9f5fe78e3a985efc9d152c630e4924c1cc98
klw11j/Financial-and-Election-Analysis-Python
/PyBank/Analysis/main.py
1,958
3.78125
4
import os import csv csvpath = os.path.join('..', 'Resources', 'budget_data.csv') total_months = [] total_profit = [] profit_change = [] with open(csvpath) as csvfile: csvreader = csv.reader(csvfile, delimiter=',') csv_header = next(csvreader) for row in csvreader: total_months.append(row[0])...
ec9836d172488b69f03e7be545c62f8c69930335
LuisC18/ws_simple_pickup
/my_grasping/src/process_path.py
2,397
3.625
4
#!/usr/bin/env python def prepare_path_transforms_list(path_source, scaling_factor=0.100): import csv import numpy as np # Load solution path from CSV into numpy Array with open(path_source) as csvfile: dataList = list(csv.reader(csvfile, delimiter=',')) path = np.array(dataList[0:], dtype=np.float) ...
01c2937df5ed2f12f113aec4133531b608125b12
NiravModiRepo/Coding
/OOD/DesignPatterns/factory.py
449
3.859375
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 2 15:28:41 2018 @author: Nirav Modi https://www.youtube.com/watch?v=flOXIdWUpmU Factory Method """ #A design patter which lets a function which class to create BaseClass = type("BaseClass", (object,),{}) C1 = type("C1", (BaseClass,), {"x":1}) C2 = type("C2", (BaseClas...
4fd9657d6c53a053601a04472a1789ae8607a382
bakunobu/exercise
/1400_basic_tasks/chap_8/ex_8_15.py
736
3.765625
4
def seq_qunc(x:int) -> float: num = x ** 2 + 100 den = x + 200 return(num / den) def calc_less_nums(my_func, min_value:float, max_value:float) -> None: while True: try: m = float(input('Введите число: ')) if min_value <= m <= max_value: ...
e2b36c88abaca12f6ebcf5503b9e10bb1ff3d6a6
MTGTsunami/LeetPython
/src/leetcode/math/202. Happy Number.py
917
3.78125
4
""" Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycl...
59432f2c8382816a320066934d7e3f32cfe86f60
Mapoet/py_ggcm
/ggcm_re.py
4,001
4.0625
4
from re import * SCI = "[+-]?\d+\.\d+[eE][-+]?\d+" DEC = "[+-]?\d+\.\d+" INT = "[+-]?\d+" num_patt_dict = {'dec':DEC, 'DEC':DEC, 'sci':SCI, 'SCI':SCI, 'int':INT, 'INT':INT} any_num_patt = ".*?(%(sci)s|%(dec)s|%(int)s)" % num_patt_dict def find(pattern, string, flags = 0): resul...
019e5614141e62e6c32481227794dc323b74d809
ykambham/mydev1
/stringexamples/sum_of_all_sub_strings.py
1,048
4.09375
4
# Sum of all sub strings # Complexity o(n2) def sub_strings(str1): sub_strings_list = [] for i in range(len(str1)): for j in range(i, len(str1) + 1): sub_strings_list.append(str1[i:j]) return sub_strings_list def sum_of_sub_strings(str1): return sum(int(a) for a in sub_strings(str1...
85b17bd3d3eb3a738573b2537c7201130821dd8b
ajay-jayanth/Python-NLP
/nlp_script.py
1,993
3.5
4
''' Author: Ajay Jayanth Date: 9/22/20 Description: Naive Bayes Algroithm predicts the Content Category feature of text using a tf-idf vectorized set of text data ''' # C:\Users\msctb\AppData\Local\Programs\Python\Python38-32\Scripts import pandas as pd import sklearn from sk...
d2db0b2f4da1841ca46af2b99cc16b1da20668f8
MartinMa28/LeetCode-Solutions
/top_interview_questions/easy/merge_sort.py
668
4.125
4
def merge_sort(arr): mid = int(len(arr) / 2) if mid == 0: # the array only has zero or one element, so it's already sorted return arr else: return merge(merge_sort(arr[0:mid]), merge_sort(arr[mid:])) def merge(arr1, arr2): if len(arr1) == 0: return arr2 if len(arr2) ...
d492d61741cf0a9bcf0a7716e291ea40b028fc59
chrisglencross/advent-of-code
/aoc2015/day21/day21.py
2,504
3.578125
4
#!/usr/bin/python3 # Advent of code 2015 day 21 # See https://adventofcode.com/2015/day/21 from dataclasses import dataclass @dataclass class Character: name: str hp: int damage: int armor: int def attack(self, other): other.hp -= max(1, self.damage - other.armor) @dataclass class Item...
bc88f4700e7a12507e10ec1dee57514f431cc9c2
FelixTheC/hackerrank_exercises
/hackerrank/CamelCase.py
251
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @created: 03.05.20 @author: felix """ def camelcase(s: str): return 1 + sum([1 for char in s if char.isupper()]) if __name__ == '__main__': print(camelcase('saveChangesInTheEditor') == 5)
97239cac6cde82a245360593d8ce4784fcc07198
jhansi-yallay/DjangoApplication
/newone.py
1,013
3.796875
4
# class Parent: # def __init__(self,msg): # self.msg = msg # def sample(self): # return self.msg # class Child(Parent): # def child_sample(self): # return "sample child class" # print("Call parent class") # obj = Parent("calling parent method") # print(obj.sample()) # print("call chi...
e46f7e310772c381787df33db8ff564c8df86175
dyoung418/Google-Drive-Python-Utilities
/retry.py
5,785
3.796875
4
""" Download all files from a specified Google Drive (identified by its "folder" id) on my Google Account "marcelschlatter@gmail.com" to D:/Google Drive/Google Drive Download. From D:/Google Drive/Google Drive Download the folder is then synced (using Google Drive functionality) with my Google Drive on marcel@aurum-s...
570ae17649ef9a83a3da67827dbf00cf8db2ec28
feizhihui/Coursera-Python-Repo
/lecture_1/find_monisen.py
353
3.75
4
# encoding=utf-8 from math import sqrt, log2 def isPrime(n): assert type(n) == int for i in range(2, int(sqrt(n)) + 1): if n % i == 0: return False return True for i in range(2, 1000000): if not isPrime(i): continue p = log2(i + 1) if not p == int(p): continue if i...
ffd0f13b91008acafd781ae22fbd082c85a31555
jenningchen/logsAnalysis
/newsdata.py
2,229
3.53125
4
#!/usr/bin/env python3 # Reporting tool that generates reports based on data provided import psycopg2 import datetime import calendar def main(): """Print most popular 3 articles of all time.""" get_articles() """Print most popular authors of all time.""" get_authors() """Days where more than 1%...
b569dff50bad1110df44e318464f013a9e86f458
anne75/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/2-uniq_add.py
182
4.03125
4
#!/usr/bin/python3 def uniq_add(my_list=[]): """ add all the unique elements in a list my_list: a list of ints Return: sum """ return (sum(set(my_list)))
d5a8797a1f66768c5b13e8dd4d8628e469d23797
juanvergaramunoz/SE-Main_Functions
/HashTable_Class.py
3,765
4.09375
4
# coding: utf-8 # In[1]: ######################################### ####### General HASH TABLE CLASS ######## ######################################### # Includes a contact class: X.name, X.number, X.address --> The number is the one that provides the main identifier ####### FUNCTIONS FOR THIS CLASS ####### # # - _...
8e906cbfe667eb73cbd2d362fb20c1b85987748a
adrielj/CS104-01
/richter2.0.py
789
4.28125
4
testing = True while testing is True: richter = float(input("What was the recorded Richter scale magnitude? Type -99 to end")) if 8 <= richter <= 10: print ("Most of the structures have fallen.") continue elif 7 <= richter < 8: print ("Many buildings have been destroyed") ...
79f423d207758bda3df1dddc9521c446f602a60c
babs20795/DataSciene_ML
/Python/Odd_Even.py
182
4.125
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 5 10:20:31 2020 @author: Babs """ num=input("Enter a number:") a=int(num) if a%2 ==0: print("Even") else: print("Odd")
fee9b6d61b1913db920f2a98feee43ad50aa5e30
zhangzi2/Quick-Python-Projects
/polynomial_roots.py
2,213
4
4
import math #1 A = float(1) B = float(0) C = float(-4) print( "\nThe coefficients of the equation:\n" ) print( " Coefficient A = ", A ) print( " Coefficient B = ", B ) print( " Coefficient C = ", C ) root1 = (-B + math.sqrt(B**2 - 4*A*C)) / (2 * A) # replace 0.0 with the quadratic formula root2 = (-B - math.sqrt(...
22e2462fe5d7d3ab5114b85eb54dea6bed9b40ee
vishalkumar9dec/demopython
/ExampleFunctionParameters.py
926
4
4
'''def addition(num1, num2): answer = num1 + num2 return answer x = addition(5,6) print(x) #No limit on the number of parameters being passed def website(font,background_color,font_size,font_color): print('font: ',font) print('BG:',background_color) print('Font_Size:',font_size) print('Font ...
0bf4b2a8074c8c3333a6a0905b9efd1fc5f6651a
mvphjx/Test_framework
/learn_and_try/python_book_automate/04-list/commaList.py
283
3.703125
4
def commaList(items): ret = '' for item in items[:-1]: ret += item + ', ' return ret + 'and ' + items[-1] spam = ['apples', 'bananas', 'tofu', 'cats'] spam.sort(reverse=True) print(spam) print(commaList(spam)) a=["b","a","c"] b = sorted(a,reverse=True) print(b)
ab47be46c47d0709982d617269085880f23cd32d
Harrison-Hughes/project_euler
/problem51.py
4,968
3.875
4
# By replacing the 1st digit of the 2-digit number *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime. # By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit number is the first example having seven primes among the ten generated numbers, yielding...
d1541ed52487a0c2a0504cd25fabc37cb2c95990
vmarcella/d2dl
/maths/auto_grad.py
3,941
3.890625
4
from mxnet import autograd, np, npx npx.set_np() # Create the initial ndarrary x = np.arange(4) # Allocate memory for the gradient buffer that is of the same shape # as the input vector. x.attach_grad() # Display the gradient buffer, which is initialized at 0. It is initialized # at 0 for the event that the gradien...
16ae54462e50f09fbb1bc3794c52e83a50003646
5thCorner/Coffee_Machine
/Problems/I have friends/main.py
481
3.640625
4
class Song: def __init__(self, artist, name, year): self.artist = artist self.name = name self.year = year def __repr__(self): rep = "Artist: {}. Name: {}. Year: {}".format(self.artist, self.name, self.year) return re...
084179ea4f9b155da661f1f2b7c5f74f3bde4f26
mi-ran/Algorithm
/CodeForce/Kefa_and_Park.py
869
3.515625
4
def visite(dic, vs, current, cnt, con): if vs[current] is 1: cnt = cnt - 1 else: cnt = con res = 0 if current in arr: for p in arr[current]: res = res + visite(dic, vs, p, cnt, con) else: if cnt >= 0: return res + 1 return res ...
7c599d75d459a069dae8e8261b74ebeb2d623526
Elwing-Chou/mtkpython
/1_oo_1020.py
1,005
4.09375
4
# https://docs.python.org/3/reference/datamodel.html#object.__init__ class Person: def __init__(self, name, height, weight): self.name = name self.height = height self.weight = weight def bmi(self): return self.weight / (self.height / 100) ** 2 def __str__(self): re...
b162adbf6fdd54a90122c9ee2c56f133430693b2
calwoo/graph-notes
/word-ladder.py
801
3.578125
4
import sys sys.path.insert(0, "./implementations/") from adjacency_list import Graph def construct_graph(words): d = {} g = Graph() # form buckets of words that differ by one letter for word in words: for i in range(len(word)): bucket = word[:i] + "_" + word[i+1:] ...
0b4304baf1755d976ea42a630b01730422a69022
sconetto/ppc
/listas/contest_2/a_cash.py
251
3.640625
4
n = int(input()) times = [] for i in range(n): h, m = input().split(' ') times.append(h + ':' + m) biggest = 0 repeated = list(set(times)) for i in repeated: if (times.count(i) > biggest): biggest = times.count(i) print(biggest)
da18b7ed765563efd8c417760c83ef1d82322d6b
balajisomasale/Chatbot-using-Python
/02 Advanced Python Functions/bond_jamesbond.py
619
4.0625
4
'''Write a function named introduction() that has two parameters named first_name and last_name. The function should return the last_name, followed by a comma, a space, first_name another space, and finally last_name.''' # Write your introduction function here: # Uncomment these function calls to test your introduc...
a68e1e1d96f90338d0f139a696ab2fea333bec03
avivrm/beginpython
/Include/assignment2/assign3.py
209
3.84375
4
# Use map and a lambda function to find the maximum x coordinate (the 0-th coordinate) in a list of points. # You will need to apply max to the result of the map arr = [45, 23, 87, 11, 23, 89] print(max(arr))
91b86aa5e9c9d5f6caf26264b886c1fc3adf37f9
Andreivilla/PythonCV
/078.py
293
3.90625
4
vet = [] for i in range(0, 5, +1): vet.append(float(input('N[{}]: '.format(i+1)))) maior = menor = vet[0] for i in range(0, 5, +1): if menor < vet[i]: menor = vet[i] if maior > vet[i]: maior = vet[i] print('Maior: {}'.format(maior)) print('Menor: {}'.format(menor))
14b1608f8e169a486eb481e7e42e943ba02d1549
hado66/python_project
/s14/day02/shopping_demo.py
928
3.984375
4
salary=int(input("please input you salary:")) list=[ ["IPhone",5800], ["Mac pro",12000], ["Starbuck",31], ["Alex python",81], ["Bile",88], ["a",200], ["b",300], ["c",400] ] account=salary current_list=[] while account>0: for index,i in enumerate(list) : # print(list.index(i)...
11d29b02d3133aa828248e66f6b7cc9e36ddf91c
will8211/my_euler_solutions
/euler_19.py
1,058
3.921875
4
#!/usr/bin/env python3 ''' You are given the following information, but you may prefer to do some research for yourself. • 1 Jan 1900 was a Monday. • Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap y...
b817f76165f147b4d92b0852477fa17f51c2cdb2
pepitogrilho/learning_python
/xUdemy_tkinter/Sect2_Python_Refresher/12_if_01.py
268
4.09375
4
# -*- coding: utf-8 -*- """ """ day_of_week = input("What day of the week is it today?").lower() if day_of_week == "monday": print("Have a great start to your week!") elif day_of_week == "tuesday": print("Tuesday!") else: print("Full speed ahead!")
cb9653b6482fba64133ccbbb4cad3f051b391bf2
Sidhus234/Python-Dev-Course
/Codes/Session 3/Session 3 - Python Basics - Escape Sequences.py
213
3.625
4
# Escape Sequence weather = 'It's sunny' weather = 'It\'s sunny' weather = "It\'s \"kind of\" sunny" weather # \n new line # \t tab print("\t It\'s \"kind of\" sunnt\n hope you have a good day !")
047c1c5c0040b7b7b7c2c330622e0752a5381316
hobg0blin/ganterbury-tales
/scripts/clean.py
1,571
3.59375
4
import argparse import re parser = argparse.ArgumentParser() parser.add_argument('filename') args = parser.parse_args() with open(args.filename, "r") as file: # this script contains a bunch of individual regexes for common footnote/non-corpus patterns and deletes lines that contain them clean_name = ("_clean....
ace8832ee9a0bcdb52f5718238c55ba2bc9399ee
BaseCampCoding/python-fundamentals
/7-methods/pytest-exercises/methods.py
3,127
3.765625
4
def greeting(name): ''' str -> str Returns a greeting telling the provided name hello. ''' raise NotImplementedError("Delete this line and put your code here") def city_banner(city_name, banner_width): ''' (str, int) -> str Returns a welcome banner for the provided city. The message shou...
c3ff78e520dca62b48e19d48cd50b09d2e178dac
blaoke/leetcode_answer
/序号题/445.py
1,485
3.625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: stack1 = [] stack2 = [] while l1 or l2: if l1: ...
c72cbaa302b31a34461aa631a30114e7bb77516f
wsgan001/InterestingnessSurvey
/FirstAssociationRules/PatternLabelling.py
1,703
3.65625
4
import sys def readAnnotationFile(file_name): association_rules = {} with open(file_name, "r") as text_file: for line in text_file: subStrings = line.split(":") rule_key = subStrings[0].strip() label = subStrings[1].strip() association_rules[rule_key] = ...
f3b54a61fbb1d6d3862548044e8b3915a7bd5e62
zlbruce/nrciz
/projecteuler/032/032-nacre.py
443
3.5
4
#!/usr/bin/env python from itertools import permutations def is_pandigital_product(s): if int(s[:2]) * int(s[2:5]) == int(s[5:]): return 1 if int(s[0]) * int(s[1:5]) == int(s[5:]): return 1 return 0 lp = [] for s in permutations('123456789'): s = reduce(lambda x, y: x + y, s) if is_pandi...
90f03a75aa39442183faa8b75f9b8d35815ef6c1
AdamZhouSE/pythonHomework
/Code/CodeRecords/2909/60889/280000.py
521
3.671875
4
def letterType(letters,limit): letters = set(letters) if len(letters)<=limit: return True else: return False String = input() limitType = int(input()) minSize = int(input()) maxSize = int(input()) count = {} maxCount = 0 for i in range(len(String)-minSize+1): str1 = String[i:i+minSi...
508142279900214b6994e85c367d9392dc43d813
TripleFlex/DojoAssignments
/Python/structure/fundamentals/cointoss.py
612
3.734375
4
from random import randint print "Starting the program..." def coinToss(): heads = 0 tails = 0 for count in range(1,5001): flip = randint(0,1) if flip == 0: heads+=1 print "Attempt #" + str(count) + " Throwing a coin... its a Head! ... Got" + str(heads) + " head(s) ...
866350497e289578c1e501e8c178498652dde4eb
migueltorrescosta/DSA-Together-HacktoberFest
/algorithms/greedy/JumpGame.py
625
3.578125
4
#Link https://leetcode.com/problems/jump-game/ """ Greedy Algorithm You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return true if you can reach the last index, or false otherwise. """ clas...
03f9aca2d2708ac738ee12b7bf7c9359b749617e
wanguiwaweru/micropilot-entry-challenge
/wanguiwaweru/count_zeros.py
390
3.953125
4
# Write a function CountZeros(A) that takes in an array of integers A, and returns the number of 0's in that array. # For example, given [1, 0, 5, 6, 0, 2], the function/method should return 2. # Naive solution """ def CountZeros(A): count = 0 for i in A: if i == 0: count += 1 return co...
d861c05b2651ff5bd978596ddcd886e27f3541a7
zcgu/leetcode
/codes/308. Range Sum Query 2D - Mutable.py
2,924
3.9375
4
# Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2). # Range Sum Query 2D # The above rectangle (with the red border) is defined by (row1, col1) = (2, 1) and (row2, col2) = (4, 3), which contains sum = 8. # Exa...
b635c4bbce464bedc7a752c832b8d7e5fc7b75b6
tanuj208/CipherForces
/flask_app/2/helper.py
1,057
4.21875
4
#TODO: Better conversion methods def convert_to_num(text): """Converts a text message to a list of numbers (their ascii codes).""" nums = [] for character in text: nums.append(ord(character)) return nums def convert_to_text(nums): """Converts a list of numbers to characters using numbers as their ascii code....
919fd01d12e48882bf9e80fd2fa1c0fc447c81a5
AMARTYA2020/nppy
/Project EULER/Problem_22.py
998
3.890625
4
''' Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For example...
91b485949feb1003b2e5e14872e26b2b96e7cc4f
shandaiwang/leetcode
/remove_duplicates_from_sorted_list.py
1,146
3.734375
4
__author__ = 'pld' import linkutils """ Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. """ class Solution(object): def deleteDuplicates1(self, head): """ :type head: ListNode...
f9f1e15b0eae2d0bc831040bc0111d04f84f3103
realRichard/-offer
/chapterTwo/algorithmsAndDataManipulation/minNumber/1.2.py
1,112
3.765625
4
def my_min(arr): if not isinstance(arr, list): print('invalid input') return None for i in arr: if not isinstance(i, int): print('invalid input') return None if len(arr) == 0: return None start = 0 end = len(arr) - 1 middle = start # i...
1e80d4cf53291e6f5fdb3dfdcf844b3842a4fc68
Bouteloua/bioinformatics_p1
/GCcontent.py
810
3.640625
4
#By: Brian Franzone #Email: Franzone89@gmail.com #For: Bioinformatics E-100. assignment 1 problem 1 #Summary: This script determines the total amount of GC content ratio in a given sequence. Ignores codon structures. import random def main(): #N is the length of the randomly generated sequence N = 30000 print 'G...
144572ebb910e8855da87401d14835f02a99f897
sanster9292/Daily-Algorithm
/kangaroo.py
441
3.84375
4
''' PROBLEM URL: https://www.hackerrank.com/challenges/kangaroo/problem Description: For two kangaroos jumping in a positive direction on the x axis, tell if they will ever cross. '''' vals = input().strip().split(' ') x1, v1, x2,v2 = [int(i) for i in vals] first = x1-x2 second = v2-v1 if (x1<x2) and (v1<v2): ...
c2c39d754f8feaf0342aa068507a596b16e35943
ralitsapetrina/Programing_basics
/exam_practice/9-10march2019/tennis_ranklist.py
560
3.5625
4
from math import floor number_plays = int(input()) start_points = int(input()) won_play = 0 tour_points = 0 for play in range(number_plays): play_outcome = input() if play_outcome == "W": tour_points += 2000 won_play += 1 elif play_outcome == "F": tour_points += 1200 elif play...
86da43ce94041f758810c0af5d4c26614048f210
Ramshiv7/Python-Codes
/Makes_twenty.py
328
4.21875
4
#### MAKES TWENTY: Given two integers, return True if the sum of the integers is 20 *or* if one of the integers is 20. If not, return False def makes_twenty(n1, n2): if n1 + n2 == 20 or (n1 == 20 or n2 == 20): print(True) else: print(False) makes_twenty(20, 10) makes_twenty(12, 8) makes_twent...
8f9058f339b5765054adcd840f8be899ea316dcf
viharati/fc_python
/04/4th-1.py
161
3.53125
4
# -*- coding:utf-8 -*- datafile = open('text2.txt', 'r') data = datafile.read() print(data+'\n\n') string=data.decode('utf-8').encode('euc-kr') print(string)
8a1d587a3a727a61ce8f33494485ab1a7e578b2f
IShahnawazShaikh/Python-Programming
/MapFilter.py
95
3.625
4
number=[1,2,3,4,2,6,2,2,9,10] def even_num(n): return n!=2 print(list(filter(even_num,number))
4e9cba77af2b9ce6913c0c8589e5dabcb3acfc23
t4rxzvf/IFT383
/mod-5/types.py
227
4.0625
4
#!/usr/bin/python myString="HELLO!" myNumber=123456 myFloat=3.14159 myList=[1, 2, 3, 4] print type(myString) print type(myNumber) print type(myList) print type(myFloat) if (type(myString) is str): print "We have a string!"
3cce9a30cb276ae3f367fd9310f3859c15654887
HuberTRoy/pythonTricks
/tricks/define_a_class_manually_by_namedtuple.py
380
3.96875
4
from collections import namedtuple # use string. Car = namedtuple('Car', 'name color') # use other iterable class. Car = namedtuple('Car', ['name', 'color']) my_car = Car('rabbit', 'light gray') # light gray. print(my_car.color) # Car(name='rabbit' , color='light gray') print(my_car) # Namedtuples are immutable. ...
896c06b8248692d9750ab1a43d8697a05270107e
Edwin-Pau/FAM-Application
/driver.py
9,746
3.65625
4
#!/usr/bin/env python3 """ This module contains the Driver class and serves as the entry point for the Family Appointed Moderator application. """ from menu import Menu from transaction import Transaction from budget import BudgetManager, Budget from user import User from rich import print class Driver: """ ...
e415e6d2e9654088096891c556930469904e8244
Michaeloye/python-journey
/simp-py-code/time.py
96
3.6875
4
import time print(time.time()) for letter in range(ord("a"),ord("y")+1): print(chr(letter))