blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
32cc2a74873ed67c2b0acec7a1cb147ab49d5f4e
yawei798/AlgorithmsAndDataStructures
/用Python解决数据结构和算法/4:递归/four_9.py
1,733
3.5625
4
""" 动态规划:找零钱问题 """ # # 通过循环,但是没有跟踪 # def dpMakeChange(coinValueList, change, minCoins): # for cents in range(change+1): # coinCount = cents # 这是按每个都是1美分时的最大情况 # for j in [c for c in coinValueList if c <= cents]: # if minCoins[cents-j] + 1 < coinCount: # coinCount = min...
c4ce8cb096120452a9e25f7d1fb86f9a4ffb2570
PrajjwalDatir/CP
/gfg/jug1.py
2,795
4.1875
4
# Question 1 """ so we have linked list with data only equal to 0 , 1 or 2 and we have to sort them in O(n) as I think before prajjwal knows the answer of this question """ #so first we need linked list to start withs class Node: """docstring for Node""" def __init__(self, data): self.data = data self.next = Non...
1a1ab1382d7b17c9eda914a0d482ed0ac6c28578
bercik29/pythoncourse
/rkapitulacia.py
589
3.5625
4
#!/usr/bin/env python import csv import sys import statistics file_name = sys.argv[1] data = [] with open(file_name, 'r') as f: reader = csv.reader(f) for row in reader: for e in row: data.append(int(e.strip())) print(data) print(len(data)) print(min(data...
248cd5a664b182aef291084a8f40aa5e68b7e503
tianhaomin/algorithm4
/Stack1.py
999
3.984375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- #链表实现,可动态处理lalala class node(object): def __init__(self): self.item = None self.next = None class Stack(object): first = node() def __init__(self):#初始化 self.first = None self.n = 0#计数 def isEmpty(self): return...
00b7e0584a958e551657b126bb2d1a331383f2b8
fancunwei95/MD_MC_molecular_simulation
/stat.py
718
3.59375
4
#!/usr/bin/env python import sys from math import sqrt fo_name = sys.argv[-1] fo = open(fo_name,"r") average = 0.0 count = 0.0 data = [] for line in fo: this_num = float(line.split()[-1]) data.append(this_num) accept = data[-1] start = int(round(0.125*len(data))) print start average = 0.0 std_2 = 0.0 count ...
f34b640719dad2fc38b2dcb820b24dcccc26f4dc
jmtellez/beautyParlorApi
/TestProgram.py
1,238
3.75
4
__author__ = 'Juan Tellez' from API import * while 1: showMenu() choice = int(raw_input()) if choice is -1: print" Bye..." break elif choice is 1: print "Your options are: Barber, Hair Stylist, Receptionist" val= raw_input() getStaffByPosition(val) elif c...
1dd0b6d5d74e9dc35335c72d06c7061b64749611
bossjoker1/algorithm
/pythonAlgorithm/Practice/151翻转字符串里的单词.py
566
3.75
4
# 我的sb解法 # 因为python string 不可变所以必须得有个额外的结果数组 class Solution: def reverseWords(self, s: str) -> str: temp = s.split(' ') temp.reverse() temp = [x.strip() for x in temp if x.strip() != ''] print(temp) return ' '.join(x for x in temp) class Solution: def reverseWords(self, ...
a7d201fcaa89ec97ca9fc07b104672b665b10c24
myano/primes
/list_of_primes.py
558
4.34375
4
#!/usr/local/bin/python import Is_Prime def findprimes(h): ''' This function will generate a 'list' of prime numbers up to the given number inputted by the user. ''' li=[] for n in range(2, h): j=0 if Is_Prime.Is_Prime(n) == True: j+=1 li.append(...
bd190ff7638072ae4befb62e0c73c880d61bb371
FabianoBill/Estudos-em-Python
/Curso-em-video/115-exerciciospython/d073_times.py
576
4.21875
4
# Exercício Python 73: Crie uma tupla preenchida com os 20 primeiros colocados da Tabela do Campeonato Brasileiro de Futebol, na ordem de colocação. Depois mostre: a) Os 5 primeiros times.b) Os últimos 4 colocados.c) Times em ordem alfabética.d) Em que posição está o time da Chapecoense. times = ("a", "e", "i", "o", "u...
6227bc8f36dce8eda0b78bf590f9b7cbf6516135
ckeown/learning_rule
/NeuralNetwork.py
9,176
3.625
4
import imp import random import math from arabic_dataset import * # imp.reload(arabic_dataset) # Node for a neural netowrk # It's set up so you can traverse the network up or down (may be overkill) class Node: def __init__(self): self.activation = 0.0 # current activation of the node self.inputs ...
c7b8055766f7d476069f35da0a4b31ac050e7a44
jazywica/Algorithms
/_03_AlgorithmsOnGraphs/Python/_08_FastestRoute.py
6,182
4.3125
4
""" Simple example with Naive and dijkstra algorithm on a directed graph G(V, E), based on the '_08_FastestRoute.JPG' """ from collections import deque # EDGE RELAXATION: # Observation: any sub-path of an optimal path is also optimal, which takes us to the following property: If S-> ..-> u-> t is the shortest pa...
6ee265b6d22c2879354a7baae74c085a03f898c2
antonio00/blue-vscode
/MODULO 01/AULA 09/aula 09_EX01.py
560
4
4
L = [5, 7, 2, 9, 4, 1, 3] print(f'A lista original é: {L}') #printa a lista original print(f'A lista possui {len(L)} posições') # mostra o tamanho da lista print(f'O maior número é: {max(L)}') #MAX mostra o maior print(f'O menor número é: {min(L)}') #min mostra o menor print(f'A soma de todos os valores da lista é {su...
568e4eb7865bf005e2eae3ce87b0f46e661d531a
akozyreva/python-learning
/5-python-statements/5-for-loops.py
1,160
4.375
4
mylist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # simple example for num in mylist: print(num) for num in mylist: # Check for even if num % 2 == 0: print(num) else: # syntax for inserting the val of variable in print function print(f'Odd number: {num}') list_sum = 0 for num in mylist...
98201176305f67bdb98a3345039d6351e0aeee6c
pasko-evg/miptLabs
/lab008_Recursion/task_05_MinkowskiCurve.py
1,262
4
4
# Нарисуйте кривую Минковского. Кривая Минковского нулевого порядка - горизонтальный отрезок. # Затем на каждом шаге каждый из отрезков заменяется на ломанную, состоящую из 8 звеньев. import sys from turtle import Screen, Turtle def draw(length, n, turtle): # при нулевом - рисуем прямую if n == 0: ...
45c545c918402af234a299f2c6a30daebb2494a5
andrewharukihill/ProjectEuler
/43.py
1,197
3.859375
4
#The number, 1406357289, is a 0 to 9 pandigital number because it #is made up of each of the digits 0 to 9 in some order, but it also #has a rather interesting sub-string divisibility property. #Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this way, we note the following: #d2d3d4=406 is divisible by ...
6ba93b98a276a527b5b61e2eebf9ed49df7c57d3
hanao18182/100nk
/100nk02.py
602
4.125
4
#最初にUTF-8に設定しておく #-*- coding: utf-8 -*- #パトカーとタクシーを変数に代入する pat = "パトカー" tax = "タクシー" #あらかじめ"パタトカシーー"を入れる変数を用意しておく #文字列を入力するため""を設定しておく moji = "" #for文を用いて文字を先頭から交互に用意した変数に格納する #zipを利用することで先頭から一番短い文字の長さまで順に連結してくれる for x, y in zip(pat, tax): moji += x + y #最終的にmojiに格納されているのを呼び出す print(moji)
6f6ba280c84bf54115fa26bbb1cd695e6a5c168b
amritat123/login-signup
/login_sign_up.py
4,537
3.78125
4
import json def sign_up(): username=input("please enter your user name:-") password1=input("please create your password:- ") password2=input("confrom your password: ") dict={} if password1!=password2: print("both passward are not same😏") else: if "a" in password1 or "b" in pas...
9ff16468c89488a9793b15a7c4e2979740b14af7
wngus9056/Datascience
/Python&DataBase/5.24/Pandas03_13_GawiBawiBo_김주현.py
3,918
3.71875
4
# 묵 찌 빠 # 2 1 3 import random cwin = 0 uwin = 0 whowin = [] num_total = 0 def defnum1(): global uwin global cwin global num_total if computer == 1: num_total += 1 print('\tCom : 가위 / User : 가위\t You Draw! 비겼습니다!',end='\n\n') print('\t=> 현재 스코어 %d : %d ( 컴퓨터 : 당신 ) 입니다.'%...
244213bc990346c40d156df4545493aa66f5ed17
playsam32/oddments
/SungKyunKwan University/Freshman/Engineering Computer Programming (GEDT018-43)/2020313793.정우성.HW2.py
9,901
3.9375
4
#!/usr/bin/env python3 # # Copyright (c) 2020 by 정우성, All rights reserved. # # File : 2020313793.정우성.HW2.py # Written on : April. 05, 2020 # # Student ID : 2020313793 # Author : 정우성 (wsung0011@naver.com) # Affiliation: School of Electrical Engineering # Sungkyunkwan University # py versi...
a4493e924b78edfeeab1d1577d472f14491dc58b
dorgek/aoc2020
/src/day21/challenge.py
2,859
3.578125
4
import numpy as np import re def callculate_allergens( food_allergens ) : allergy_list = {} products_list = [] solved_products = [] for food_allergen in food_allergens : allergens = re.findall( "(?<=contains)[\\sa-zA-Z,]+", food_allergen )[0].replace( " ", "") products = re.fi...
5bdaa6d600bdcde565d783b605dda8f27723aacb
dnoronha15/git_practice
/fillDisk/fillDisk.py
2,141
4.09375
4
# Written to fill current drive by truncating file size. Will create new file if existing Garbage file is present import shutil import os # function to confirm user exit def press_to_exit(): input("Press Enter to exit...") print("Goodbye") exit() # Returns total,used, and free for drive in GiB def get_u...
0395af4323894a5e0829c0f34dd675b2a959b032
butterflylady/exercism
/leap/1.py
3,261
4.25
4
from typing import Dict, Optional, Tuple import string # Complete the max_result_expression function below. # You may add any imports you require from the standard library. # Feel free to define your own helper functions, classes etc as you see fit. def max_result_expression(expression: str, variables: Dict[str, Tu...
921e9699c12104305b67d56edb0d35ab9ca7f1ce
AFazzone/Python-Homework
/afazzone@bu.edu_hw_11_7.7.py
1,434
3.546875
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 19 21:31:06 2019 @author: alf11 """ class LinearEquation: def __init__(self, a, b, c, d, e, f): self.__a = a self.__b = b self.__c = c self.__d = d self.__e = e self.__f = f def getA(self): ...
f7a7116b8f540cf47b9979392c14ee5058698bb3
ParanoidAndroid19/Common-Patterns_Grokking-the-Coding-Interview
/3. Fast & Slow Pointers/2_Find Start of Cycle (medium).py
1,174
3.703125
4
class Node: def __init__(self, data, next=None): self.data = data self.next = next def checkCycle(link): slow = link fast = link while fast != None and fast.next != None: fast = fast.next.next slow = slow.next if(fast == slow): ...
6c2fb8422a8737fd920af0eb4ff441b140e194aa
99YuraniPalacios/scientific-computing-hw-
/Waring.py
984
3.8125
4
# Jun/09/2016 # Yurani Melisa Palacios Palacios # La conjetura de Warin: cada numero entero impar exceding 3 es cither un numero primo o la suma de tres numeros primos # Escribir una funcion que dado un numero entero positivo mayor que 3 decide si la conjetura de Waring es cierto. # Debe devolver el numero si es pri...
64357e28f4a78e95932b41791afebf6bcfeea36d
mumarkhan999/python_practice_files
/Lists/15_a_use_buil_in_instead_of_complex_comprehensions.py
633
4.71875
5
matrix = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12] ] print(matrix) # * is to for unpacking arguments list # it is to tell that # don't take matrix as a single positional arugment # rather take it as # [1, 2, 3, 4] ---- first argument # [5, 6, 7, 8] ---- second argument # [9, 10, 11, 12] ---- third...
2ae461c9881d56a2eef93b5b7270b7ecea2d9cb1
Xyleff2049/hexagone
/Objects.py
2,553
3.640625
4
# { Objects } # class Tile: length = 0 # Number of objects tiles = [] # List of all objects tilesCoords = [] # List of coords of objects external = [] # List of external Tile def __init__(self, listSprite, posTile, external=False, selected=False, team="Neutral", occup=False): if extern...
5605bb7c5c7609f800efdc4425956d470361b04d
rashmitallam/PythonPrograms
/strg1.py
276
4.15625
4
#WAP to accept 2 strings from user and swap their 1st two characters str1=input('Enter 1st string:') str2=input('Enter 2nd string:') #Slicing 1st 2 characters of both strings and swapping their positions str3= str2[:2]+str1[2:]+' '+str1[:2]+str2[2:] print(str3)
68ec1d13982f68a3d0a917cccc16961bcd89e843
arislam0/Python
/Anusur Islam Py file/p64.py
146
4.09375
4
import re #pattern = r"ice(-)?cream" pattern = r"a{1,3}$" if re.match(pattern,"aaaa"): print("Matched") else: print("Not Matched")
c5ac022094f80eeda111f4dc3143d8511713f1fd
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_3_neat/16_0_3_vk_eipi_C-coinjam.py
1,268
3.53125
4
#!/usr/bin/python import random import sys import math # Sieve MAX = 100000 primes = [] #divisor = [1 for i in xrange(MAX)] is_prime = [True for i in xrange(MAX)] is_prime[0] = False is_prime[1] = False for p in xrange(2, MAX): if is_prime[p]: primes.append(p) for multiple in xrange(p*p, MAX, p): # divi...
79d50c5d7a5916bdb265a6d7305023b57de943cf
encukou/gillcup
/gillcup/expressions.py
43,048
4.34375
4
"""Dynamic numeric value primitives This module makes it possible to define arithmetic expressions that are evaluated at run-time. For example, given an Expression ``x``, the Expression ``x * 2`` will always evaulate to twice the value of ``x``. The power of Expressions becomes apparent when we mention that :class:`~...
aa73b42a0e92709a37e92e6fd691a267a62245a9
AjithPanneerselvam/Algo-Problems
/firecode/powerOf4.py
776
3.984375
4
""" Google Power of 4 Write a method to determine whether a given integer (zero or positive number) is a power of 4 without using the multiply or divide operator. If it is, return True, else return False. Examples: is_power_of_four(5) ==> False is_power_of_four(16) ==> True Hint: An integer is considered to be a po...
5fc5ed482ac72484804cb1611adc2254cfa49140
ubuntu-prasad/myPython
/pythonStudy/assignments/as4_empSalary.py
269
3.65625
4
# WAP to get the basic salary from employee and calculate it gross salary (Basic salary + 10% DA and 12%TA) basicSalary = input("Enter Basic Salary: ") grossSalary = basicSalary + 0.1 * basicSalary + 0.12 * basicSalary print "Gross Salary of Employee: ", grossSalary
067860a7b88eb6654c342a35fbbce04e5413edf8
yukaixue/spyder
/汉诺塔游戏.py
397
3.828125
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 13 15:07:57 2020 @author: Administrator """ count = 0 def hanoi(n,src,dst,mid): global count if n == 1: print('{}:{}->{}'.format(1,src,dst)) count +=1 else: hanoi(n-1,src,mid,dst) print('{}:{}->{}'.format(n,src,dst)) cou...
334043e5b75ce0d220b594983c05714db2b07f81
chavhanpunamchand/pythonYogeshSir
/Weekend/weekend_30-08-2020/weekend/variables.py
8,907
3.640625
4
name = "Python" version = 3.8 val1 = "This is {} lang and version is {}".format(name,version) # position val2 = "This is {1} lang and version is {0}".format(version,name) #index val3 = "This is {nm} lang and version is {vr}".format(nm=name,vr=version) #name val4 = f"This is {name} lang and version is {version}" #f...
1cda37636512c3fe865e055c83cddbeba573bd09
reshmaladi/Python
/1.Class/Language_Python-master/Language_Python-master/LC8_HW6_CheckArmstrongNumber.py
275
3.875
4
def sum(n,s): if n==0: return 0 else: s=(n%10)**3+sum(int(n/10),s) return s def main(): n=eval(input("Enter Digit\t")) s=sum(n,0) if(n==s): print(n,"Is an armstrong number") else: print(n,"is not an armstrong number") if __name__=='__main__': main()
0caf83d41a07b95a510d62a236ce1d401ebcddf6
Byliguel/python1-exo7
/code/vie/vie_code_3_2.py
1,004
3.609375
4
def evolution(tab): """ Calcule l'évolution en un jour Entrée : un tableau à deux dimension Sortie : un tableau à deux dimension """ nouv_tab = [[0 for j in range(p)] for i in range(n)] for j in range(p): for i in range(n): # Cellule vivante ou pas ? if tab[i][j...
746481dc27ac58fee99a0dcc15c0ad65c3256d00
yeshengwei/PythonLearning
/04函数学习/08-函数嵌套调用应用-计算.py
203
3.984375
4
def sum_num(x, y, z): return x + y + z # result=sum_num(3,5,6) def average_num(x, y, z): result = sum_num(x, y, z) return result / 3 average = average_num(4, 9, 5) print(int(average))
f24e247ea3dead367e47c4081fec0840319ed2d9
phulei/chirico
/python/curses1.py
1,100
4.1875
4
#!/usr/bin/env python # Ref: http://www.amk.ca/python/howto/curses/ import curses,time stdscr = curses.initscr() curses.start_color() curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE) curses.noecho() stdscr.keypad(1) x=20;y=7 h=5;w=40 win=curses.newwin(h,w,y,x) stdscr.addstr(0,0,"Current mode: Typing mode", cu...
9234239d2500bcbd51ba113521ac8d308df4bc03
hoangperry/Tree-Visualization
/BST_AVL.py
17,823
3.9375
4
import datetime class Node: def __init__(self, key, size:int): self.key = key self.size = size self.left = None self.right = None class Node1: def __init__(self, key, size:int, height:int): self.key = key self.size = size self.height = height self.left = None self.right = None class BST: def __i...
b1296a208db9ad413e4d7a2be1bc6d43738d05d3
MrLotU/AdventOfCode2020
/solutions/sixteen.py
2,384
3.53125
4
import re import functools TEST_INPUT = '''departure class: 0-1 or 4-19 row: 0-5 or 8-19 departure seat: 0-13 or 16-19 your ticket: 11,12,13 nearby tickets: 3,9,18 15,1,5 5,14,9''' PATTERN = r'(?P<rules>(?:[a-z ]+: \d+-\d+ or \d+-\d+\n?)+)\n{2}your ticket:\n(?P<ticket>(?:\d+,?)+)\n+nearby tickets:\n(?P<other_ticke...
be6ef2887148d826c5bd45ccbdae7204cbb4bf5f
ookun1415/guess-number
/number.py
618
3.859375
4
import random #import載入 random 模組-隨機 start = input('請輸入隨機數字範圍開始值') end = input('請輸入隨機數字範圍結束值') start = int(start) end = int(end) r = random.randint(start,end) #randint 隨機整數(random+int) r = int(r) count = 0 #count 計數 while True: count += 1 #count = count + 1的快寫法 num = input('請猜數字') num = int(num) if num == r: prin...
f71dacc1e69c7775907d6718b48d27a8efe2b751
Chaitanya-Raj/Semester6
/DataMining/ControlStructures/1/sum.py
240
3.859375
4
def sumofdigits(n): sum = 0 while n != 0: sum += n % 10 n = n // 10 print(sum) def startingPoint(): val = int(input("Enter Number : ")) sumofdigits(val) if __name__ == "__main__": startingPoint()
c461936e2c9f99c4f80a3ae2e1f93a86c1e2e365
LogicalFish/DiscordBot
/python/modules/dice/godroll.py
2,261
3.6875
4
import random from config import configuration from .standard_diceroller import StandardDiceRoller class GodRoller(StandardDiceRoller): def dice_result_to_string(self, dice_results): result_response = "" if len(dice_results) < configuration['dice']['dice_softcap']: for result in dice...
55db89b8638149590ed2c0e4f6654131be5a3d78
maxmoro/matrices_decision_making
/DecisionMakingWithMatrices.py
7,286
3.828125
4
# Decision making with Matrices # This is a pretty simple assingment. You will do something you do everyday, but today it will be with matrix manipulations. # The problem is: you and your work firends are trying to decide where to go for lunch. You have to pick a resturant thats best for everyone. Then you should de...
e3d5fd7f8d28171309155f9d5a6f0bb2a37d2f59
happycupofjava/Data-Mining
/data_mining_p1.py
13,670
3.75
4
import numpy as np import sys import matplotlib.pyplot as plt from sklearn import svm ''' File Name TEMP_FILE_NAME is used to store the pickdataclass output and splitData2TestTrain as Input. ''' TEMP_FILE_NAME = 'test.out' ''' Converts the string passed to corresponding integers using ASCII values. ASC...
9f93ca4542f88dff119a1531732b4fe5af9ca344
chetanpv/python_learn
/4_functions.py
3,849
3.859375
4
# ---------------------------------------------------------------------------------------- # Function call without return value # ---------------------------------------------------------------------------------------- def a(name): print "hello", name # hello Chetan # when you use , operator a default space is giv...
a54899924fa7c8bf7f61253d9184d4d31c0eef3f
maher-mouelhi/backup
/project_one/myexercice.py
647
3.828125
4
#input data family 1 and 2 familiesList = [] PersonneDictionary = {"name":'',"age":0} PersoneList = [] for i in range(2): fam = input("data family plz give name ") pere = input(" plz give name pere ") pereAge = input(" plz give age pere ") PersonneDictionary["name"]= pere PersonneDictionary["ag...
1f75dcecf445d0edd97e84e2ef944ff08a52661d
raaffaaeel/github-course
/usp_python.py
1,252
4.25
4
print('Eu serei expert em python') 10 type(10) <class 'int'> type("tudo bem") <class 'str'> 5 / 2 <2.5> type(5 / 2) <float> 10 // 3 <3> 10 % 3 <1> # colocqndo 2 variaveis # peso = 78 altura = 1.83 print (peso) print (altura) # buscando o indice de massa corporal, peso / altura elevado ao quadrado # IMC = peso ...
7333865760e217ab5cafb17c63884852d80cfee0
Competitive-Programmers-Community/LeetCode
/492. Construct the Rectangle/main.py
272
3.546875
4
class Solution: def constructRectangle(self, area): """ :type area: int :rtype: List[int] """ W = int(math.sqrt(area)) for w in range(W, 0, -1): if area%w == 0: return [area//w , w]
bb978ee5cb0408e8ef673e531bb5232c8b18a999
yoon50/ds-algorithms
/tree/print_reverse_level_order.py
999
4.0625
4
from node import Node def print_reverse_level_order(root): """ Put in the right child followed by the left child of the recently popped parent. Place parent in the stack. Once we have processed all the nodes, then we will pop each element from the stack and print the data. """ if root is ...
38fd3c77094e41fe7352738069ed697e2a2555c2
ajitnak/py_pgms_heap
/kth_smallest.py
1,199
3.640625
4
def smallest(list, k): return kth_smallest(list, 0, len(list) - 1, k-1) def kth_smallest(arr, low, high, k): # If k is smaller than number of # elements in array if (k >= 0 and k <= high - low ): pos = partition(arr, low, high) #print pos, low,k if pos - low == k: ...
f46691b8d9b02993bc536efcec3b5ababf9cf2d0
sf-playground/hack-usability
/research/languages/python.py
475
3.640625
4
def f(x): return (x % 3 == 0) or (x %% 5 == 0) filter(f, range(2, 25)) # [3, 5, 6, 9, 10, 12, 15, 18, 20, 21, 24] # -------------------------------- def cube(x): return x ** 3 map(cube, range(1, 11)) # [1, 8, 27, 64, 125, 216, 343, 512, 729, 1000] # -------------------------------- seq = range(8) def add(x, y): ret...
aed9fbc08f9669ff5f5dd4d3b58ffe7303183646
isidorogu/Intro-to-Programming
/PS_2/calculator.py
322
3.75
4
value = input("Home Value: ") down = input("Down Payment: ") p = input("Term (in years): ") i = input("Annual Int Rate: ") value = float(value) down = float(down) p = float(p) i = float(i) l = value - down p = p*12 i = i/100 import mortgage a = mortgage.mortgage_pymnt(l, p, i) print('Your payment is', round(a, 2)...
45abb1998d003274803b40881f00a7839704c60a
aliakseik1993/skillbox_python_basic
/module1_13/module2_hw/task_5.py
1,066
4.21875
4
print('Задача 5. Вход в систему') # Что нужно сделать # Исправьте программу и допишите необходимые команды для получения нужного результата. # Будьте внимательны при исправлении и помните о правилах названия переменных. # Программа: first_name = input('Введите имя пользователя: ') greeting = 'Привет' print(greeting,...
d92f38987702a22918faefd9d909765d62984faa
zhzeshu/Algorithm-Problem-Solutions
/Data Structure Implementations/UpTree.py
1,447
3.5
4
#!/usr/bin/env python3 class UpTree: def __init__(self): self.parent = dict(); self.size = dict() def __len__(self): return len(self.parent) def __getitem__(self, key): # "find" function if key not in self.parent: raise KeyError(str(key)) q = [key] while s...
90b2fb5cd10c6510892d918cef64ea27d6d30b89
aticomismana/turma51487
/logica/exercicios/4.listas/icaro_listas.py
2,219
4.21875
4
""" 1. Crie uma lista notas e, por meio de while, calcule a média: 7,8,8,7.5,8.5,9,10 2. Calcule a média com notas obtidas a partir do teclado que serão armazenadas em uma lista. 3. Crie um programa que ler cinco números, armazena-os em uma lista e depois solicita que o usuário escolha um número a mostrar. """ def l...
339422678c5c7ce5cc1557b81d7fade312f20816
DoctorSad/_Course
/Lesson_08/_2_dict_1_zip.py
1,751
4.15625
4
""" Создание словаря с помощью zip. zip(iter1, iter2) запаковывает элементы последовательностей iter1 и iter2 и возвращает объект zip из которого можно сделать словарь dict(zip(iter1, iter2)) * при не равном количестве элементов последовательностей, лишние ключи либо значения - игнорирую...
dd395eb40a4645720921a9279091c12a698aa3fb
Aasthaengg/IBMdataset
/Python_codes/p02939/s471464271.py
128
3.65625
4
S=input() pre="#" cur="" cnt=0 for s in S: cur+=s if pre!=cur: cnt+=1 pre=cur cur="" print(cnt)
f216c35de9fccf98a84cb33869eb1bb576c51c8a
Didred/MSI
/lab4/lab4.py
2,419
3.546875
4
import random import math import primes def exp(base, power, m): result = 1 for _ in range(power): result = (result * base) % m return result def get_p(): a = primes.a rand = random.randint(100, len(a)) return a[rand] def get_fact(p): fact = [] n = p - 1 for i in...
80f08beaef85afd213a59fb1b512a97fb4d38b7c
srcmarcelo/Python-Studies
/PythonTest/ex020.py
185
3.78125
4
people = {'name': 'Marcelo', 'gender': 'M', 'age': 17} print(people) print(people['name']) people['weight'] = 54 for k, v in people.items(): print(f'{k}: {v}') del people['weight']
485d649ba950fb42db98fc5f3c321d5b6fe1849a
ShawnWuzh/algorithms
/空格替换.py
1,562
3.9375
4
''' 请编写一个方法,将字符串中的空格全部替换为“%20”。假定该字符串有足够的空间存放新增的字符,并且知道字符串的真实长度(小于等于1000),同时保证字符串由大小写的英文字母组成。 给定一个string iniString 为原始的串,以及串的长度 int len, 返回替换后的string。 测试样例: "Mr John Smith”,13 返回:"Mr%20John%20Smith" ”Hello World”,12 返回:”Hello%20%20World” ''' # written by HighW ''' 首先统计出空格的数目,然后算出最终字符串的长度,然后从字符串的最后面开始遍历,遇到非空格,就移动到新字符...
2717ae50c1c24c997dfe6df031265cf4e63e8a0b
treviza153/DailyCoding
/ListExercises/Test.py
394
3.515625
4
#!/usr/local/bin python3 import Main import unittest class TestList(unittest.TestCase): def testNumDivisible10(self): self.assertEqual(Main.numDivisible(10), [2,5], "Should be [2,5]") def testNumDivisible30(self): self.assertEqual(Main.numDivisible(30), [2, 3, 5, 6, 10, 15], "Should ...
e3a71eba44f4898bcc6f13d22a976719860310a9
Asky-M/dscnf-06
/scripts/01.basic/04.set.py
551
3.890625
4
s = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4} print(s) # length/size print(len(s), s) # add item to set s.add(4) s.add(5) print(s) # conversion from/to set ## list l = list(s) print(l) l = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] s = set(l) print(s) ## tuple t = tuple(s) print(t) t = (1, 2, 2, 3, 3, 3, 4, 4, 4, 4) s = set(t) print(s...
3b80bf8a4d1e9ead14896aeedb0dc2f7c67d8209
mario-alop/primeros_programas_python
/src/sumatorio.py
239
3.578125
4
sumatorio = 0 i = 1 while i <= 1000: sumatorio += 1 print(sumatorio) i += 1 print('Hecho') sumatorio1 = 0 contador = 0 while contador < 1000: contador += 1 sumatorio1 += contador print(sumatorio1) print(sumatorio1)
b682521c0358dd22beddaaed8fe60a975ed77284
n73274246/280201001
/lab10/example3.py
237
3.8125
4
def sum_of_nested(x): if not isinstance(x,list): return x else: sum_result = 0 for item in x: sum_result += sum_of_nested(item) return sum_result a_list = [3,12,76,[4,56,43],[2,8],81,75] print(sum_of_nested(a_list))
9e6f3b431f657b5ccc47ef940603f1235bac5686
analylx/learn
/temp2/re_way.py
350
3.609375
4
# coding=utf-8 import re r1= re.compile(r'way') with open('newfile.txt','r') as f: for a in f.readlines(): s = re.search(r1,a) #如果加了re.M|re.I就不能用预编译的pattern #如果没有匹配到那么b的值就是none,此时的b是没有group属性的。先判断b再取值 if s: print(a)
edf91b0c35168bca9ba9f32065fd14d7c835fc75
RajeshReddyG/PythonScripts
/SongDownloader.py
1,531
3.53125
4
''' Download any song Author : Sushaanth P Sample Input - 5 Kygo It Ain't Me Gryffin & Illenium ft. Daya - Feel Good Taylor Swift- We Are Never Ever Getting Back Together Alesso Years Adele- Rolling in the Deep ''' import urllib import urllib.request as urllib2 from bs4 import BeautifulSoup # import...
d9e709ab5825a0660f75cd1d8fffa9282f158e04
Aasthaengg/IBMdataset
/Python_codes/p02384/s044416712.py
1,963
3.546875
4
# 10_* class Dice: def __init__(self, label: list): self.top, self.front, self.right, self.left, self.back, self.bottom = label def roll(self, direction: str): if direction == "N": self.top, self.front, self.right, self.left, self.back, self.bottom = ( self.front, ...
b6e8e7c18f414837f95453b703638926bac936c9
Tuzosdaniel12/learningPython
/functions_basics/cart.py
303
3.71875
4
#packing def cal_total(*args): total = sum(args) print(args) cal_total(25,25,20,100) #unpacking def unpacking(): return 1,2,3 var1, var2, var3 = unpacking() print(var1) print(var2) print(var3) first, last = input('Enter your full name: \n').split(" ") print(first + " " + last)
6a5ffc2f7e603f0ae9309d3ad91cabc676fc42fc
gcoop-libre/ejemplos_cursosfp
/alumnos/facu_albarracin/adivinarnumeroCgcoop.py
943
3.875
4
#! -*- coding: utf8 -*- # Problemas con if, while, booleanos. import random # Problema 3. Adivinar número al azar print ("Bienvenido! Adivine un número en tres intentos!") numerodef= random.randint (1, 8) intentos= 3 intento= 0 # Sentencia break que rompe con la iteracion de un bucle! while...
cb34459def65311b65ea6cd00610b8086d7580dd
jtanwk/reddit-dailyprogrammer
/easy-challenges/45_e.py
1,639
3.953125
4
# Challenge 45, easy # https://www.reddit.com/r/dailyprogrammer/comments/sv6lw/4272012_challenge_45_easy/ # Sample grid # ---------------- # | |XXXX| | # | |XXXX| | # |XXXX| |XXXX| # |XXXX| |XXXX| # | |XXXX| | # | |xxxx| | # ---------------- # given dimensions, draws a row of x squares n...
1df6711edf5488e80960f7afa97cf347653ebd19
MiKueen/Data-Structures-and-Algorithms
/Leetcode/0051-0100/0092-reverse-linked-list.py
1,076
3.984375
4
''' Author : MiKueen Level : Medium Problem Statement : Reverse Linked List II Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: Input: 1->2->3->4->5->NULL, m = 2, n = 4 Output: 1->4->3->2->5->NULL ''' # Definition for singly-linked list. # class ListNode(objec...
e8c1cb0ed750040a5e13250c1e9f6cecb9584a35
nicolageorge/idiomaticpython
/presentation/3 0 multiple exit points.py
1,415
3.921875
4
# Distinguishing multiple exit points in loops # Donald Knuth came up with some structured equivalent # need flag variable to say if something is found or not found # the code could be returned/exited earlier when value is found, however this type of code is # usually a portion of a bigger functionality thus can't be...
3ff5eedf311417f583ed5276b24cdd477ede95ad
naghashzade/my-python-journey
/day2-AgeLeftcalculator.py
423
4
4
age = input("Insert your age: ") age_to_month = int(age) * 12 age_to_week = int(age) * 52 age_to_day = int(age) * 365 remain_year = 90 - int(age) remain_month = 90*12 - int(age_to_month) remain_week = 90*52 - int(age_to_week) remain_day = 90*365 - int(age_to_day) print(f"you will live {remain_year} years or {remain_mo...
780d5bdabee7f7fd3c91a7ff2929d5d3982a6d4e
krailis/hackerrank-solutions
/Algorithms/Warmup/time_conversion.py
383
3.65625
4
import sys def timeConversion(s): # Complete this function s = s.split(':') pm_am = s[-1][-2:] s[-1] = s[-1][:2] if (pm_am == 'AM'): if (s[0] == '12'): s[0] = '00' elif (pm_am == 'PM'): if (s[0] != '12'): s[0] = str(int(s[0]) + 12) return ':'.join(s) ...
ec6b4bc7b7245e37f6897694e70f623650d5d8fd
hafizadit/Muhammad-Hafiz-Aditya_I0320064_AbyanNaufal_Tugas6
/I0320064_Exercise6_8.py
126
3.78125
4
for i in range(2,17,3): # dari 2 sampai kurang dari 17 dengan inkremen 3 print("Kuadrat dari {} adalah {}".format(i,i**2))
cd4b5c8e599c1a72b87f416e973521ccd479f9ed
omarelhariry/Gotta-Catch-em-All
/PythonApplication2/PriorityW.py
598
3.671875
4
import queue; class PriorityW(queue.PriorityQueue): def __init__(self): queue.PriorityQueue.__init__(self) self.counter = 0 self.lower = 0 self.upper = 0 def put(self, item, priority): queue.PriorityQueue.put(self, (priority, self.counter, item)) self.counter +=...
0546fbd254448e88c3fd199fb7770e0b47959dc5
sikibuton/test_repo
/turtle_test.py
6,152
3.59375
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: koki # # Created: 27/08/2013 # Copyright: (c) koki 2013 # Licence: <your licence> #------------------------------------------------------------------------------- from...
99b1ccb16d97e508a03024f40758854082f085aa
yashwanth033/competitive_Programming
/competitive programming/Week1/Day4/FindInOrderedSet.py
452
3.9375
4
def binarySearch(arr, l, h, x): while l <= h: mid = l + (h - l) // 2; if arr[mid] == x: return True elif arr[mid] < x: l = mid + 1 else: h = mid - 1 return False def contains(ordered_list, number): result = binarySearch(ordered_list, 0, (l...
b5c62a8ea0c97b65c7d627db55130e131de55fb1
ASHWINIBAMBALE/snake_game
/snake.py
1,326
3.859375
4
from turtle import Turtle, position POSITIONS=[(0,0),(-20,0),(-40,0)] MOVE_FORWARD=20 UP=90 DOWN=270 RIGHT=0 LEFT=180 class Snake: def __init__(self) : self.snake_body=[] self.create_snake() self.head=self.snake_body[0] def create_snake(self): for position in POSIT...
6e21ea6274ab202bf9b139407b4b119346c1603f
Mi-clouds/py_practice
/write_create_files.py
758
4.625
5
# write to an existing file # to write an existing file, you must add a paramenter to the open() functions: # "a" - append - will append to the end of the file # "w" - write - will overwrite any existing comments # open the file and append the content to the file: f = open("../files/demo_text2.txt", "a") f.write("Now...
1cac639aea4f5146b3d9b85f01c1a90e55ab4a5f
vinceajcs/all-things-python
/algorithms/graph/dfs/topological_sort.py
557
3.75
4
"""Given a DAG, return a topological ordering of its nodes.""" def topological_sort(graph): visited = collections.defaultdict(bool) stack = [] for node in graph.keys(): if not visited[node]: dfs(graph, node, visited, stack) return stack # stack should contain the topological or...
3102d414a6ffbd3f4ee6b3a03be5334757570e29
feizei2008/nowcoder-huawei
/044.py
1,185
3.890625
4
# 检查这个数能不能填 def check(sudoku, i, j): cur = sudoku[i][j] for k in range(9): if k != i and sudoku[k][j] == cur: return False if k != j and sudoku[i][k] == cur: return False if (k//3 != i%3 or k%3 != j%3) and sudoku[i//3*3+k//3][j//3*3+k%3] == cur: return...
ace47dda6ea0352fde438d913e357c97f196fad6
asimoglufatih/gaih-students-repo-example
/Homeworks/HW3.py
654
4.09375
4
student = dict() listOfGrade = [] def getGrade(): for index in range(5): student[index] = {} midterm = int(input("Enter midterm grade: ")) project = int(input("Enter project grade: ")) final = int(input("Enter final grade: ")) listOfGrade.insert(index, calculatePassingGrade(...
d2cb61cb6f92243fa67a658a4af87addbd28c814
amiraHag/python-basic-course2
/database/database4.py
1,331
4.1875
4
# -------------------------------------------------------- # -- Databases => SQLite => Retrieve Data From Database -- # -------------------------------------------------------- # - fetchone => returns a single record or None if no more rows are available. # - fetchall => fetches all the rows of a query result. It retur...
901f42f0930c5a74c5671b6fdedf2e74591e0fd1
VisualAcademy/PythonNote
/PythonNote/32_Algorithms/12_GroupAlgorithm/GroupAlgorithm.py
1,765
3.625
4
#[?] 컬렉션 형태의 데이터를 특정 키 값으로 그룹화 # 그룹 알고리즘(Group Algorithm): 특정 키 값에 해당하는 그룹화된 합계 리스트 만들기 # 테스트용 레코드 클래스 class Record(): def __init__(self, name, quantity): self.name = name # 상품명 self.quantity = quantity # 수량 def main(): #[1] Input records = [ Record("RADIO", 3), Record("TV", 1), Record(...
896f385641c959390dc44fefcb6907709468bdea
david12d/projects
/Numbers/Fibonacci.py
596
4.40625
4
""" **Fibonacci Sequence** - Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number. """ import sys print("This program is a Fibonacci Sequence Generator.\n") while True: try: x = int(input("Enter a number: \n")) if x < 0: ...
080d28c6f1467abf777e76ac49a786b0e0055333
chrismvelez97/GuideToPython
/techniques/functions/built_in_functions/sum.py
478
4.15625
4
# How to use the sum() function ''' The sum() function adds all the numbers up from a list of numbers. Note that for min, max, and sum, you can only do them on lists full of numbers. also it is not a method attached to the number datatype which is why it is in the techniques folder instead o...
9aee4347b18e20e71991dd52682697d23724127f
barvaliyavishal/DataStructure
/Leetcode Problems/48. Rotate Image .py
520
3.5625
4
def rotate(matrix): n = len(matrix[0]) for i in range(n // 2 + n % 2): for j in range(n // 2): tmp = [0] * 4 row, col = i, j for k in range(4): tmp[k] = matrix[row][col] row, col = col, n - 1 - row for k in range(4): ...
04ff07eadbbb9ea1d581dd795c11457f3d5fc5e2
falecomlara/CursoEmVideo
/ex079.py
1,194
4.21875
4
# Digite varios valores numéricos e cadastre uma lista # caso o numero já existe, ele não irá cadastrar # mostrar todos os numeros em ordem crescente # Solução do curso: numeros = [] while True: n = int(input('Digite um valor: ')) if n not in numeros: numeros.append(n) print(f'Valor adicionado ...
959e4d74244a354022e8939345f03185dab566c2
SanJin1213/Python
/multiprocessing/code/pool_multiprocessing.py
740
3.53125
4
import multiprocessing as mp def job(x): return x * x def multicore(): # 不加参数,就是默认使用所有的核 # 要设置用几个核 用processes= pool = mp.Pool() res = pool.map(job, range(10)) res1 = pool.apply_async(job, (2,)) multi_res = [pool.apply_async(job, (i,)) for i in range(10)] # res2 = pool.apply_async(job...
602de06bff0a78969c81b114e42acbc81ab22328
Lisanity2019/Learning
/day6/封装.py
1,409
3.859375
4
# -*- coding: utf-8 -*- # ----> 封装:属性和方法都藏起来,不被外部访问 变量名或方法名左边添加双下划线 # 所有的私有属性或方法,不能被类外部访问 # class Person: # def __init__(self,name,passwold): # self.name=name # self.__passwold=passwold #----> 私有属性 # # def __get_pwd(self): #----> 私有方法 # print(self.__dict__) # return self.__pass...
ecbe968a88bf2811a54102d014cb6b4da11973f6
nucfive/Python
/ex5_dictionary.py
369
3.875
4
#dictionary 字典类型 {} my_phone = {"iphone" : 1000, "Sumsang" : 900} #取出键中的值 用[] iphone_price = my_phone["iphone"] print(iphone_price) #更改键值 my_phone["iphone"] = 4000 print(my_phone["iphone"]) print("Iphone price :" + str(my_phone["iphone"])) my_dic = {1 : "wrf1", 2 : "wrf2", 3 : "wrf3"} str1 = my_dic[1] my_phone.clear() ...
ef7f416952bce64499197ba24c63ab3690f186f1
SethDeVries/My-Project-Euler
/Python/Problem102.py
863
3.640625
4
#credit to jasonbhill for most of this code, placing this #here because my code did not work for reasons unbeknownst to me def num_divisors(n): # if n is divisible by 2 if (n % 2 == 0): n = n/2 divisors = 1 count = 0 while (n % 2 == 0): count += 1 n = n/2 divisors = divi...
dcc2cdb3f7159f80d6a48f0923696b8439a2537e
dhruvarora93/Algorithm-Questions
/Array Problems/prod_of_numbers_except_index.py
432
4.09375
4
def product(ar): product_of_numbers_before_index = [] product_of_numbers_before_index.append(1) product=1 for i in range(1,len(ar)): product *= ar[i-1] product_of_numbers_before_index.append(product) product=1 for i in range(len(ar)-1,-1,-1): product_of_numbers_before_in...
b848aec45bf58fa0c8a05c7a3cdfbc254f50f309
MaX-Lo/ProjectEuler
/010_summation_of_primes.py
842
3.890625
4
""" Task: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. """ import time def main(): start_time = time.time() limit = 2000000 # list containing for every number whether it has been marked already numbers = {} for x in range(3, limit, 2)...
8c35a32d6773be93f021a5f10a7e2cd536a8c3b8
NguyenHung2602/baikt
/bai4.py
418
3.90625
4
def Fibonacci(): n = int(input()) if n<2: print("Nhập lại n lớn hơn 2") n = int(input()) lst = [] for i in range(n): if i == 0: lst.append(i) elif i == 1: lst.append(i) else: lst.append(lst[i-1]+lst[i-2]) ...
d9b07428e020b201e237a48cab5da0a2e0d7d5dc
TheDurableDane/coding_pirates
/diceRoll.py
832
3.875
4
""" Dice roll -- Showing the law of large numbers: https://en.wikipedia.org/wiki/Law_of_large_numbers author: Thomas Lolk Schmidt email: thomaslolkschmidt@gmail.com date: 29jan2017 """ import numpy as np import matplotlib.pylab as plt # Get some random numbers np.random.seed(1) N = 10000 randomNumbers = np.random.r...
49a232a4893712d640d0ee136d8520c71de22c5c
fwr666/ai1810
/aid/day03/juzhon.py
239
3.515625
4
s1 = 'hello!' s2 = """i'm studing python!""" s3 = 'i like python! ' s4 = '+--------------------------+' n=len(s4)-2 s = print(s4) s = print('|'+s1.center(n)+'|') s = print('|'+s2.center(n)+'|') s = print('|'+s3.center(n)+'|') s = print(s4)