blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
a2a18544685a691a7b072d14b04f7b2f1e6ddca7
SebastianoFazzino/Python-for-Everybody-Specialization-by-University-of-Michigan
/Word_coutnter_using_dictionaries.py
461
4.125
4
#how to find the most common word in a text: openfile = input("Enter file name: ") file = open(openfile) counts = dict() for line in file: words = line.split() for word in words: counts[word] = counts.get(word,0) + 1 bigcount = None bigword = None for word, count in counts.items(): ...
76c516ac88561e7cbca00914c45cd1f9e1437745
SebastianoFazzino/Python-for-Everybody-Specialization-by-University-of-Michigan
/Dictionaries.py
746
3.71875
4
new = dict() new['money'] = 12 new['candy'] = 3 new['pen'] = 2 print(new) new['candy'] = new['candy'] + 2 print(new) counts = dict() names = ['csev','cwen','csev','zqian','cwen'] for name in names: if name not in counts: counts[name] = 1 else: counts[name] = counts[name] + 1 ...
5cd45a7e4fee6f5440f4126b64ae8e80730e9ae9
SebastianoFazzino/Python-for-Everybody-Specialization-by-University-of-Michigan
/Conditional Statements.py
907
4.25
4
#Calculating the score score = input("Enter Score: ") try: score = float(score) if score > 0.0 and score < 0.6: print ("F") elif score >= 0.6 and score <= 0.69: print("D") elif score >= 0.7 and score <= 0.79: print ("C") elif score >= 0.8 and score <= 0.89: ...
2580d38e27183584a05d33e9f3b9791cdb8f5ad6
AidenBurgess/Uni-2021
/ENGSCI 760/Assignments/3/coinChange.py
933
3.90625
4
def optimalCoinChange(x, denoms): # Function finds the minimum number of coins required to change a monetary # amount. # Inputs: # x = amount of money to be given in coins, given as an INTEGER, in cents. # e.g. $1.35 is input as 135 # denoms = denominations of coins available, in INTEGER cents, ...
aad1357862222f1d2a9b300a3cbb1b79b2068f58
vhsw/CodeMasters_Tourney
/Python 3/sortByLength.py
247
3.96875
4
# Given an array of strings, sort them in the order of increasing lengths. # If two strings have the same length, their relative order must be the same as in the initial array. def sortByLength(inputArray): return sorted(inputArray, key=len)
bbd2cb9997f966800845636a91585c1cf1808914
vhsw/CodeMasters_Tourney
/Python 3/increasingNumber.py
416
3.9375
4
# You are given a positive integer x and you should perform n operations, # where on the i-th operation you increase x in such a way that its new value is divisible by i (operations are numbered from 1 to n). # Find the minimal value of x you can obtain by performing n operations described above. def increasingNumbe...
96fa1e5c15ef53eb8d55b0d622de4f2ae62746c1
vhsw/CodeMasters_Tourney
/Python 3/uniqueDigitProducts.py
341
3.796875
4
# Let's call product(x) the product of x's digits. Given an array of integers a, calculate product(x) for each x in a, and return the number of distinct results you get. def uniqueDigitProducts(a): def p(n): res = 1 for d in str(n): res *= int(d) return res return len(...
0e89c989b67cbeaa060fc55bc0cc783b50d5bef8
vhsw/CodeMasters_Tourney
/Python 3/higherVersion.py
509
3.578125
4
# Given two version strings composed of several non-negative decimal fields # separated by periods ("."), both strings contain equal number of numeric fields. # Return true if the first version is higher than the second version and false otherwise. def higherVersion(ver1, ver2): a = ver1.split('.') b = ver2....
cedd4566df1dd7e40af2ec8d0642d3382294b4bf
vhsw/CodeMasters_Tourney
/Python 3/candies.py
336
3.5625
4
# n children have got m pieces of candy. # They want to eat as much candy as they can, # but each child must eat exactly the same amount of candy as any other child. # Determine how many pieces of candy will be eaten by all the children together. # Individual pieces of candy cannot be split. def candies(n, m) : ret...
c261b463b013923b135f0c3610ae8ce1060d3909
vhsw/CodeMasters_Tourney
/Python 3/concatenationProcess.py
1,018
4.09375
4
# Given an array of strings, produce a single string as follows: # Repeat the following steps while there is more than one string in the array: # find the shortest string in the array (if there are several strings of the same length take the leftmost one); # find the shortest string among the rest (if there are several...
fd0fc62887f7a094d05da8a40d720d35098afe8d
vhsw/CodeMasters_Tourney
/Python 3/countWaysToChangeDigit.py
265
4
4
# Given an integer, find the number of the ways to change # exactly one digit in it in order to obtain a bigger integer. def countWaysToChangeDigit(value): answer = 0 while value > 0: answer += 9 - value % 10 value //= 10 return answer
9a801eff9401beb50ff24b2a18c94ec0ec340a7d
vhsw/CodeMasters_Tourney
/Python 3/prefixSums.py
346
3.6875
4
# Construct an array b of prefix sums of the given array a. # b is defined as: # b[0] = a[0] # b[1] = a[0] + a[1] # b[2] = a[0] + a[1] + a[2] # ... # b[n - 1] = a[0] + a[1] + ... + a[n - 1] # where n is the length of a. def prefixSums(a): b = [ a[0] ] for i in range(1, len(a)): b.append(b[i...
1d1d20bbc150eb8859cdfdf46237408e73928d38
vhsw/CodeMasters_Tourney
/Python 3/isPermutation.py
182
3.890625
4
# Given a certain array, find out if it's a permutation of numbers from 1 to a given integer. def isPermutation(n, inputArray): return sorted(inputArray) == list(range(1, n+1))
7ff419e2d36aa2e66110d0cca581f6e85064b1a6
vhsw/CodeMasters_Tourney
/Python 3/quickSort.py
523
4.0625
4
# You are given an array of integers. Sort its sub-array between the given indices l and r (inclusive) and leave the other elements intact. def quickSort(a, l, r): if l >= r: return a x = a[l] i = l j = r while i <= j: while a[i] < x: i += 1 while a[j] > x: ...
9be4a9569f8411bedc8636a12c6b56699492d09b
vhsw/CodeMasters_Tourney
/Python 3/visitsOnCircularRoad.py
589
3.515625
4
# There are n houses in a village on a circular road numbered # from 1 to n starting from some house in clockwise order. # It takes one minute to get from one house to any of two adjacent houses # and there are no other roads in this village besides the circular one. # Find the minimal time required to make all visits ...
c8d4399e0689763a09b0a7af8bd2977b7953d027
vhsw/CodeMasters_Tourney
/Python 3/avoidObstacles.py
552
3.734375
4
# You are given an array of integers representing coordinates of obstacles situated on a straight line. # Assume that you are jumping from the point with coordinate 0 to the right. You are allowed only to make jumps of the same length represented by some integer. # Find the minimal length of the jump enough to avoid al...
464b66356043490e68c543de8f6c183b396dd73f
vhsw/CodeMasters_Tourney
/Python 3/rightmostRoundNumber.py
343
3.71875
4
# Given an array of integers, find the rightmost round number # in it and output its position in the array (0-based). # If there are no round numbers in the given array, output -1. def rightmostRoundNumber(inputArray): ans = -1 for i in range(len(inputArray)): if inputArray[i] % 10 == 0: ...
ea512409b6960fa0080fddc769c21f746743af4c
mightykim91/ProblemSolving
/swea_5248_그룹나누기.py
472
3.6875
4
def find_set(x): if p[x] != x: p[x] = find_set(p[x]) return p[x] def union(x,y): p[find_set(y)] = find_set(x) for tc in range(1, int(input())+1): N, M = map(int, input().split()) p = [x for x in range(N+1)] data = list(map(int, input().split())) sets = [] for i in range(M): ...
6ddf8eb05457c374cc6fd36c24b58320417eb8d2
mightykim91/ProblemSolving
/swea_5203_베이비진.py
2,081
3.5625
4
def shuffle(player, lst, output, level, used): #exit if level == len(lst): babygin(player, output) return for i in range(len(lst)): if not used[i]: used[i] = True shuffle(player, lst, output+[lst[i]], level+1, used) used[i] = False if ...
96dd5264ff38d0fd2c97413156397cea4da742d9
JLockleyASC/jaymond_ASC3
/mash.py
1,132
4.15625
4
house =["Mansion", "Apartment", "igloo", "House" ,"tent", "tree house"] spouse =["peewee herman", "Snookie", "Oprah", "kylie jennner"] car =["horse", "bugatti with one wooden wheel", "DeLorean DMC-12", "Scooter"] kids =["0", "1", "2", "5"] print ("Enter the name of three people you could marry: ") name1 = input("Name1:...
7dd8d1962a727f60fdeff190c8f7641a7f848247
rongtianbiao/python_cookbook
/2str_text_lx.py
3,187
3.78125
4
# coding=utf-8 # 1.使用多个不同的字符分割字符串 import re line = 'asdf fjdk; afed, fiek,asdf, foo' s_line = re.split(r'[,;\s]\s*', line) # 分割符为逗号、封号、和空格 print(s_line) # 2、检查字符串的开头和结尾 # 方法一匹配一种可能的开头: str.startswith() str.endswith() # 方法二: 匹配多种可能的开头和结尾,只需将匹配项放入到一个元组中,然后传给 str.startswith() str.endswith() filenames = ['makefile...
0421dfde7834d60d6eecc494d8eeb776fe85b216
adaogomesl/PyFlow
/pyflow/flow/commands.py
1,850
3.5
4
class Commands: """ Class with various static methods for constructing commands used to perform workflow actions such as beginning workflow steps, running calculations, and handling their outputs. """ @staticmethod def get_run_command(step_id: str, wave_id: int, time: int) -> str: "...
0463d54f32b58a04b17702f42c7b1dd8ba72306e
MercerBinaryBears/Slides
/2016/slides/Math/siv-of-eratosthenes.py
334
3.765625
4
def primes_upto(limit): is_prime = [False] * 2 + [True] * (limit - 1) for n in range(int(limit**0.5 + 1.5)): # stop at ``sqrt(limit)`` if is_prime[n]: for i in range(n*n, limit+1, n): is_prime[i] = False return [i for i, prime in enumerate(is_prime) if prime] print(pri...
dad8dc4f489a889edcc12c411b54449e0a2e38b8
MercerBinaryBears/Slides
/2016/slides/ComputationalGeometry/theo.py
396
3.609375
4
import math def theta_term(n): return math.atan2(1, n ** 0.5) def radius(n): return (n + 1) ** 0.5 # # In our case, we have a closed for the radius at n. However, the total rotation for a given n is actually given by the # sum of every theta_term(n) below it: # sum(theta_term(k) for k in range(1, n+1)) # T...
d178dca6ef0bff7d8f7aaa747c7cddfde84b4d27
kvan1231/simple_advection
/advection.py
6,360
3.671875
4
""" An implementation of linear 1-d advection The equation for advection is given by: a_t = -u a_x Need to solve the equation using a) upwind (a_i^n+1 - a_i^n)/dt = -u(a_i^n - a_i-1^n)/dx b) FTSC (a_i^n+1 - a_i^n)/dt = -u(a_i+1^n - a_i-1^n)/2dx c) IIT (implicit in time) (a_i...
1cd63596dd2dd52859bdfb265de35b5c2cc2b855
ZerkoDeV/practicee
/no10.10.py
198
3.515625
4
import string check_pangram = lambda text : sorted(set(text.lower().replace(" ",""))) == sorted(set(string.ascii_lowercase)) print(check_pangram("The quick brown fox jumps over the lazy dog"))
19133f80044a3e481f018c7634bbe8751e95618b
sj-nv20/Python
/제어문 - while 반복문[실습과제2].py
184
3.71875
4
#while 반복문[실습과제2] #while문을 사용하여, 100 이상의 자연수 중 가장 작은 23의 배수를 출력해 보세요. i = 100 while i % 23 != 0: i += 1 print(i)
fdbd9b8bd2aa87a49842971de9332965fe9cedf0
sj-nv20/Python
/제어문[실습과제5].py
774
3.859375
4
#제어문[실습과제5] #while문을 사용해서 구구단 프로그램을 만들어 봅시다. #실행하면 아래와 같은 결과물이 출력되어야 합니다. ''' 1 * 1 = 1 1 * 2 = 2 1 * 3 = 3 . . . 9 * 7 = 63 9 * 8 = 72 9 * 9 = 81 ''' #참고로 이 문제는 '중첩 while문'이라는 개념을 사용해야 하는데요. #중첩 while문은 while문의 수행 부분 안에 또 다른 while문을 넣는 것을 이야기 합니다. #제가 특별히 설명드리지 않은 개념이지만, 조금 고민하다 보면 여러분이 직접 알아내실 수도 있습니다. #도저히 생각이 안 난다...
d45ca59a0dfbd49c06d92f6eba78d4bfbed08685
sj-nv20/Python
/파일 읽기.py
466
3.625
4
#파일읽기 ## r = read의 약자 with open('data/chicken.txt', 'r') as f: #읽어드린 파일을 변수f에 저장 print(type(f)) #<class '_io.TextIOWrapper'> # 파일 내용 출력하기 with open('chicken.txt', 'r') as f: for line in f: #한 줄씩 순서대로 변수line에 저장 print(line) #인코딩 문제 발생 시 with open('data/chicken.txt', 'r', encoding='UT...
eb8ef1b18d56a39e05bcd9c7fe2b448340d654c5
sj-nv20/Python
/추상화 [실습과제1].py
814
3.796875
4
#짝수? 홀수? ''' 어떤 수가 짝수인지 홀수인지 판단해 주는 함수 is_evenly_divisible를 쓰세요. is_evenly_divisible는 number(수)를 파라미터로 받습니다. 짝수인 경우, 즉 number가 2로 나누어 떨어질 경우에는 True를 리턴해 줍니다. 홀수인 경우, 즉 number가 2로 나누어 떨어지지 않을 경우에는 False를 리턴해 줍니다. 함수 안에는 print문이 아닌, return문을 사용해야 합니다. 그리고 참고로 불린 개념을 잘 사용하면, 함수 단 한 줄로 작성할 수 있습니다! ''' def is_evenly_divi...
c29c9e529cb4d7c09a92a24e946007e1999de810
sj-nv20/Python
/for반복문 - range 함수.py
940
3.546875
4
#range 함수 - 파라미터를 1~3개 쓰는 버전이 있음 #range 함수 장점 - 간편 / 깔끔 / 메모리 효율성(1쓰고 버리고 2쓰고 버기로 등) for i in [1,2,3,4,5,6,7,8,9,10] : print(i) # 파라미터 1개 버전 ''' for i in range(stop) : #0부터stop-1까지의 범위 print(i) ''' for i in range(10): #0부터 9까지 범위 print(i) # 0 1 2 3 4 5 6...
0ab55107576bc3938061a94c6a2d978d7a72156a
rcha3704/Udacity-CS101-Introduction-to-Computer-Science
/Lesson4 - Problem Sets/latency.py
743
3.890625
4
# Write a procedure, speed_fraction, which takes as its inputs the result of # a traceroute (in ms) and distance (in km) between two points. It should # return the speed the data travels as a decimal fraction of the speed of # light. speed_of_light = 300000. # km per second def speed_fraction(time,distance): tim...
e3e14d6b50222fddaea52f6a1a9012daf1654cdb
NakonechnyiMykhail/PyGameStart
/lesson26/repeat.py
505
4.1875
4
# functions without args without return # 0. import random # library # 1. create a function with name "randomizer" # 2. create a varieble with name "data" = 'your text at 6-10 words' # or "lorem ipsum..." # 3. select var "data" with text and with random method print # with for-loop 20 times only ONE character data = ...
30538a826edda608f45ab7eab1f80bf2e49c0287
NakonechnyiMykhail/PyGameStart
/test/project_generation.py
1,442
3.828125
4
#!/usr/bin/python # 06/01/2018 # m1ss10n # v.001 # Code generation the basic project structure # ideas # create folders and copy standart files # add regular for input path and case for different situations # import os, sys def createFolder(directory): try: if not os.path.exists(directory): o...
7b8216073a24a42d0f7ec4fde06bf37e307d0ec7
pedrohbraz/python_codes
/imposto3.py
343
3.96875
4
while 1: salario = input("salario:") imposto = input("imposto:") if not imposto: print("valor de imposto nao encontrado") elif imposto == 's': break else: imposto = float(imposto) if imposto < 15 : print("furto") else: print("assa...
7a59ecd15805aba7be4b688d8383150cb17b494b
Relex12/Languages
/Code/Python/ZCasino.py
1,842
3.90625
4
# def entrez_numero: # x = imput ("Entrez un numéro entre 0 et 49 compris") # try: # int(x) # except Exception as e: # raise # return x # # # print ("Bienvenue dans le jeu du ZCasino, ici on joue à la roulette") # print ("Le ZCasino vous donne 50$, ce sera votre somme de départ") # somme_joueur = 50...
e5700dcae0fa3d63d6431a80f1adf4671fa0f3f6
jasoncoelho/adventOfCode2020
/Day1/process1a.py
427
3.578125
4
import os import sys with open(os.path.join(sys.path[0], "input.txt"), "r") as reader: targetValues = set() for line in reader: diffValue = 2020-int(line) # what we are looking for if int(line) in targetValues: # have we seen the inverse before returnVal = int(line) * diffValu...
abdca2934cefce7f0d2fe25666d171e0adfd92a9
jasoncoelho/adventOfCode2020
/Day2/process2.py
596
3.796875
4
import os import sys import re def isValid(min,max,character,password): count = password.count(character) valid = (count >= min) & (count <= max) print(str(min) + " " + str(max) + " " + character + " " + password + " " + str(valid)) return valid with open(os.path.join(sys.path[0], "input.txt"), "r") ...
1ea7490cdccf34f77ab2a56d8aee12cdcde46787
ksera332/Atcoder_records
/ABC007/ABC007B.py
88
3.71875
4
# coding: utf-8 # In[7]: A = input() if("a"<A): print("a") else: print(-1)
5a7c3d5d4e180868040f1a16f882773d185e4e13
ksera332/Atcoder_records
/ABC166/ABC166A.py
97
3.609375
4
# coding: utf-8 # In[1]: S = input() if S == "ABC": print("ARC") else: print("ABC")
e7cc49964fd538385e654896c2601eebe0345aea
ksera332/Atcoder_records
/ABC124/ABC124C.py
288
3.6875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: S = input() ans_0 = 0 ans_1 = 0 check = "0" for i in S: if i == check: ans_0 += 1 else: ans_1 += 1 if check == "0": check = "1" else: check = "0" print(min(ans_0,ans_1)) # In[ ]:
0efc850e2a231b48d98d8ba54534f7bd0362bcf0
ksera332/Atcoder_records
/ABC155/ABC155C.py
590
3.875
4
#!/usr/bin/env python # coding: utf-8 # In[28]: import sys read = sys.stdin.buffer.read#全部読み込むやつ readline = sys.stdin.buffer.readline#1行読み込むやつ readlines = sys.stdin.buffer.readlines#リストで読み込むらしい # In[22]: N = int(input()) dic = {} for i in range(N): S = input() if (S in dic) == False: dic[S...
fa1f83a1efdeb7b89d2a527d71ee47e1dda78c4c
Kim-so-hyun/16CPFC-Kim-So-Hyun
/ex35/ex35.py
1,325
4
4
# -*-coding:utf8 # http://learnpythonthehardway.org/book/ex35.html from sys import exit if "raw_input" not in dir(__builtins__): raw_input = input def gold_room(): print ("This room is full of gold. How much do you take?") choice = raw_input("> ") if "0" in choice or "1" in choice: how_much ...
d3eed8aa92cc1349d90a2357ceb5015ad8c8eb07
bingoshu/Python123
/二叉树.py
340
3.96875
4
import turtle as t def tree(length,level): #树的层次 if level <= 0: return t.forward(length) #前进方向画 length距离 t.left(45) tree(0.6*length,level-1) t.right(90) tree(0.6*length,level-1) t.left(45) t.backward(length) return t.pensize(3) t.color('green') t.left(90) tree(100,6)
1882ed322f2dd687687fbfed113a2c8f575d9036
Stephen-Kamau/Data-Filtering-and-manipulation-using-pandas
/pandas3.py
1,230
3.6875
4
import pandas as pd import numpy as np # Read csv file into a pandas dataframe df = pd.read_csv("property data.csv") # Take a look at the first few rows df.head() #first 5 elements by default # Making a list of missing value types missing_values = ["n/a", "na", "--"] df = pd.read_csv("property data.csv", na_values...
96baef2cef528aedb47e5e26269199e73c14060c
jgruselius/misc
/Python/well_generator.py
1,107
3.5625
4
#! /usr/bin/env python3 import argparse import string def main(args): rows = string.ascii_uppercase[:8] cols = range(1, 13) if args.r: wells = [(r, c) for r in rows for c in cols] else: wells = [(r, c) for c in cols for r in rows] if args.p: fstr = "{}{:02d}" else: ...
728f3119e53d2c3a06b1cd76766a75de78557e0e
jgruselius/misc
/Python/qparse.py
1,067
3.5625
4
import argparse import csv import math def linear_least_squares(x_values, y_values): m = len(y_values) n = len(x_values) # Demand x_values[] and y_values[] of equal size: if m != n: raise ValueError("Lists of different length") # Calculate a linear least squares regression function on the form y = a + bx: sum_...
38a0497c118c42ce41fdd450ed882973dfe56883
absbin/genreator-test
/davin_reddy/class/inheritage.py
815
3.609375
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 27 23:38:29 2017 @author: ABSBIN """ class Vehicle: def general_usage(self): print('General use is transprtation') class Car(Vehicle): def __init__(self): print ('I am a Car') self.wheels=4 self.has_roof=True def specific_usag...
9de79e49664d6ccd15afa6f31697af96f69d5f0f
absbin/genreator-test
/davin_reddy/fun_sum.py
361
3.78125
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 27 11:18:13 2017 @author: ABSBIN """ def sum(a,b=2): ''' This function gives two numbers and gives sum of them ''' print ("a = " + str(a)) print ("b = " + str(b)) total=a+b print("ali's total expenses list is", total) n...
dce10412b46ca39815faeaeba60caa56dbac4a47
absbin/genreator-test
/davin_reddy/if_cuisines.py
424
3.6875
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 27 09:34:09 2017 @author: ABSBIN """ Iranian=['kabab', 'abgosht','kashk' ] Indian=['samosa','daal','naan'] Italian=['pizza','pasta','risoto'] dish=input('Enter a dish :') if dish in Iranian: print ('Iranian cuisine') elif dish in Indian: print ('Indian cuisine'...
ee9cea9cbdef71f805cb185261770d0dbdbc73d2
absbin/genreator-test
/davin_reddy/fibonacci.py
1,097
3.765625
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 26 14:59:53 2017 @author: ABSBIN """ import argparse def fib(n): a,b=0,1 for i in range(n): a,b=b,a+b return a def main(): parser=argparse.ArgumentParser() group=parser.add_mutually_exclusive_group() group.add_argument('-v','--verbose',a...
b6f0faf184ead86576a6af8ffa92d9efed60cc32
absbin/genreator-test
/davin_reddy/bubble_sorting.py
590
3.875
4
def bubble_sort(lst): for i in range(len(lst) - 1): for j in range(len(lst) - i - 1): if lst[j] > lst[j + 1]: a, b = lst[j], lst[j + 1] lst[j], lst[j + 1] = b, a return lst lst = [2, 1, 4, 7, 8, 2, 3] lst_sorted = bubble_sort(lst) print("Sorted list is : {}...
510eb1b36d844d56431dc7dadd2bd1396c1b6906
absbin/genreator-test
/davin_reddy/exeption2.py
538
3.625
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 28 10:27:09 2017 @author: ABSBIN """ try: # print(1) raise MemoryError('memooory errrror') except MemoryError as e: print(e) print('******************') try: # print(1) raise Exception('memooory errrror') except Exception as e: print(e) print(...
12cd0ba02a66de331c0dd46ee5fa1ff2845b2cf1
absbin/genreator-test
/davin_reddy/Multiprocessing/Multiprocessing8.py
964
3.703125
4
# -*- coding: utf-8 -*- """ Created on Fri Dec 29 14:34:59 2017 @author: ABSBIN """ # this progrAM IS RAN FROM command import multiprocessing def cal_square(numbers,res): global results for i in numbers: print("square:"+ str(i*i)) res.append(i*i) print("results square inside ...
49423017b82271ba212ae9a85ebc65a2f78fc024
phyogitty/rass-ciscohackathon
/TimeExtractor.py
5,218
3.53125
4
import re import csv from datetime import datetime as dt import datetime # need: current date in (tomorrow, next week) # Look for day of the week separately # dayoftheweek(DOTW), month(m) day(2;0<d<32), year(4;y>=thisyear) # xx:xx (pm,am) (today, next week, friday..) # x:00(pm) time should be recorded separately # t...
1fac4c3d0c610d8b8982c491cde05cb644e8e5b9
phyogitty/rass-ciscohackathon
/track3/MailFilter.py
1,266
3.796875
4
import re import csv # input: csv file with mail body and header (each row has body, header) # regex: search for key words and numbers in email, if none exist, don't add to new file # output: new csv file with filtered mails class MailFilter: keywords = ['mon', 'tue', 'wed', 'thur', 'fri', 'schedule', 'sat', '...
e128dc2672cbf6b6b4dee1c1537884ffcc9dc86a
ridhim-art/practice_list2.py
/tuple_set_dictionary/example_contacts.py
707
4.1875
4
#program where user can add contacta for contact book contacts = {'help': 100} print('your temp contact book') while True: name = input("=> enter contact name :") if name: if name in contacts: print('=> contact found') print(f'=> {name} :{contacts[name]}') else: ...
95084412f42e93e610a01e2bcc127a14a940eee2
ridhim-art/practice_list2.py
/list_comprehension3.py
317
3.9375
4
names = ['DIVYA SRIVASTAVA','AYUSHI VERMA','RIDHI MISHRA'] names_containing_e = [names for nmae in names if 'e' in names] names_capitalized = [name.title() for name in names] names_ending_with_a = [name for name in names if name.endswith('a')] print (names) print(names_containing_e) print(names_capitalized) print(n...
c504e5e4f9433cea90d3a95157a7424ab9a74f25
ridhim-art/practice_list2.py
/prime_number.py
287
4.15625
4
# 7 -> 7/2,7/3,7/4,7/5,7/6 prime # 20 -> 20/2 non prime # program to find if number is prime num = int(input('enter a number : ')) for i in range(2,num): print(num,'%',i,'=',num % i) if num % i ==0: print('non prime') break else: print('prime')
a2e797303ab643b59711cc67889035cb0fa552dd
ridhim-art/practice_list2.py
/functions/returntype_functions.py
750
3.828125
4
def mean(*numbers): if numbers: return sum(numbers)/len(numbers) m1 = mean(1,2,3,4,5,6) print(mean(1,2,3,3,4,5)) m2 = m1 * 10 print('meanx10',m2) def word_counter(sentence): if sentence: words = sentence.split() count = len(words) return count from string import punctuation d...
ad5fdda33ea752ed77936eba34e371562ed868bc
ridhim-art/practice_list2.py
/condition_1.py
264
4.21875
4
a = 10 if a > 5: print('this is a greater than 5') if a > 15: print ('this is also bigger than 15') if a == 10: print ('thisis equal to 10 ') if a == 5 or a < 15: print ('so this condition is true ') print('any one of them is true')
cebf038f1c68927b1c610e29ed003bd567827c12
ridhim-art/practice_list2.py
/for_str_iterate.py
98
3.515625
4
sentence = 'the theory of everthing' print(len(sentence)) for char in sentence: print (char)
63063065a860fa6459c56eba1e772d5c85b07ad4
katshun0307/sort-algorithms-in-python
/quick_sort.py
564
3.828125
4
import time import RandomArray def Quicksort(A, p, r): if p < r: q = Partition(A, p, r) Quicksort(A, p, q-1) Quicksort(A,q+1, r) def Partition(A, p, r): x = A[r] #pivot i = p-1 for j in range(p,r): if A[j] <= x: i = i+1 A[i], A[j] = A[j], A[i] ...
349017f82dfde4a4186db6694eac483dcbec52b7
subbuinti/python_practice
/numrectangularpattern2.py
123
3.5625
4
rows = int(input()) columns = int(input()) for i in range(1, rows+1): pattern = (str(i)+" ")*columns print(pattern)
35ad4effe541c40608461a458feffc06dda3a7fb
subbuinti/python_practice
/permssiontoattemptexam.py
351
3.875
4
attendance = input() medical_reason = input() lenght = len(attendance) attendance = attendance[:(lenght-1)] attendance = int(attendance) if attendance >= 75: print("Allowed to write exam") elif attendance <75 and medical_reason =="Y": print("Allowed to write exam") elif attendance < 75 and medical_reason =="N":...
644ea41190c4b370c3d664c678f0b45ecd5ceb95
subbuinti/python_practice
/solidrightangletriangle.py
100
3.671875
4
n = int(input()) counter = 1 while counter <= n: print("* " * counter) counter = counter + 1
e3c1cf30e1dd32ba715bcb261090315745a3b9e3
subbuinti/python_practice
/loopControlSystem/EvenAndOdd.py
203
3.53125
4
M = int(input()) N = int(input()) count_odds = 0 count_even = 0 for i in range(M, N+1): if i % 2 == 0: count_even += 1 else: count_odds += 1 print(count_odds) print(count_even)
56e9c71374e4b415c2617cb794a8a79362b1c0b6
subbuinti/python_practice
/dictionaries/combineTwoDictinories.py
956
3.921875
4
def convert_string_to_int(str_num_list): int_list = [] for str_num in str_num_list: num = int(str_num) int_list.append(num) return int_list def convert_to_key_value_pairs(keys_list, values_list): dict_a = {} number_of_keys = len(keys_list) for i in range(number_of_keys): ...
c37ece405e54f01809f1267c33ea4fcd645def9e
subbuinti/python_practice
/recursion/kthlargestnum.py
261
3.90625
4
numbers = input() k = int(input()) num_list = numbers.split(",") length_of_num_list = len(num_list) for i in range(length_of_num_list): num_list[i] = int(num_list[i]) num_list = sorted(num_list) kth_largest_number = num_list[-k] print(kth_largest_number)
1cd0945d56b7037358cfd2f0c3bd361f33b24fee
subbuinti/python_practice
/sumofnumMtoN.py
102
3.71875
4
m = int(input()) n = int(input()) total = 0 for i in range(m, n+1): total = total + i print(total)
49bd1aed517dbb85ba5f34580333e8c88724fb6f
subbuinti/python_practice
/hallowfullpyramid.py
276
3.6875
4
n = int(input()) for i in range(1, n+1): left_space = " " * (n-i) if (i >2) and (i < n): hollow_space = " " * (i-2) stars = "* " + hollow_space + "* " print(left_space+stars) else: stars = "* " * i print(left_space + stars)
e12d88aef7a118fcb17a3f0d11ed48ea6d48bf53
subbuinti/python_practice
/functions/funsumofsqaresMtoN.py
273
3.984375
4
def sum_of_squares_m_to_n(m, n): # Complete this function total = 0 for i in range(m, n+1): total += (i**2) return total m = int(input()) n = int(input()) # Call the sum_of_squares_m_to_n function result = sum_of_squares_m_to_n(m, n) print(result)
8a58a3f61e35813305c2efc0c4f9a3e0901b424b
subbuinti/python_practice
/digit8.py
226
3.875
4
n = int(input()) no_of_rows = (2*n) + 1 for i in range(1, no_of_rows+1): if (i == 1) or (i == (n+1)) or (i == no_of_rows): print("* " * n) else: spaces = " " * (n-2) print("* " + spaces + "* ")
bcb36d5bf1bd58e829a3d2943fe66aedb0cff3f1
subbuinti/python_practice
/perimeterofrectangle.py
179
3.703125
4
length_rect = input() length_rect = int(length_rect) breadth_rect = input() breadth_rect = int(breadth_rect) perimeter_rect = 2 *(length_rect + breadth_rect) print(perimeter_rect)
59162dcb94e0813396ca9de6a3b28d14bc72f380
subbuinti/python_practice
/electiciybill.py
319
3.90625
4
units = int(input()) bill = 0 if units < 50: bill = 2*units elif units < 150: bill = (2*50)+(3* (units -50)) elif units < 250: bill = (2*50)+ (3*100)+(5*(units-150)) elif units >= 250: bill = (2*50)+ (3*100)+(5*100)+(8*(units-250)) surchare = (0.2 * bill) total_bill = (bill+surchare) print(total_bill)
f1387c908ea911c86956de7edbceff98d41f67b3
subbuinti/python_practice
/printcharecters.py
130
3.734375
4
a = input() counter = 0 length_of_a = len(a) while counter <= (length_of_a - 1): print(a[counter]) counter = (counter + 1)
b29e38fe40600648d28ad0f5cceb0a32db57e77a
subbuinti/python_practice
/dictionaries/Squares.py
110
3.921875
4
n = int(input()) square_dict = {} for num in range(1, n+1): square_dict[num] = num*num print(square_dict)
9b5e8976b71888f0f9a2728ff4bf0ba31a82e1c7
subbuinti/python_practice
/functions/fourpassengeranddriver.py
361
3.9375
4
def number_of_cars_needed(no_of_people): # Complete this function number_of_cars =no_of_people // 5 remaining_people = no_of_people % 5 if remaining_people > 0: number_of_cars += 1 return number_of_cars no_of_people = int(input()) # Call the number_of_cars_needed function result = number_of...
71f3e8e9f01f1e74cde2cd514ef62fbed4fc45f3
subbuinti/python_practice
/graterthan5.py
252
3.984375
4
first_num = input() first_num = int(first_num) second_num = input() second_num = int(second_num) positive_num = (first_num > 0) and (second_num > 0) greater_num = (first_num > 5) or (second_num > 5) result = (positive_num and greater_num) print(result)
076e4b34a66d0bced7cb3cfbcb02ef6b92478f04
subbuinti/python_practice
/dictionaries/exactnumber.py
193
3.8125
4
list_a = input().split(",") num_list = [] for item in list_a: is_digit = item.isdigit() if is_digit: number = int(item) num_list.append(number) print(num_list)
7f5aae7ed46c60a22e399d3c9794f7f68742b1b9
subbuinti/python_practice
/functions/perimeterofsquare.py
175
3.90625
4
def perimeter_of_square(arg_1): # Write your code here perimeter = arg_1 * 4 return perimeter side = int(input()) result = perimeter_of_square(side) print(result)
66b83419bd37b1535baa06103921393c9773ad58
subbuinti/python_practice
/forprintint2.py
92
3.78125
4
start = int(input()) end = int(input()) for number in range(start, end+1): print(number)
fcd66891e5b8f163245f1f459d19fe92b010f6f1
subbuinti/python_practice
/dictionaries/sportsData.py
317
3.953125
4
students_dict = { "Ram": "Cricket", "Naresh": "Football", "Vani": "Tennis", "Rahim": "Cricket" } # Write your code here n = int(input()) for i in range(n): key_value_pair = input().split() key, value = key_value_pair[0], key_value_pair[1] students_dict[key] = value print(students_dict)
48dcae1f47997ff3f0942b7675f4e2602763031d
subbuinti/python_practice
/NestedConditions/NameOfMonth.py
124
3.71875
4
x = int(input()) import calendar if (x <= 12): print(calendar.month_name[x]) else: print("Invalid Month Number")
d9e76d1f7a25dfa8d4e160ce4a1f89fcd8eaf704
subbuinti/python_practice
/loopControlSystem/HallowDaimond.py
865
4.25
4
# Python 3 program to print a hallow diamond pattern given N number of rows alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U','V', 'W', 'X', 'Y', 'Z'] # Diamond array diamond = [] rows = -1 # Prompt user to enter number of rows while rows ...
165aa24d18a79694d15c7879dbc2baeac678dc10
subbuinti/python_practice
/dictionaries/charecterFrequency.py
241
3.984375
4
def print_char_count(line): line = line.lower() unique_chars = set(line) unique_chars.discard(" ") for char in sorted(unique_chars): print("{}: {}".format(char, line.count(char))) line = input() print_char_count(line)
bade2a1a2429cbf3f02cafa36a04154eeee3703f
subbuinti/python_practice
/hollowdaimond2.py
406
3.5625
4
n = int(input()) for row in range(0, n): #upper stars_count = n - row left_stars = "* " * stars_count hollow_spaces = " " * (2 * row) right_stars = "* " * stars_count print(left_stars + hollow_spaces + right_stars) for row in range(1, n+1): #lower stars_count = n - row stars = "* " * row...
2075a06111176c308862fedae0a660b371f4bfcd
subbuinti/python_practice
/soliddaimond.py
222
3.75
4
n = int(input()) k= n-1 for i in range(1, n+1): spaces = " "* k stars = "* " * i print(spaces+ stars) k= k-1 k= n for i in range(1, n): spaces = " "* i stars = "* " * (k-i) print(spaces+ stars)
8ace88479e0afee153ae62318d72db1f0d68a6e2
TatsuhikoA0314/word_bingo
/wordBingo/bingo/check_bingo.py
7,744
3.9375
4
# ビンゴチェック用関数 # 各入力値の妥当性のチェック def inputs_check(grid_num, bingo, words_num, words_list): """ inputs_checkの説明 入力された数値がすべて条件に当てはまっているかチェックする Args: ---------- grid_num (INT): グリッドのサイズ(S) bingo (STRIN二次配列): 入力されたビンゴ内文字列を空白で分けたもの words_list (STRING配列): 入力され...
f6ef587277e59d1568fad4072db790627afc6657
jaewHong/myappsample
/jae_week1hw.py
251
4.125
4
#!/usr/bin/env python3 import datetime if __name__ == '__main__': print("user name:",end='') username = input() date = datetime.datetime.now() print("Hello {0}! Today is [{1}/{2}/{3}].".format(username,date.month,date.day,date.year))
915ca9bbea032f07b0adc06a94f3409c6d7e3bad
lokeshsharma596/Base_Code
/Pyhton/Lambda_Map_Filter.py
2,346
4.375
4
# Lambda Function # any no of arguments but only one statement # single line ,anoymous,no def,no return # example-1 def sum(a, b, c): return a+b+c print(sum(4, 5, 1)) add=lambda a,b,c: a+b+c print(add(4, 5, 1)) # example-2 cube=lambda n:n**3 print(cube(4)) # Map Function # Atleast Two arguments :function and ...
f6796937861b4965d2b911320b0e86df7e1e661e
cpipilas/copi1-spanner-examples
/testing/3.complex-tests/measure-power-consumption.py
1,770
3.515625
4
# This example will make sure our device meets some specifications or thresholds # that we want to be true for every future version of our code. In other words, # we wanna make sure that these are always tested and we never end up exceeding # them. # # In this particular example this is a battery-powered device and we ...
cd6ead045850d0f0d29c52bd38ec4a55a87d2bd4
marcomarcucci30/MOBD-Project
/scaler.py
2,368
3.546875
4
import sklearn.preprocessing as preprocessing import numpy as np from scipy import stats def minMaxScaler(train_x, test_x): """Scaling data using minMaxScaler fitting only on train_x Args: train_x: Training set without Class Target test_x: Testing set without Class Target Ret...
05e4adc4278612b94664afb937ae7e61d2c37512
btozer/fatiando
/cookbook/vis_mpl_basemap2.py
663
3.546875
4
""" Vis: Plot a map using the Mercator map projection and pseudo-color """ from fatiando import gridder, utils from fatiando.vis import mpl # Generate some data to plot area = (-20, 40, 20, 80) shape = (100, 100) lon, lat = gridder.regular(area, shape) data = utils.gaussian2d(lon, lat, 10, 20, 10, 60, angle=45) # Now...
a14211b62a25ee61f3d06bd5382468c6a29c37be
btozer/fatiando
/fatiando/inversion/solvers.py
14,056
3.5625
4
""" Methods to optimize a given objective function. **Gradient descent** * :func:`~fatiando.inversion.solvers.linear`: Solver for a linear problem * :func:`~fatiando.inversion.solvers.newton`: Newton's method * :func:`~fatiando.inversion.solvers.levmarq`: Levemberg-Marquardt algorithm * :func:`~fatiando.inversion.sol...
7b8bd07bc71367894adf16ffae63e70e41099f8a
jackgray/phototools
/digiPixSize.py
2,567
3.921875
4
# digi_pix_size import math whatPhone = input('What type of phone? (Type "other" to enter manually) ') err = 1 while err == 1: # loop while invalid input err = 0 if whatPhone == str('iPhone 6'): # Front Camera Specs frontMP = 5 # megapixels frontSensorSize = 1....
a20e2e32cd4950296e9fb8d001863f53466fbc37
jackgray/phototools
/photo.py
6,407
3.546875
4
import math # Convert mm to in def mm2in(mm): return mm / 25.4 # Convert in to mm def in2mm(inches): mm = float(inches) * 25.4 return mm # provides negative legnth and width given film format type as dim_orig array def askFormat(format): err = 1 while err == 1: # loop while input invalid ...
965b3a61c238260b65d3e1629c701b1b6c70fd12
semolex/pyshortix
/shorteners.py
1,178
3.765625
4
import random import uuid from string import ascii_lowercase from string import ascii_uppercase from string import digits def _uuid_shorten(url=None, **kwargs): """ Shorten function based on UUID. String with replaced hyphens will be returned. :param url: url string, used for generating UUID. :p...
efa550f2896db88bdb5cbf6855d171f17093f878
mx419/diary_of_programming_puzzles
/arrays_and_strings/naive_suffix_array.py
489
4.0625
4
""" Given a string, construct its suffix array. String comparison for sorting potentially O(n^2) Naive implementation: O(n^2logn) """ def build_suffix_array(input_string): suffixes = {} for i in xrange(0, len(input_string)): suffixes[i] = input_string[i:] suffixes = sorted(suffixes.items(), ...
784d3d39166a6ba77ddd68b69c7875c4ceaed31e
ryankolean/CWS
/Python/BakingCake/tests.py
488
3.875
4
test.describe('Time to bake some cakes!') test.it('How many cakes can we make:') recipe = {"flour": 500, "sugar": 200, "eggs": 1} available = {"flour": 1200, "sugar": 1200, "eggs": 5, "milk": 200} test.assert_equals(cakes(recipe, available), 2, 'Wrong result for example #1') recipe = {"apples": 3, "flour": 300, "suga...