blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f3e15424cbabfa65909bb5ecd9be58598d976790
matheus-frota/GameRecommendationSystem
/gameRecommender/main.py
237
3.5
4
from knn import recommender, personalization def main(): k = int(input("How many games do you want to know? ")) gameName = input("Enter the name of your favorite game: ") personalization() recommender(k,gameName) main()
5d6c1a0fddce4304784f333e96e685069a49ad69
hollandm/cs441-majestic-eagle
/CEEBData/ceebScraper.py
2,318
3.9375
4
# # Description: This python file scrapes CEEB code data from the # website "sat.collegeboard.org # # Input: None. # # Output: A .csv file containing every high school's name and CEEB # number as reported by the SAT Collegeboard. # # Based on the data scraping tutorial provided in the book "Visualize # This" by Nathan ...
d31636b5246aa906e66d8e9a3cca1151102cd73f
shennyrs/bash
/python/class_objects/constructors.py
336
3.96875
4
#constructor is a class function that instantiates an object to predefined values #defined with a double underscore() it is __init__() method class user(): name=" " def __init__(self, name): self.name=name def sayhello(self): print("hello "+self.name) user1=user("alex") ...
2bff0411f32abb66898beebd7ec43965a1a6b301
nazninnahartumpa/python
/test2.py
747
3.921875
4
# x = "Hello world {}.format('inserted')" result = 100/777 print('The result is {r:1.3f}'.format(r=result)) print(5+7) #pring mod print(15%5) #printin 2 to the power 3 print(2**3) #print with new line print("Hello \n World") #string indexing var = "Hello World" print(var[0]) #print negetive indexing print(var[-3]) #s...
0c8113f49b5c8b55319996f2169268cd77a294a6
NAMRATHABATHULA/listtupledictionary
/listupledict.py
786
4.25
4
#1 inputting elements to an empty list list=[] n=int(input("enter number of elements of the list")) for i in range(0,n): a=int(input("enter the element")) list.append(a) list1=list print(list1) # addind an element in existing list,let the number be 67 list1.append(67) print(list1) # adding more than one ele...
602387f3423605bfb1e6a3255cc3701144bc5b20
ashokpal100/python_written_test
/python/number/arm_or_not.py
215
3.875
4
num=int(raw_input("enter any no: ")) number = int(num) orig = number rev = 0 while number > 0: rm=number%10 rev=rev+(rm*rm*rm) number=number/10 print rev if orig==rev: print "arm",rev else: print "not",rev
c595aa711930f30c03fd2561ff6b206d11b87ca2
spencerpeters/BackDoorExperiment
/src/TakataDSeparator.py
1,446
3.59375
4
import networkx from src.DSeparation import DSeparator LABEL = 'label' DETERMINED = 'determined' DESCENDANT = 'descendant' START_NODE = "DSeparatorStartNode" REACHABLE = 'reachable' __author__ = 'Spencer' class TakataDSeparator: # Note! This is for D-separation. So D-separation in the back-door graph gives ...
4db064549cb8ef865478ff942ecddaff29c66a8f
r2d2c3po/learntris
/imple1
1,166
3.515625
4
#!/usr/bin/env python #Joey Y. Ni import sys import pygame numClear=0 score=0 matrix=[['.' for x in xrange(10)] for e in xrange(22)] #global game board initialized with . def main(): pygame.init() while True: for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if eve...
2cad4a419625d7ab1802e25546a199c6f1203a95
cdr-caique/uri-online-judge
/python-3.8/1074.py
481
3.859375
4
n = int(input()) message = "" for i in range(n): x = int(input()) if(x==0): message += "NULL\n" elif(x%2 == 0): message += "EVEN " if(x > 0): message += "POSITIVE\n" else: message += "NEGATIVE\n" else: message += "ODD " ...
a26e34a725fcceeceb72891e1fc9c053955a493e
suacalis/VeriBilimiPython
/Ornek2_1.py
245
3.8125
4
''' Örnek 2.1: İki sayının toplamını hesaplayan basit matematiksel işlemi yapalım. ''' A = int (input("1.sayıyı gir:")) #hatalı kullanım: A = input("1.sayıyı gir:") B = int (input("2.sayıyı gir:")) T = A + B print ("Toplam= ", T)
303243ad222dcb575390d352f952e7eea2c15fbb
rickerje/web-caesar
/caesar.py
1,182
4.0625
4
import string def alphabet_position(letter): alphabet = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y...
a10a03597e16bfff920a0d72128630bb9fbd0435
gavarito/520_python_fundamentals
/fatorial.py
204
4.1875
4
#!/usr/bin/python3 def factorial(num): aux = 1 for x in range(1,num+1): aux *= x return aux # from math import factorial num = int(input('Digite o número: ')) print(factorial(num))
453310fee72d48acd9aa4b119213e95db19b7d5d
Badw0lf613/Data-Structure_2
/项目代码-1812055-姚施越/P2/Preprocess.py
2,337
3.546875
4
#文本预处理,做分词、清洗工作 #首先引入nltk以及re的模块,以便后续使用 from nltk.tokenize import sent_tokenize, word_tokenize from nltk.corpus import stopwords import re #python正则表达式 #后续做清洗时会用到 #主要对一些标点符号进行了分割 pattern = r'(\/\w+)|(\d+\-\S+)|(\[)|(\]\S+)|(\])|(\')|(\")|(\.)|(\,)|(\;)|(\!)|(\()|(\))|\$?\d+(\.\d+)?%?| \.\.\.| ([^A-Za-z0-9]\.)+ ' #在这里...
6caddf5e5e599b216c5edfd5a21a5811680b57ca
seanlab3/algorithms
/algorithms_practice/6.DP/9.DP_longest_increase.py
391
4.15625
4
""" Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. The time complexity is O(n^2). """ from algorithms.dp import longest_increasing_subseque...
c5f2ee7e7ec10a219cf4da141219284a963dea5a
Davidnet/Euler-Project-Python
/Problem11.py
776
3.84375
4
def nthtrianglenum(n): return (n * (n + 1)) / 2 def numberofdivisors(n): divisors = 1 count = 0 f = 2 while n % f == 0: count += 1 n /= f divisors *= (count + 1) f = 3 while f <= n: counter = 0 while n % f == 0: counter += 1 n /= ...
b4e4d1bb0b0fded67373f0662da1ed8a9b9eae82
MSuha/Codeforces_Problem_Set
/Python/Problem339A_HelpfulMaths.py
418
3.875
4
def main(): expression = input() length = len(expression) num1 = num2 = num3 = 0 while length > 0: if expression[length-1] == '1': num1 += 1 elif expression[length-1] == '2': num2 += 1 else: num3 += 1 length -= 2 result = num1 ...
b3b39d33e0a4c52473612d66c29f14fdcd63b553
singi2016cn/python-start-programming
/7/7.9/vacationland.py
286
3.625
4
# 梦想的度假胜地 vacationlands = [] active = True while active: vacationland = input('你梦想的度假胜地是哪里?\n') if vacationland == 'q': break vacationlands.append(vacationland) print('人们梦想的度假胜地有:\n') print(vacationlands)
2b1d5baf4024d283b587d975764592c23c6cc64c
NitishPuri/ud120-projects
/decision_tree/dt_author_id.py
1,472
3.75
4
#!/usr/bin/python """ This is the code to accompany the Lesson 3 (decision tree) mini-project. Use a Decision Tree to identify emails from the Enron corpus by author: Sara has label 0 Chris has label 1 """ import sys from time import time sys.path.append("../tools/") from email_preprocess im...
c2bb017b404c9dd2f4fb00978b2b23f22d72c5a6
ramin153/algebra-university
/q4.py
2,398
3.6875
4
import sys from pandas import * ''' M-> our matrix order to multiplication and vale is theirs size chain-> our array to save multiplication results help_chain-> help to track back n ← M.length − 1 for i ← 1 to n chain[i, i] ← 0 for size ← 2 to n ; size is length of chain for i ← 1 to n − size + 1 j ...
1cba709c555b7a58394de4e02a3619bb30d5e2fc
EricMa206/dsc-object-oriented-shopping-cart-lab-nyc-ds-career-042219
/shopping_cart.py
756
3.53125
4
class ShoppingCart: # write your code here import numpy as np def __init__(self, total=0, emp_discount=None, items={'name': [], 'price': []}): self.total = total self.employee_discount = emp_discount self.items = items def add_item(self, name, price, quantity=1...
15d828e752d90d673260ecc621b7a42660e24ce6
Nico34000/API_ong
/test_fonction.py
2,336
3.90625
4
import unittest from functions_panda import per_capi, average_year, latest_by_country class TestMethods(unittest.TestCase): def test_by_country(self): """This function test latest_by_country. With this function we testing the function latest_by country. We test several...
bcb011e22c3bf4df9e63449955837317e8001496
youyuebingchen/Algorithms
/paixusuanfa/selectsort.py
647
3.828125
4
# def SelectSort(alist): # n = len(alist) # for i in range(n-1): # min = i # for j in range(n-i): # if alist[min] > alist[i+j]: # min = i+j # alist[i],alist[min] = alist[min],alist[i] # return alist # a = [1, 5, 3, 2, 7, 4, 9] # b = SelectSort(a) # print(b...
87288e65557091ef27a264a7158554342d3b806e
Shari87/Python-Bootcamp
/Day-2/Day-2-2/BMI.py
273
4.28125
4
height = input("enter your height in m: ") weight = input("enter your weight in kg: ") # code below this line new_height = float(height) new_weight = int(weight) # formula to calculate the BMI BMI = new_weight / (new_height*new_height) # convert to integer print(int(BMI))
66e9f6540ea0f6d5e3a0f1793ee22cff00cb2de2
DOps12/Test_proj
/com_ele.py
174
3.609375
4
def common_ele(l,n): e = [] for i in l: if i in n: e.append(i) return e #Hello###### n = [1,2,3,4,5] l = [1,3,4,6] print(common_ele(l,n))
151ce8625340edacbd0b3713ee98bafa48db91eb
yize11/1808
/17day/06-a+=a和a=a+a的不一样.py
333
4.09375
4
def test(a): a+=a print(a)#[1,1] x = [1] test(x) print(x)#[1,1] def test1(a): a=a+a#先算等号右边,然后把值赋值一个新的变量来指向 print(a)#[1,1] x = [1] test1(x) print(x)#[1] ''' def test2(a): a+=a print(a)#[1,1] 如果可变类型数据,是指a指向上的变量上修改 '''
444a32fc381b5cdd5860283f1dde45e3049fd217
enterpriseih/data-structure-algorithms
/P0/P0/Task1.py
880
4.0625
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 1: How many different telephone nu...
5619ff192fd0e03945cafa54505ead95f3f79794
pytorch-ts/pytorch-ts
/lstm/model.py
1,226
3.53125
4
"""Pytorch lstm """ import torch import torch.nn as nn class LSTM(nn.Module): """ lstm """ def __init__(self, cov_dim, hidden_dim, batch_first=True, output_dim=1, num_layers=2, dropout=0.): super(LSTM, self).__init__() self.cov_dim = cov_dim self.hidden_dim = ...
9542507cd41d2b317fd4539eace498bf765bfaba
Abhishek-IOT/Data_Structures
/DATA_STRUCTURES/Stacks&Queues/StackPermutations.py
767
3.71875
4
from queue import Queue def stackPermutation(inp,out,n): input=Queue() output=Queue() for i in range(n): input.put(inp[i]) for i in range(n): output.put(out[i]) temp=[] while(not input.empty()): ele=input.queue[0] input.get() if ele==output.que...
f713f4d2ae3bf224c8afe5b8308024a539581575
wnj00524/CodeAcademy_proj1
/main.py
1,427
3.734375
4
class room(): def __init__(self, name, description, exits): self.name = name self.description = description self.exits = exits def __repr__(self): seen_exits = "" for exit in self.exits: seen_exits = seen_exits + exit + "\n" if seen_exits == "": ...
64404f90301457af47593624ec70395f99871bb8
Gurdeep123singh/mca_python
/python/practice python/fact_without_recursion.py
1,397
4.09375
4
''' program to find factorial from 1 to given no and from n to 1 using without recursion used only 2 function and without returning i/p -> 6 o/p-> 1 ! is : 1 2 ! is : 2 3 ! is : 6 4 ! is : 24 5 ! is : 120 6 ! is : 720 reverse order of factorial is : 6 ! is : 720 5 ! is : 120 4 ! is : 24 3 ! is : 6 2 ! is ...
8d2945480e6036e83510b23fd4806d7303c3070f
carinatze/cscoffeechat_matching
/validate.py
381
3.5
4
def valid_filename(filename): """Check if filename is for a CSV file with no folder names.""" return not "/" in filename and filename.endswith(".csv") def duplicate_matches(past_matches, matches): matches_pairs = set( frozenset(s.email for s in students) for students in matches.items() ...
eba88be00144b950fe5ded43d38d593898c89ff8
Kunal352000/python_adv
/17_userDefinedFunction4.py
362
4.0625
4
""" mixing of default and non-default arguments """ def add(x=1,y): z=x+y print(z) add(2,2) """ we recive syntaxError becoz non default argumnets follows default arguments we can pass first as a non default and pass the second as default is true if we can pass first as a default and second one as ...
d3d540a659ff1160794f22a1a36faabe327f5579
Aditya11020/MusicPlayerInPython-tkinter-
/Python project/bg.py
542
3.515625
4
from tkinter import * from PIL import ImageTk master = Tk() #width, height = Image.open(image.png).size canvas = Canvas(master, width=900, height=563) canvas.pack() image = ImageTk.PhotoImage(file="image.png") canvas.create_image(0, 0, image=image, anchor=NW) canvas_id = canvas.create_text(10, 10,fill="white",anch...
8426694ae1a863761505271f336f99b570c59571
supperllx/LeetCode
/965.py
589
3.875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isUnivalTree(self, root: TreeNode) -> bool: if not root: return True else: l = se...
e658bdd1c6921872b0fa1743cf8f27efeefdfcfb
fzingithub/SwordRefers2Offer
/4_LEETCODE/1_DataStructure/3_Stack/单调栈/矩阵中的最大矩形.py
959
3.578125
4
class Solution: def largestRectangleArea(self, heights): if not heights: return 0 length = len(heights) minL = [-1] * length minR = [-1] * length Stack = [] # 单调递减栈 for i in range(length): while Stack and heights[i] <= heights[Stack[-1]]: ...
ea7594aadcef5561f06cd51c3c1ae4b6d4dc3e0e
hariprabha92/anand_python-
/chapter2/problem17.py
604
4.5
4
''' Write a program reverse.py to print lines of a file in reverse order. $ cat she.txt She sells seashells on the seashore; The shells that she sells are seashells I'm sure. So if she sells seashells on the seashore, I'm sure that the shells are seashore shells. $ python reverse.py she.txt I'm sure that the shells ...
8779ac78ea86004e6b179240b4e79a63dff82b3c
Sitarweb/Python_study
/pythontutor_2/num_1.py
239
3.96875
4
#Даны два целых числа. Выведите значение наименьшего из них. a = int(input("введите число")) b = int(input("введите число")) if b > a: print(a) else: print(b)
563f68c333bb5bcfe8a84dfb5d657bbefe38ea5b
Sharukkhan777/Python
/general/Generators with example.py
1,825
4.59375
5
# Generators in python ''' Generators : * Definition: A generator-function is defined like a normal function, but whenever it needs to generate a value, it does so with the yield keyword rather than return. If the body of a def contains yield, the function automatically becom...
86ce2fa70be7b7dbb5274b90407610899ca89557
luhralive/python
/Jaccorot/0012/0012.py
646
3.796875
4
#!/usr/bin/python # coding=utf-8 """ 第 0012 题: 敏感词文本文件 filtered_words.txt,里面的内容 和 0011题一样, 当用户输入敏感词语,则用 星号 * 替换,例如当用户输入「北京是个好城市」,则变成「**是个好城市」。 """ def trans_to_words(): type_in = raw_input(">") with open('filtered_words.txt') as f: text = f.read().decode('utf-8').encode('gbk') print text.split("\...
27c4e879e277a5d3a344110aafa93dbab422aff2
viad00/code_olymp
/olymp2017/3.py
159
3.890625
4
def IsPrime(n): for i in range(2, n): if (n % i == 0) and (i!=1) and (i!=n): return False return True print(IsPrime(int(input())))
64736f36afefdadb43b374af179e512fffc650c6
Git-hSin/python-challenge
/PyBank/main.py
2,021
3.640625
4
import os import csv import pandas as pd import numpy as np from pathlib import Path file = Path('C:/Users/hahma/OneDrive/Desktop/PythonData/USCLOS201811DATA3/03_python/homework/Instructions/PyBank/Resources/budget_data.csv') df_pd = pd.read_csv(file) Total_Months = df_pd["Date"].count() PLdiff = [] for i in range...
b9120dfc17cda4537ccac648dc63f950767bdcec
URTK/Lab-5
/Main.py
701
3.859375
4
import math masX = [] masY = [] n = 1 # Массив X for i in range(3): # 19 print('Введите элемент массива', n) masX.append(int(input())) n += 1 print(' MasX ', masX) # Массив Y for i in range(3): y = 0,5 * math.log(masX[i]) masY.append(y) print(' MasY ', masY) # Поиск наибольшего ...
fb7726678dd568dc59501372739ae431648c32d6
nikhil2596/phy
/1.py
132
4.09375
4
a=input("enter the number:") if a>0: print"a is positive" elif a<0: print"a is negative" else: print "a is zero"
d31a5b0486c27ded4d68f162dddf7e340789b594
sidtsc/algoritmos
/coursera/dezenas.py
115
4.03125
4
n = int(input("Digite um número inteiro: ")) print(n) d = (n // 10) % 10 print("O dígito das dezenas é: %d" % d)
7df1141e7a4c136ac4329b4abc74bf4a10a135f9
amarmulyak/Python-Core-for-TA
/hw03/ashep/task5.py
265
4.09375
4
day_of_week = ['Monday','Tuesday','Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ] k = int(input("Enter number ")) if 0 < k <= 365: n = day_of_week[(k % 7)-1] print("The weekday is {}".format(n)) else: print("k should be between 1 and 365")
824c29f82c254155bd3356dadcbe9fc98590f78d
mourakf/Python-FDS-Dataquest
/Python II - Intermediate/Working with Dates and Times in Python-353.py
2,353
3.71875
4
## 1. Introduction ## from csv import reader potus_visitors_2015 = open('potus_visitors_2015.csv') read_potus_visitors_2015 = reader(potus_visitors_2015) list_potus_visitors_2015 = list(read_potus_visitors_2015) potus = list_potus_visitors_2015[1:] print(potus) ## 3. The Datetime Module ## import datetime as dt ## ...
b3b98595a6e4a25f115c0757846757a1241470b1
FMRodrigues97/Lista02-CES22
/Questão05.py
185
3.59375
4
class Point: def __init__(self, x=0, y=0): self.x = x self.y = y def reflect_x(self): return self.x, -self.y print(Point(3, 5).reflect_x())
e944e8d61a560098603ac2676a1699a7c613523b
nnonnoon/beta
/Python/word_chain.py
401
3.765625
4
len_word = int(input()); ro = int(input()); word = [] for i in range(ro): word.append(input()) def check_word(a, b): count = 0 for i in range(len_word): if a[i] != b[i]: count += 1 return True if count >= 3 else False for i in range(ro): if i < ro - 2: if check_word(word[i], word[i+1])...
d2ae3077e65b45be20704d1e0de5915cff234c19
pcaa3000/Python_code
/reloj.py
344
3.71875
4
ms = 0 s = 0 min = 0 hr = 24 while hr < 24: while min < 60: while s < 60: while ms < 1000: print(f'{hr} hr : {min} min : {s} s : {ms} ms') ms += 1 s += 1 ms = 0 min += 1 s = 0 hr += 1 min = 0 print(f'{hr} hr : {min}...
4a473785c2f34f76eca6875de6b7c1c460d31d71
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/mggdac001/question1.py
279
4.15625
4
#Rect angle def rectangle(): y=eval(input('Enter the height of the rectangle:\n')) l=eval(input('Enter the width of the rectangle:\n')) x=y-1 while x<y: x+=1 #print('*'*x,end='') print(('*'*l+'\n')*x) rectangle()
0d167e02d7e6fc108c9d5c07cf1124bf5f657aaf
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4432/codes/1721_3067.py
397
3.984375
4
a=input("ataque espada ou cauda ") b=int(input("numero ")) c=int(input("nu ")) d=int(input("dfsdfg ")) e=int(input("fdfgd ")) if(a=="CAUDA")or(a=="ESPADA"): if(b<=0)or(b>=7)or(c<=0)or(c>=7)or(d<=0)or(d>=7)or(e<=0)or(e>=7): print("Entrada invalida") elif(a=="CAUDA"): z=(b+c+d)*e print(z) elif(a=="ESPADA")...
b4ae7c03b928a0090221cb219208f78a5689ee51
qader1/pathfind-and-sort-visualizer
/interface.py
8,060
3.5
4
import tkinter as tk from tkinter import ttk from list_visualizer import * from maze import * import dbs def v_sort(): # according to the selected item in the listbox, speed, and size, it run the visualize function. if lst_sort.curselection()[0] == 0: data = visualize_sort(list_size.get(), v...
d60314cced05376d396a9e63a89f01784d7ed480
sohn0356-git/TIL
/PyStudy/day06/p305.py
1,325
3.625
4
f = open("live.txt", "wt", encoding='UTF-8') f.write("""God will make a way Where there seems to be no way He works in ways we cannot see He will make a way for me He will be my guide Hold me closely to his side With love & strength for each new day He will make a way He will make a way God will make a way Where there ...
9c531073982a38ee4f619ccea7e5c5729923864a
plilja/project-euler
/problem_32/pandigit.py
484
3.515625
4
from math import sqrt from common.functions import is_pandigital def pandigital_products(): res = set() for product in range(1, int(sqrt(123456789))): for multiplicand in range(2, int(sqrt(product))): if product % multiplicand == 0: pandigital_candidate = int(str(product) ...
ded2b1c097117385a34e4f9db7cc455810c1ce07
odair-pedroso/Nanodegree-Python
/amigo.py
195
3.609375
4
def is_friend(name): if name[0]=="D": return True if name[0]=="N": return True else: return False print is_friend("Damara") print is_friend("Odair")
9e1687562b2d67b36f48fc5170045f84748393dd
ziyaad18/LibariesPython
/dropdown.py
229
3.609375
4
from tkinter import * OPTIONS = [ "Jan", "Feb", "Mar" ] #etc Window = Tk() variable = StringVar(Window) variable.set(OPTIONS[0]) # default value w = OptionMenu(Window, variable, *OPTIONS) w.grid(row=1, column=3) mainloop()
bc4ade117fd8017f2ead0adac5ffb0c7e2c479ce
giftnadia/Age-Calculator
/hello.py
270
4.25
4
year_of_birth=int(input("year_of_birth")) def age_calc(yearofbirth): age=(2019-year_of_birth) if age < 18 : print("your are a minor") elif age < 35 : print("you are a youth") else : print("you are an elder") age_calc(year_of_birth)
c51a770a9182d9dba58002659549bc4a1d589cc7
yaochie/AdventOfCode2019
/6.py
1,994
3.5625
4
class Node: def __init__(self, name): self.name = name self.children = set() self.parent = None def add_child(self, child): # child should also be a node assert isinstance(child, Node) self.children.add(child) assert child.parent is None or chil...
5966f2ca4298ae1514e8cd061615fc8661d17aed
kylejava/InterviewPractice
/merge.py
619
3.984375
4
def mergesort(data): if(len(data) == 0 or len(data) == 1): return data mid = len(data) // 2 a = data[:mid] b = data[mid:] a = mergesort(a) b = mergesort(b) return merge(a, b) def merge(a, b): c = [] while(len(a) != 0 and len(b) != 0): if(a[0] > b[0] ): ...
01240ebbeac9cd0dd912097c8249ca7c6654b73f
janedallaway/ThinkStats
/Chapter2/pumpkin.py
1,975
4.25
4
import thinkstats import math '''ThinkStats chapter 2 exercise 1 http://greenteapress.com/thinkstats/html/thinkstats003.html This is a bit of an overkill solution for the exercise, but as I'm using it as an opportunity to learn python it seemed to make sense''' class Pumpkin(): def __init__ (self, ty...
be198122a49dcbc18eaefc8a501a18fc76c54cdd
KondakovY/Python
/Lesson2/Task2.py
658
4.3125
4
""" 2. Для списка реализовать обмен значений соседних элементов, т.е. Значениями обмениваются элементы с индексами 0 и 1, 2 и 3 и т.д. При нечетном количестве элементов последний сохранить на своем месте. Для заполнения списка элементов необходимо использовать функцию input(). """ list = input('Значение через пробел: '...
1d32952c8bdc4fdbcffa5a37cbaf9181ff35cdb6
jajatisahoo/PythonProgram123
/DailyProgram/loop.py
170
3.96875
4
print("hello world") i = 1; while (i <= 2): print("value of i is" + str(i)); i = i + 1 # j =input("enter a string") name="jajati" length=len(name) print(length)
8322d1f4ca5d1365720fa9bc36dac86bdcd67929
alex2018hillel/Hillel2020Python
/Lesson_2/Task_6.py
305
3.984375
4
import re str = "English = 78 Science = 83 Math = 68 History = 65" def sum_num(str): """Return sum all numbers in string""" regex_num = re.compile('\d+') numbers_string = regex_num.findall(str) numbers = [int(elem) for elem in numbers_string] return sum(numbers) print(sum_num(str))
5cff738f71bed1e7b605dc20cc1dbfe9865579ce
jeongwoohong/iot_python2019
/01_Jump_to_python/3_control/3_for/5_144.py
248
3.8125
4
#coding: cp949 #step1] ̽ ⺻ a=[1,2,3,4] result=[] for num in a: result.append(num*3) print(result) a=[1,2,3,4] result = [num *3 for num in a] print(result) a=[1,2,3,4] result=[num *3 for num in a if num%2==0] print(result)
7061c403eb80a27bfa101d8eaef35a258f470334
rtullybarr/battlesnake-python
/app/collisions.py
3,629
3.546875
4
from app.movement import UP, DOWN, LEFT, RIGHT, points_equal, move_point, move_towards, distance # set of weighting fuctions designed to help us avoid collisions. def avoid_walls(data, weight): criteria = {"goal": "avoid_walls", "weight": weight} # walls: places with x, y outside the game area # where we...
de9dea6f907835b05912b49feb664be1b0ac1d16
castilhos90124/E-PRIME-Converter
/DataTools_2.0.py
407
3.515625
4
import os error = True choice = 0 while error: error = False print("Que tipo de arquivo sera inserido ?") print("1: Os do Pedro") print("2: IAPS / Attractfaces") choice = input() if choice == "1": import parte1 import parte2 elif choice == "2": import Main...
a6f7c25d852c431f22641cc9a4ea54e32b00e29e
p4t0p/codewars
/chess_exercise.py
1,479
3.515625
4
from chess.main import start as StartGame from chess.helpers import inverse, compare, get_range, to_x_cord, from_x_cord def pawn(game, from_i, to_i, from_j, to_j): color = game.queue is_straight = from_j == to_j move_to_fig = game.find(to_i, to_j) max_move = 1 if (color is 'black' and from_i == 2)...
c11d343a9d2cc62bfe2e401a1bcf568638a6e86e
coltynw/Sprint-Challenge--Data-Structures-Python
/ring_buffer/ring_buffer.py
841
3.734375
4
class RingBuffer: def __init__(self, capacity): #where it the iterating position is self.current = 0 #the array self.store = [] #the max number of things in the array self.capacity = capacity def append(self, item): #check if the length of the array is...
b7cba9ec47ec9a03d7478a4de7a68f29c2a12014
giridhersadineni/pythonexamples
/fibonnaci.py
212
3.625
4
import sys def cube(n): #generator function if(n<0): return yield n*n*n c = cube(9) while True: try: print (next(c), end=" ") except StopIteration: sys.exit()
ac562896435c8d41ef57f2dad1a9ef240e68ec72
busuka/Python_src
/Checkio/★digits-multiplication.py
850
3.65625
4
import itertools def checkio1(number): v = list(str(number)) mv = list(map(lambda x: x.replace('0', '1'), v)) # => ['1','2','3','4','1','5'] nv = list(map(int, mv)) pdt = 1 for i in nv: pdt = pdt * i return pdt def checkio(number): number_list = [x for x in map(int, list(str(num...
8129fc331e458127c84d8faece4cf0cd2452507c
ksturm/python-challenge
/pypoll_nopandas_trial.py
1,941
3.796875
4
#GROFIT # Import Libraries import os import csv # Init Variables/Lists num_votes = 0 candidates = [] vote_counts = [] # Define Path poll_data = "Resources/election_data.csv" poll_path = os.path.join(poll_data) #Open File with open(poll_path, newline="") as csvfile: csvreader = csv.reader(csvfile) #Skip He...
991bf9f915f370cc1cb7a467b3fb7273b926d406
YanHengGo/python
/19/lesson.py
339
3.859375
4
def discounts(price,rate): final_price=price*rate old_price=50 print('in function old_price : ',old_price) return final_price old_price=float(input('please enter a price :')) rate=float(input('please enter a rate :')) new_price=discounts(old_price,rate) print('global old_price:',old_price) print('disco...
080341b9ac0f1d109c9c1f7de120adfc989e216e
mepragati/100_days_of_Python
/Day 001/BandNameGenerator.py
251
4.1875
4
#Band Name Generator Program print("Welcome to the Band Name Generator !!") name=input("What is the name of the city you grew up in?\n") pet=input("What is the name of the first pet you owned?\n") print("The name of your Band could be: "+name+" "+pet)
a7eb8027dd3973f991318dc08847dec1a43f322e
Devanosh/python-projects
/list comprehension.py
159
4.0625
4
# odd=[] # for x in range(3,60): # if(x%3==0): # x+=8 # odd.append(x) # print(odd) a=[x+8 for x in range(3,60) if x%3==0] print(a)
93d9b612bb2a7a93efa7612fbe6f199eb1af4d0e
seddon-software/python3
/Python3/src/_Exercises/src/Pandas/07_additional_column.py
560
3.796875
4
''' Use Pandas to read the file "../MiniProject/wtk_site_metadata.csv" Create the same dataframe 'Rhode Island' as in the previous exercise. Now add an extra column called 'power' that is computed as the product of the columns 'capacity_factor' and 'wind_speed'. ''' import pandas as pd pd.set_option('display.precisio...
08e34bbdeeed4761a8bd0b85875e8ac64ff7875e
marcelofreire1988/python-para-zumbis-resolucao
/Lista 1/questão03.py
377
3.921875
4
#Escreva um programa que leia a quantidade de dias, horas, minutos e segundos do usuário. Calcule o total em segundos. dias = int(input("insira um dia: " )) horas = int(input("insira as horas: ")) minutos = int(input("insira os minutos: ")) segundos = float(input("insira os segundos: ")) total = dias * 24 * 60 * 60 +...
a8bb4b1590e9ea71d7589b68283b8b7155adf26f
SuchismitaDhal/Solutions-dailyInterviewPro
/2020/08-August/08.02.py
1,144
3.828125
4
# AMAZON """ SOLVED -- LEETCODE#340 You are given a string s, and an integer k. Return the length of the longest substring in s that contains at most k distinct characters. For instance, given the string: aabcdefff and k = 3, then the longest substring with 3 distinct characters would be ...
1f5af626290f012084e1aafe8e86a1a629835726
antomin/GB_Algorithms
/lesson_2/task_2_3.py
463
4.3125
4
""" Сформировать из введенного числа обратное по порядку входящих в него цифр и вывести на экран. Например, если введено число 3486, то надо вывести число 6843. """ def revers_func(num): res = 0 while num > 0: res = res * 10 + num % 10 num = num // 10 return res print(revers_func(nt(inpu...
e19cc8244e1db0c143ebd921995f1cedbb99a85c
thebillington/menu_pyg
/menu_pyg/menus.py
1,328
4.09375
4
#Class that implements the most basic menu class Menu(object): def __init__(self, screen, x, y, width, height, font, aa, colour): #Store the screen self.screen = screen #Setup a list of menu items self.menu_items = [] #Setup a list to store the renders self.item_r...
4b099712f20c917a1e17b58b53e671d49224dd8a
Alamin-H-M/photon_theory
/photon_theory.py
622
4.28125
4
# what is the angular momentum of an electron in 3rd shell? if the radius of the shell 3.6 * (10**-8)cm , determine the velocity of the shell. [mass of an electron = 9.11 * (10**-28 g)] ''' here, shell no., n = 3 plunk constant, h = 6.626 * (10**-34) Js constant, pi = 22/7 mass of electron, m = 9.11 * (10...
261d8a1cca6b0e39e5d5535c5a9204b44d207178
hussainMansoor876/Python-Work
/practice/.idea/practice 9.py
658
3.65625
4
from collections import defaultdict import json # numbers = [2, 3, 5, 7, 11, 13,15,17] # filename = 'numbers.json' # with open(filename,'r+') as f_obj: # data=json.dump(numbers,f_obj) # data1=json.load(f_obj) # print(data1) # print(data[0]) # username = input("What is your name? ") username = {'name': 'mans', '...
12a6321d1692888412cbf0fb4743490727938069
oggyoggy448/school_management_system_using_sqlite
/db_conn.py
1,321
4.1875
4
import sqlite3 from sqlite3 import Error def create_connection(db_file): """ create a database connection to the SQLite database specified by db_file :param db_file: database file :return: Connection object or None """ conn = None try: conn = sqlite3.connect(db_file) re...
56fa7796fa14663c3fc6e9ac960dd9221f394f79
j0ker404/flappy-clone
/state.py
1,439
3.5
4
import colours import pygame class State: def __init__(self, game_area,bird,SCREEN,pipe, pipe_group=None): """ game_area: Game_Area instance pipe_group: Pipe_group instance bird: bird instance SCREEN: Display Surface area """ self.game_area = game_area ...
f0f35b6d5104853340a6597a3ec70a59e9be6dee
qhuydtvt/C4E3
/Assignment_Submission/minhdn/Session 4 - Assignment 3/3.1.2. Circle in circle.py
112
3.59375
4
from turtle import * color('green') i = 0 r = 10 while i < 10: circle(r) i = i + 1 r = r + 10
7f4ef7d2fa5dd2f331b88f3b604cc19cbfac3389
mshibatatt/wcbc_problems
/problemsets/chapter11/fird.py
439
3.625
4
from utils import WcbcException def fird(inString): split = inString.split() if len(split) != 3: raise WcbcException("input must be composed of 3 numbers") M, a, b = int(split[0]), int(split[1]), int(split[2]) if a > b: raise WcbcException("a must be equal to or smaller than b") ...
d6f9870c10af1020405d3815d3198062f44cd0db
KvinLiu/Udacity
/ITCS/Lesson_2/Median.py
283
3.703125
4
def bigger(a,b): result = a if b > a: result = b return result def biggerst(a,b,c): return bigger(bigger(a,b),c) def median(a,b,c): if a == biggerst(a,b,c): return bigger(b,c) if b == biggerst(a,b,c): return bigger(a,c) if c == biggerst(a,b,c): return bigger(a,b)
1f2ee8d45634fdcd402042ab92066db0bbe60dd2
benfetch/Project-Euler-Python
/problem17.py
1,804
3.75
4
def spell_number(n): word = '' dict_words = {'1': 'one', '2': 'two', '3': 'three', '4': 'four', '5':'five', '6': 'six', '7':'seven', '8': 'eight', '9':'nine'} dict_teens = {'11': 'eleven', '12': 'twelve', '13': 'thirteen', '14': 'fourteen', '15': 'fifteen', '16': 'sixteen', '17': 'seventeen', '18': 'eightee...
0ada1809658e1113b361146cb2cfb2988342f9d1
xxcocoymlxx/Study-Notes
/CSC148/06 Tree(BST)/more tree practice.py
2,617
3.921875
4
#没壳的 class BTNode(): def __init__(self, data, left=None, right=None): self.data, self.left, self.right = data, left, right def longest_path(self): """ BTNode -> list of BTNode""" ## 这是下面已经包含了的base case ## if self.left == self.right == None: ## return [self] ...
de6c43ab4974ced18cb43983528b39c140c491e0
Ernest-Sharp/Programming_for_Informatics
/Curso_1-4/05week_01.py
813
4.40625
4
# 3.1 Write a program to prompt the user for # hours and rate per hour using raw_input to # compute gross pay. Pay the hourly rate for # the hours up to 40 and 1.5 times the hourly # rate for all hours worked above 40 hours. # Use 45 hours and a rate of 10.50 per hour # to test the program (the pay should be 498.75). #...
fb13f8e1038f223d98292846a36846fa93d776e8
JATP98/ejercicio_json
/ejer5.py
420
3.515625
4
#5. Pedir un id pelicula y contar # cuantos generos tiene. import json from pprint import pprint idd=input("Dime un id: ") contador=0 with open('peliculas.json') as data_file: data = json.load(data_file) for pelicula in data: if (pelicula["id"]) == idd: #for genero in pelicula["genres"]: # contador=contador+1 ...
80259cd8abb51eb33e42c7e0385210b27e35db9c
khanabdul16/Full-Python-Course
/3. if statements, Loops, Break,Pass,Continue, Prime no.py
839
4
4
###### If Statement ###### x=2 y=3 if x<y: print("greater") elif x==y: print("equal") else: print("lesser") print() ###### While Loop ###### x=1 while x<=5: print(x,end=" ") x+=1 print() ###### For Loop ###### x=[1,3,34,4,5] for i in x: print(i,end=" ") print...
32ec25d18eb77688e3c4f4502a479d008f6696b3
5oma/acpythonscripts
/GUI/hwsophi.py
290
3.921875
4
from tkinter import * import math root = Tk() # root (main) window top = Frame(root) # create frame top.pack(side='top') # pack frame in main window hwtext = Label(top, text='Hola, Ariel! Me llamo 50πΔ. Vamos a crear un jardín de formas.') hwtext.pack(side='left') root.mainloop()
2dd350d39109137a8dbb80f2812721d6f4047b03
philgineer/Python_projects
/Deeplearning_math/Chapter01/python_class2.py
498
3.6875
4
class node: node_cnt = 0 # class variable def __init__(self, x, y): self.x, self.y = x, y self.add = None self.adder() node.node_cnt += 1 def adder(self): self.add = self.x + self.y node1 = node(10, 20) print("x: ", node1.x, "\...
d043ff9deea7e05d38c32fb1b2664121f34fc9fc
gary391/CWH-PythonBeginner
/oopstut2.py
853
4.28125
4
# First class # How to make your own class # How to make your own object from this class # What is init method class Person: # This constructor method is called each time we make an object of the class # There we are defining the attribute for our object # self key word is convention, but you can write you...
66475394f2ec10a0ffc7fcd1c75322d452a6cdb0
Lominelo/infa_2021_Litovchenko
/lab_2/упр 8.py
127
3.78125
4
import turtle import math turtle.shape('turtle') for i in range (0,1000): turtle.forward(i*10) turtle.left(90)
865dfc7305a55d66dbcdbcadc1c3c2d18b72ec96
mishrasunny174/DataStructuresAndAlgorithms
/python/DataStructures/LinkedList/LinkedList.py
1,194
4.03125
4
from Node import Node class LinkedList(object): def __init__(self): self.head = None self.size = 0 # O(1) complexity def insertBegin(self, data): if self.head is None: self.head = Node(data=data) else: self.head = Node(data=data, nextNode...
28d50188fdd027f54728ce5bd2e5e2a6382d4b2b
stoic-plus/codewars_kata
/python/descendingOrder.py
632
4.21875
4
# Your task is to make a function that can take any non-negative integer as a argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible number. # # Examples: # Input: 21445 Output: 54421 # # Input: 145263 Output: 654321 # # Input: 1254859723 Output: 987...
11b21a9139f6ecc597e0096e560d93abf1be5c9e
Zekess/Asignacion_de_Turnos_webapp
/Solver_codigos/get_instancias.py
12,655
3.59375
4
import pandas as pd import streamlit as st import base64 # descarga de archivos def xldownload(excel, name): data = open(excel, 'rb').read() b64 = base64.b64encode(data).decode('UTF-8') href = f'<a href="data:file/xls;base64,{b64}" download={name}>Download {name}</a>' return href def get_co...
98f94d5512b3fd153ea489a796ccd4a87ca30bd9
rundong-zhou/PHY407-Projects
/Lab4/Lab04-407-2020-sol/L04-407-2020-Q3c.py
2,236
3.796875
4
# Author: Nico Grisouard, University of Toronto Physics # Answer to questions related to finding roots and extrema import numpy as np import matplotlib.pyplot as plt from matplotlib import rc import scipy.constants as pc # physical constants def f(x): return 5*(np.exp(-x) - 1.) + x def df(x): return 1 - 5*np.exp(...
bafee89a6ac13c21997e7054175e2a4ee2afaa93
Mike-droid/ejercicios-python-youtube
/Diccionarios/ejercicio4.py
458
4.09375
4
meses = { '1' : 'Enero', '2' : 'Febrero', '3' : 'Marzo', '4' : 'Abril', '5' : 'Mayo', '6' : 'Junio', '7' : 'Julio', '8' : 'Agosto', '9' : 'Septiembre', '10' : 'Octubre', '11' : 'Noviembre', '12' : 'Diciembre' } fecha = input("Escribe una fecha en formato dd/mmm/aaaa : ") #* 22/10/2021 fecha = f...