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
6fdea0162fa4b52bdfc052a33a73e03706a71060
elip12/Lines_Queueing
/configs/zdep/config4.py
13,057
3.703125
4
import random import math """ - Data holds the data for one session. - Each inner list represents a group. - Each inner inner dict represents a period. - Period dicts can have no more dictionaries than there are participants. - Each dict represents a player. - for now, all groups must be the s...
ef3d7a6aaad781f2bf8ad8484cf807c2afc3e28a
Ryugene/Zapoctak
/Minesweeper/Minesweeper.py
16,873
3.6875
4
import pygame import random pygame.init() ind = None #Icon icon = pygame.image.load("icon.jpg") pygame.display.set_icon(icon) #SETTINGS FUNKCE pocet_x = 0 pocet_y = 0 pocetmin = 0 def settings(): global pocet_x,pocet_y,pocetmin print("\n\n--Please select your difficulty settings--\n\nRecommended di...
088a600b0d851da9345a6ef2e336bdf32c9dddb8
rhaydengh/IS211_Assignment1
/assignment1_part2.py
614
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Assignment 1, Part 2""" class Book: """Class for books""" def __init__(self, author, title): """this function returns a book by author and title based on variables""" self.author = author self.title = title def display...
8abf72ea1f212128af347444953f315b2b26d1df
y1212/myslite
/function.py
1,267
4.03125
4
#函数的调用 def add(): a,b=12,13 print(a+b) add() #用过的函数 # type() # print() len() # open() int() # float() str() # bool() list() # tuple() dict() # set() #函数的参数 def adds(a,b): print(a+b) adds(a=12,b=2) #调用的函数 # adds(a=13,b=34) # for i in range(1,40): # adds(a=12,b=i) # add(12,13) adds(12,b=13...
0197bce6a32e97761dce10deb57290cb666b78a7
y1212/myslite
/tuple.py
979
4.28125
4
# tuple1=(1,2,3,"hello tom",False) # print(tuple1,type(tuple1)) # list1=[1,2,3,4] # print(list1,type(list1)) # #列表转换 # tuple2=tuple(list1) # print(tuple2,type(tuple2)) # #对元组的遍历索引号 # for i in range(len(tuple1)): # print(tuple1[i]) # #元组遍历 # for element in tuple1: # print(element) # print(len(tuple1)) # print(tu...
8f4d206000d6afc76b72ec6dc1ce87f537d0b17a
Rajadurai02/my_python_programs
/Matplotlib/pie.py
1,203
3.515625
4
import matplotlib.pyplot as plt import numpy as np #using pie #it uses the formula x/sum(x) to draw x = np.array([24,67,86,12]) plt.pie(x) plt.show() #using labels x = np.array([24,67,86,12]) label = ['orange','apple','mango','banana'] plt.pie(x,labels = label) plt.show() #changing angles using startangle x = np....
350a41c340bd45fedd7abe1b50b1fe9f534c8ff5
Rajadurai02/my_python_programs
/multiprocessing/multiprocess.py
408
3.5625
4
import multiprocessing def square(num): square = num ** 2 print("Square is : {}".format(square)) def cube(num): cube = num ** 3 print("Cube is : {}".format(cube)) if __name__ == "__main__": p1 = multiprocessing.Process(target = square,args = (10,)) p2 = multiprocessing.Process(target = cube,args...
52c3ef100de9592cac7a891148ae0af264733c87
Rajadurai02/my_python_programs
/conditional_statements/ternary.py
74
3.640625
4
a=input("enter a number:") text1="logout"if a==0 else"login" print(text1)
4e8e2252adae3a033f4b539a9963e926e9f0e396
yesOrNo123/algorithms
/leetcode/46.全排列.py
700
3.78125
4
""" @Author: yanzx @Date: 2021-08-03 13:51:46 @Desc: 全排列 """ from typing import List class Solution: def permute(self, nums: List[int]) -> List[List[int]]: res = [] def dfs_helper(path): if len(path) == len(nums): res.append(path.copy()) return ...
b7c7383b899c7d7048919eff5e7b74a1d017d232
yesOrNo123/algorithms
/剑指offer/12. 矩阵中的路径.py
1,815
3.875
4
""" @Author: yanzx @Date: 2021-08-03 12:56:12 @Desc: 给定一个 m x n 二维字符网格 board 和一个字符串单词 word 。如果 word 存在于网格中,返回 true ;否则,返回 false 。 单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。同一个单元格内的字母不允许被重复使用。 dfs """ from typing import List class Solution: def exist(self, board: List[List[str]], word: str) -> bool: ...
22dcc7777ee9f221b2cf4104d17b6f867fdc519c
yesOrNo123/algorithms
/leetcode/07. 整数反转.py
882
3.6875
4
""" @Author: yanzx @Date: 2021-07-28 13:44:38 @Desc: 给你一个 32 位的有符号整数 x ,返回将 x 中的数字部分反转后的结果。 如果反转后整数超过 32 位的有符号整数的范围 [−231,  231 − 1] ,就返回 0。 假设环境不允许存储 64 位整数(有符号或无符号)。 """ class Solution: def reverse(self, x: int) -> int: res = 0 if x == 0: return 0 elif x < 0: x_...
e38c73481d25ab08f86713a5de287c74a7f43a3d
Tarrant777/Python_basic
/Calendar.py
1,303
3.578125
4
# encoding: utf-8 year=input("Plz input year:") month=input("Plz input month:") year=int(year) month=int(month) leapyeartimes=year//4-year//100+year//400 monthday=[31,28,31,30,31,30,31,31,30,31,30,31] if year%400 == 0 : monthday[1]=29 leapyeartimes=leapyeartimes-1 elif year%100 == 0: monthday[1]=28 elif ye...
2e9a94b250b80ef56ee75a8fcd96585540abccdb
furikake6000/Python_Enshu1
/ex3.py
173
3.890625
4
yourName = {} yourName['Last'] = input('名前は? >> ') yourName['First'] = input('苗字は? >> ') print('君の名は ' + yourName['First'] + ' ' + yourName['Last'])
12c8deb3096b3114d3caa5ae2b309f77661d5953
rajibgupta01121998/ecm3412-nature-inspired-computation
/main.py
2,673
3.546875
4
from evolution import evolve_bin_packing_solution def run_binpacking_experiment(b1, i1, b2, i2, m, p, n_experiments=5, crossover=True, n_iterations=10000): """Run the evolutionary algorithm a number of times, return the best results. Args: b1: The number of bins in the first bin packing problem ...
6e29c29f32d27aa1e76cc0a3ead78b2b3cca6515
sachlinux/python
/exercise/strings/s3.py
369
4.15625
4
#embedding value in string value = "500" message = "i hav %s rupees" print(message % value) #we can do without variable also print(message % 1000) #more example var1 = "sachin" var2 = "dentist" message1 = "%s: is in love with %s" message2 = "%s is so %s" print(message1 % (var1,var2)) print(message2 % ('she',...
dda1715fa6fc7b8d944c5e13a560aa945f052b69
sachlinux/python
/exercise/strings/s2.py
427
3.546875
4
#if string starting with ' or '' or ''' it must end with the same #u can enter ' and " quotes inside ''' ''' string #but inside ' and " quote string if u want to use quotes use backslash \ single_quote_string = 'hello,"sachin" \'ahirkar\'' double_quote_string = "hello,'sachin'" tripple_quote_string = '''hello, 's...
f547319072c08c23fb7494645b36fb8f125d821a
yudistirans/Fundamental
/Python/04_first_python_app/code.py
128
4.1875
4
your_age = int(input("Enter your age : ")) months = 12 * your_age print(f"Your age is {your_age}, is equal to {months} months")
c9a74ad5885ea02548dc6f3a664738fb01c990f1
Juryun/programmers_coding_test_practice
/크레인인형뽑기게임/solution.py
647
3.53125
4
def solution(board, moves): answer = 0 stack=[] for i in range(len(moves)): move = moves[i]-1 for j in range(len(board[0])): if board[j][move] !=0: if len(stack)==0 : stack.append(board[j][move]) board[j][move] =...
658ec398f352a09390fd9534cb448e2a91bffc9c
debakshmi-hub/Hacktoberfest2021-2
/checkPrime.py
756
4.21875
4
# //your code here # Program to check if a number is prime or not num = int(input("Enter a Number ")) flag = False if num > 1: for i in range(2, num): if (num % i) == 0: flag = True break if flag: print(num, "is not a prime number") else: print(num, "is a prime num...
d4f62443537a9b224e34fccc09411c7428cf0fa9
buribayeva/Learning-Python-the-hard-way
/ex6.py
635
3.921875
4
x="There are %d types of people." %10 #here is interger 10 varuable binary= "binary" #just string do_not= "don't" #another string y="Those who know %s and those who %s." % (binary, do_not) #putting string inside the str print x #printing out x print y #printing out y print "I said: %r." % x # putting str inside str ...
daaaf5ce2ae2376ec06838ce876288b38ce6770a
wozu-dichter/wavelength
/discontinued/BandPowers.py
4,187
3.53125
4
def fft_continuous(data, n=None, psd=False, log='log', fs=None, window='hamming'): """Apply the Fast Fourier Transform on continuous data. Apply the Fast Fourier Transform algorithm on continuous data to get the spectrum. Steps: 1- Demeaning 2- Apply hamming window ...
81da2f1fced9d8119adaba181c50f027af3b9789
William-An/SMSAssignmentSystem
/DataStoreIntoDB.py
594
3.640625
4
import sqlite3 database=sqlite3.connect("StudentsDatabase.db") try: database.execute('''CREATE TABLE Students118(name text,class text,number int)''') except sqlite3.OperationalError as err: print("Table already exists, "+str(err)) tempdatafile=open("database.txt",encoding="utf-8") datatemp=[i for i in te...
4b3574c1b2c3fcbeaf9dd096d9f1b196ab020bc6
epicufscar/workshop-python
/12_recursividade.py
645
4.0625
4
# Exemplo 9: # Fatorial iterativo def fatorial_ite(num): if(num == 0): return 1 else: resultado = 1 for i in range(1, num+1): resultado *= i return resultado # Exemplo 10: # Fatorial recursivo def fatorial_rec(num): if(num == 0): return 1 ...
971105e258afb6dbb579bd081e1e6004c8c70007
sbwiecko/GeMS
/src/api/app_utils.py
774
3.5625
4
def similarity_jaccard(a, b): """ Given two genesets, returns a similarity measure based on the Jaccard coefficient: k(a, b) = (a AND b) / (a OR B) :param a: Set<String> :param b: Set<String> :return: Float """ intersect = len(set.intersection(a, b)) union = len(set.union(a, b)) k = float(in...
fcff968ea5be265612bf1ead1109a4e582ab908b
jakemiller13/Random
/Manning_Classic_Computer_Science_Problems_in_Python/Chapter_1/Ch1_Fibonacci.py
983
3.890625
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 3 13:13:00 2020 @author: jmiller """ from typing import Dict, Generator from functools import lru_cache # NOTE: Infinite recursion def fib1(n: int) -> int: return fib1(n - 1) + fib1(n - 2) def fib2(n: int) -> int: if n < 2: return n return fib2(n -...
8bc1664f33c672f30565a380ece4cc7ebc05fc66
maireadreid/Numerical-Integration
/main.py
4,736
3.859375
4
# importing the modules we need at the top import numpy as np import matplotlib.pyplot as plt import math plt.figure(figsize=[12,12]) # size of graphs in units of inches #Function to give h def h (a, b, n): return (b-a)/(n) #taken directly from formula given in question description #Function to give rectangular ...
4636e3cfdcdc333fdca7d83f1bdeb87606976718
svaithee12/Python
/expression.py
603
3.53125
4
# python program to evaluate expressions eg: 2+4*5-6/2 the output will be 17 t=input() t=int(t) while t : print() k=input().split() i=1 while k[i]!='=' : if k[i] == '+' : k[i+1]=int(k[i+1]) + int(k[i-1]) elif k[i] == '-' : ...
dd4568e48e8172a2fea1c570d230a4ff6577fdeb
shoriwe-upb/LaboratorioFuncionesRemoto
/primo.py
789
4.09375
4
def is_prime(number): if not number: return False number = abs(number) half = number / 2 div = 2 while div <= half: if not number % div: return False div += 1 return True def main(): primes = 0 while True: try: number = int(input(...
4ccd2386c1e8778a1539420ac69e6e9a96598a3b
madulex/pdsnd_github
/bikeshare.py
8,658
4.03125
4
import time import pandas as pd import numpy as np import collections as cl '''The upload of .csv files from source into the editor''' CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } def get_filters(): """ Asks user to s...
fb54c0d63382752c3c9a3feb327321a2c77492cc
gautamk/ProjectEuler
/problem1.py
528
4.25
4
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. MAX = 1000 def mul_of(multiple_of, max=MAX): multiplier = 1 multiple = multiple_of * multiplier while multiple < M...
a5d5c16203d1e1d6ce04e5a1f537152bad43a776
nikkiwong/Comp20230_project1
/Project1/linked_list.py
2,426
4.09375
4
class Node(object): """ A Node in a Linked List """ __next = None __element = None def __init__(self, element=None): self.__next = None self.__element = element def get_next(self): return self.__next def get_element(self): return self.__element...
b1ab21b55ce470dca57aad621c3e35ea5b69b803
505515/coursera
/ProgrammingForEverybody/Week7/assignment5_2.py
607
4
4
loop = True small = None big = 0 def checkint(x): try: x = int(x) return x except: x = 'err' return x while loop == True: number = input('Enter a number: ') if number == 'done': break else: number = checkint(number) if number == 'err': ...
03240c9b0cfb47276c2b5fde90abf9c9059f5f66
505515/coursera
/Python Data Structures/Week3/assignment7_1.py
300
3.90625
4
ifile = input('Enter file name: ') try: ofile = open(ifile, 'r') except: print('Could not find file', ifile) quit() # read file into memory rfile = ofile.read() # strip \n and whitespace in front and end sfile = rfile.strip() # upper case all letters ufile = sfile.upper() print(ufile)
5e28656a95e5819b2fe2e76a699674259d28b94a
505515/coursera
/Python Data Structures/Week4/assignment8_4.py
307
3.609375
4
file = 'romeo.txt' try: ofile = open(file, 'r') except: print('Could not find file:', file) words = [] for w in ofile: wstrip = w.strip() sentence = wstrip.split() for missing in sentence: if missing not in words: words.append(missing) words.sort() print(words)
d99ec0dea524a972d64458c85695d01b51850a08
leoramosa/clases_python
/listas.py
1,098
4.09375
4
#indice 0 1 2 3 alumnos = ["henry","jose","pedro","manuel"] notas = [20,16,17,50] valores = ["juan",True,20.78,50] #diccionarios clientes = {"a100:juan","a200:pedro"} provee = {"prove:[100,200,500]"} #tuplas cursos = ("python","flask","django") # print(type(alumnos)) # print(type(clientes)) ...
84fbc4e1f2f841e2ebc16f7630af943be6af797e
leoramosa/clases_python
/repetitivos2.py
115
3.703125
4
for i in range(1, 20): if i == 10: break else: print("no llego a diez", i) continue
34270d7a395f3e281582406957b53d8ddcd90ffd
leoramosa/clases_python
/diccionario3.py
490
4.03125
4
mi_diccionario ={"bolivia":"la paz","chile":"santiago","uruguay":"montevideo"} #imprime diccionario print(mi_diccionario) #imprimir un valor especifico print(mi_diccionario["bolivia"]) #agregar un valor al diccionario mi_diccionario["peru"]="lima" #modificar un valor mi_diccionario["peru"]="arequipa" print(mi_diccionar...
ee54a02fa566be951154e0ecae0b14d9f0191487
lsh931125/altole
/week5/for2.py
141
3.6875
4
#2. for 변수명 in range(시작값,끝날값 +1) total = 0 for i in range(1, 1001): total += i # total = total + i print(total)
0dd0835e394bf58bdc4982c16e110d60c566f888
lsh931125/altole
/week4/chapter3_for2.py
179
3.515625
4
# range 함수 # 1~ 10 까지 반복 # for 변수명 in range(1,11): # range(시작값,끝나고 싶은값 +1): total = 0 for i in range(1,11): total += i print(total)
e21e0a76b0e7a98737c2f176ea26713ed976e674
lsh931125/altole
/week4/var_number.py
597
3.546875
4
# 변수 var # 변수 = 값 a = 3 b = 2 # 사칙연산 # 플러스 + # 마이너스 - print(a+b) print(a-b) print(a*b) print(a/b) print(a//b) print(a%b) # 팁 : 변수명은 가능하면 명시적으로 만든다. # 변수명을 딱 본순간 어떤 용도인지 어떤 값이 들어가있는지 예측 가능하게 만들면 좋다. # 팁 : 영어의 명사 + 동사 , 영어단어 # 변수명을 만들때 크게 두가지 타입 # ex) updateEvent - 카멜케이스 # update_event - 파스칼케이스 # updateevent - X # ...
eaf294806b4972a953925a1ac50c9ab8a99de884
lsh931125/altole
/week5/for.py
174
3.84375
4
# for - 반복문 # 1. for 변수명 in [리스트값1,리스트값2,...] numberList = [1,2,3,4,5] sum = 0 for number in numberList: sum = sum + number print(sum)
491594e6d11e2aacaa39b52bdc4f3f7c380bac6e
kaushalfeb/Learning-Numpy
/ndarray.py
228
3.875
4
import numpy as np arr = np.ndarray(shape =(5),dtype =int) n = arr.size print("Size is",n) print('Dimension:',arr.ndim) print('Enter %d elements' %n) for i in range(n): arr[i] = int(input("Enter element")) print(arr)
4e3180b1c44289a359d3192b3e04a95ec8aa3d00
Mrafiansyah/pemrograman-beroriensi-objek
/segitigasikusikuterbalik.py
241
4.0625
4
string = "" bar = int(input("Masukkan angka :")) #Looping Baris while bar >= 0: kol = bar # Looping Kolom while kol > 0: string = string + "*" kol = kol - 1 string = string + "\n" bar = bar - 1 print (string)
5975eda02c3f3028037789b40630357a556d518d
Deepanraj79/decorate-self-method
/module1.py
557
3.859375
4
"""Module to perform the basic mathematical operation, Addition and Subtraction of two numbers. """ from log import Logger, track_function_state class AddSub(Logger): def __init__(self, arg1=5, arg2=3): self.arg1 = arg1 self.arg2 = arg2 @track_function_state def add_num(self): ""...
47f71021b0292bcfbf75de2b9538e2e7165a4e7a
has-sidd/Lab-Tasks-in-python-1st-Semester
/Lab 7 (1).py
365
3.75
4
list1 = [(5, 3), (5,8), (6.2, 5.7), (1.1, 8), (3,7)] minimum = min(list1) maximum = max(list1) print("Minimum Tuple is : {0} and Maximum Tuple is : {1}".format(minimum,maximum)) print() co = [(1,1), (10,11), (6,6), (7,8)] for i in co: x = 0 y = 1 if i[x] <= 10 and i[y] <= 10: print(i, ...
7291aa9533a295742aeb44b55ae6109bad7352a1
has-sidd/Lab-Tasks-in-python-1st-Semester
/Lab Task 2(2).py
255
3.703125
4
#Q4 radius = 0.25 speed = 10 av = speed / radius print("Angular speed is : ", av, "radians/second") print() #Q5 radius = 0.2 av = 12.56 time = 10 velocity = radius * av distance = velocity * time print("Distance covered is : ", distance,"m")
732cf21a215a90866a3183cdf24a1a6489011ba8
has-sidd/Lab-Tasks-in-python-1st-Semester
/nth term.py
408
4.03125
4
from math import* def trm(a, d, n): x = a + (d*(n-1)) return x first = float(input("Enter the fist term : ")) diff = float(input("Enter the common difference : ")) cont = input("Do you want to continue, yes/no : ") while cont == "yes": term = float(input("Enter the number of term to generate...
ace27e961772c6afa7ff9fe135f10e7bbfb1f596
deeps-47/stone_paper_sissor_in_python
/STONEPAPERSISSERGAME.py
1,533
4.0625
4
import random print("----------STONE PAPER SISSER GAME----------") List = ["STONE","PAPER","SISSOR"] User=input("Enter \"Start\" to play or Enter \"Exit\" to exist:") comp=0 user=0 while(User!="EXIT"): User=input("Your play:") Computer= random.choice(List) print("Computer Play:",Computer); if(...
803285c8534d518d57a692a2eadf908e7a53e058
adi-nair/Snake-Game
/scoreboard.py
586
3.65625
4
from turtle import Turtle from food import Food class Scoreboard(Turtle): def __init__(self): super().__init__() self.score = 0 self.penup() self.hideturtle() self.color("white") self.goto(0,260) self.update() def update(self): self.clear() ...
b8e683f115e418bfee1e389307415667d1a63ebf
wittyfool/linux_amenities
/xls2csv.py
668
3.703125
4
#!/usr/bin/env python3 import argparse import sys import xlrd import csv parser = argparse.ArgumentParser() parser.add_argument("<xlsfile>", help="specify xls file", type=str) parser.parse_args() #print( sys.argv[0] ) print( "Reading xlsfile: " + sys.argv[1] ) def csv_from_excel(): wb = xlrd.open_workbook( sys.a...
daed36f3c072c907e46fbbf8d966ed967b833f77
Cynthia-Lu0604/python-challenge
/PyBank/main.py
2,625
3.828125
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #The total number of months included in the dataset #The net total amount of "Profit/Losses" over the entire period #The average of the changes in "Profit/Losses" over the entire period #The greatest increase in profits (date and amount) over the entire period #he great...
62c22f35bc1f16af1050ad5fc53b14cc63417ee7
Technology-Development/oop-python
/Refactoring/refactoring_5_inheritance/main.py
461
3.5
4
""" Simulate a simple board game. There are 2 players. Each player takes turn rolling a die and moving that number of spaces. The first person to space 100 wins. """ from game import Game # In PyCharm, mark parent directory as Sources Root for imports to work if __name__ == '__main__': game_1 = Game(num_players=2...
27c52f42084ab41cc9b28efbfeaf924a2bc51112
TommyTours/Bio-Computation-Assignment
/evolution.py
7,706
3.75
4
import random import ann import copy class Individual: # Class to represent Individuals within the population gene = [] # List of real values between gen_upper and gene_lower fitness = 0 gene_upper = None gene_lower = None def __init__(self, upper, lower): self.gene_upper = upper ...
3560ba8fef4169ed5894e0185d702167543ce4ff
JasonArce/UMN
/Projects/Artificial Intelligence (Python + Snake)/CodeAnaysis4/code/problems/csp_problem.py
1,846
3.59375
4
import re import operator from problem import Problem class ConstraintProblem(Problem): # Thanks StackOverflow: # http://stackoverflow.com/questions/1740726/python-turn-string-into-operator operators = { '+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv, '==': op...
5cb43454eb8fee2419ccedf48483000e81130025
JasonArce/UMN
/Projects/Computing & Programming Concepts (Python)/hw1.py
1,088
4.03125
4
def windchill(temp,wind): print(35.74+0.6215*temp-35.75*wind**0.16+0.4275*temp*wind**0.16) windchill(0,10) def computeWC(): temp = input('Enter temperature (F):') wind = input('Enter wind velocity (MPH): ') temp = float(temp) wind = float(wind) print('The windchill is: ') print(windchill(te...
7add06c1c8ff7206a788347dcc2eef13d255dbd3
JasonArce/UMN
/Projects/Computing & Programming Concepts (Python)/shortestDist.py
739
3.71875
4
def shortestDist(x): import math alist=x blist=[] count=1 count2=0 y=1 while len(alist)>0: while len(alist)>count: xcoor1=alist[0][0] ycoor1=alist[0][1] xcoor2=alist[y][0] ycoor2=alist[y][1] if count2==0: val...
1421fcf7e6c0d95b610fddf784ab517ed7db1f96
JasonArce/UMN
/Projects/Computing & Programming Concepts (Python)/findtriples.py
923
3.890625
4
import math def Findtriples(): n=int(input("Enter an upper bound:")) count=0 a=1 b=1 x=1 c=2 retry = 0 while retry<3: if n<10: print("Input error! must be > 10") n=int(input('Enter an upper bound:')) else: while count<=n: ...
29a24b3d702e2fe4169cecebc319b2c455b43bae
arukakibay/ADM-HW1
/MapLambdaFunction.py
198
4.15625
4
cube = lambda x: pow(x,3) def fibonacci(n): # return a list of fibonacci numbers listt = [0,1] for i in range(2,n): listt.append(listt[i-2] + listt[i-1]) return(listt[0:n])
468c16311e65050e9bdbaff196762f708bb3656e
arukakibay/ADM-HW1
/RegexandParsing.py
2,548
3.65625
4
#Detect Floating Point Number # Enter your code here. Read input from STDIN. Print output to STDOUT import re for _ in range(int(input())): print(bool(re.match(r'^[-+]?[0-9]*\.[0-9]+$', input()))) #____________________________________________________________ #Group(), Groups() & Groupdict() # Enter your cod...
6e7fd5f07a8e1d5745a219a2b6c6d7cabca3999f
garibayalberto/Chapman-University-Comp-Sci
/CPSC_230/AGaribay_Assignment2/Seconds.py
418
4.03125
4
# this program should tell the time in a 24 hour clock when given the seconds import math seconds_str = input("Enter the amount of time in seconds" "(The number cannot exceed 86,400):") seconds_int = int(seconds_str) sec_min = seconds_int // 60 hours = sec_min //60 mins = sec_min % 60 sec = secon...
ffef4de8531f38ceb53e7aed98c529d52833c5ae
ari1807/Practica1-python
/run.py
324
3.71875
4
#Quinto desafio print('Ingrese dos cadenas de texto') cadena_1 = input() cadena_2 = input() long_cadena_1 = len(cadena_1) long_cadena_2 = len(cadena_2) if (long_cadena_1 > long_cadena_2) : print(cadena_1) elif (long_cadena_2 > long_cadena_1): print(cadena_2) else: print('Ambas cadenas tienen el mismo taman...
2d3d89a4834001db03c89c7498ed2c3a31a23f3f
varunn807/Coding-Exercise
/lengthofLastWord.py
678
3.671875
4
class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ dummy=s res=0 words=[] if dummy.replace(' ',"")=='': return 0 splits=s.split(' ') for word in splits: if word...
a83445878203f0262ab3ae9b04c750135ed80bd1
varunn807/Coding-Exercise
/searchInsert.py
1,459
3.765625
4
class Solution(object): def searchInsert(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ if len(nums)==1: if nums[0]==target: return 0 start=0 end=len(nums)-1 if targe...
d6c6af1499216a91843a93374b4ccccf29ac4a99
varunn807/Coding-Exercise
/UniquePaths.py
558
3.640625
4
class Solution(object): def uniquePaths(self, m, n): """ :type m: int :type n: int :rtype: int """ # grid=[[0]*m]*n grid=[[0 for i in range(n)] for j in range(m)] for i in range(m): grid[i][0]=1 for b in range(n): ...
47b4d90bfb4b2f24d2fb09b3a4e65e2578d6c107
varunn807/Coding-Exercise
/RotateLinkedList.py
944
3.765625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ ...
82ab63006c1a2b51154022884dd54864bd33d7ef
varunn807/Coding-Exercise
/isToeplitzMatrix.py
495
3.5625
4
class Solution(object): def isToeplitzMatrix(self, matrix): m=len(matrix) n=len(matrix[0]) for i in range(1,m): for j in range(1,n): if(matrix[i][j]!=matrix[i-1][j-1]): return False return True """ :t...
c56eb0859ef72809e34913550c77e245e5e5c473
Buvaneshwari-m/ev
/ev.py
134
4.125
4
j=int(input("Enter the number")) if j%2==0 and j>0: print("Even") elif j%2==1 and j>0: print("Odd") elif j<=0: print("invalid")
ab968de3cb5438c68bf5de8a004a8a0f98502280
kenneth-nguyenn/Using-range-color-for-finding-shape-in-image
/Finding_Shapes_in_range_color.py
787
3.5
4
import numpy as np import imutils import cv2 # load the image image = cv2.imread("finding_shapes_example.png", cv2.COLOR_BGR2HSV) w, h = image.shape[:2] image = cv2.resize(image, (h*2, w*2)) # find all the 'black' shapes in the image lower = np.array([0, 0, 0]) upper = np.array([15, 15, 15]) shapeMask = cv2...
2df58ceb51acfc29514d7366070b28cdc695f1d0
CameronDennis/sudokuInPy
/sudoku.py
6,202
3.84375
4
#Sudoku #How should a board be represented? #list of lists #board = [r1, r2, ...] #efficiency #check for 8s #Define Functions #Initial Create def createBoard(r0, r1, r2, r3, r4, r5, r6, r7, r8): #different things later board = [r0, r1, r2, r3, r4, r5, r6, r7, r8]; return board def createNBoard(board...
eebd933f8213bb988b74a222bd603855aecf5a0d
singegow/PythonBasics
/function_returns_values.py
435
3.96875
4
def square(input_num): return input_num * input_num result = square(3) print(result) print(square(4)) # If the funciton doesnt return any value then python by default uses # return None # None represents the absent of a value def rect(input_num): print("The value passed to the rectangle:" + str(input_num)) ...
25d829af7705a3058347c03f017a02825dcd08e9
singegow/PythonBasics
/car_game.py
1,405
4.03125
4
# user_input = "" # # while user_input.lower() != "quit": # user_input = input("> ") # if user_input == "help": # print("Displayng helath mendu") # elif user_input.lower() == "start": # print("Car started") # elif user_input.lower() == "stop": # print("car stopped") # else: #...
9fc019152feb3cbf0df28415365215e03f4beb19
singegow/PythonBasics
/operator_precedence.py
184
3.84375
4
print(10 + 3 * 2) print(10 + ( 3 * 2)) # Order of precedence # parenthesis # exponentiation 2 ** 3 # multiplication or division # addition or subtraction x = (2 + 4) ** 2 * 3 print(x)
7bf09489819f0775d5af7231c685e9c6c8c87476
TataSatyaPratheek/AlgoToolbox
/grouping_points.py
813
4
4
""" you have a finite set of points given to you, you have to find a way to group them in such a way that for any two members of a group, their distance is not more than a unit, with the least number of groups. """ def greedy_grouping(given_points): #part one of the solution, sorting the elements monotonically ...
18456133f662e52895de8c9022af574959b4800b
priyanka-karn/Typing-speed_test-game
/Typingspeed.py
2,897
3.515625
4
words=['Grapes','Mango','Apple','door','Laptop'] def labelSlider(): global count,sliderwords text='welcome to typing speed increaser game' if(count>=len(text)): count=0 sliderwords ='' sliderwords=sliderwords+text[count] count+=1 fontLabel.configure(text=sliderwo...
54630a976756ee2f089cbc9b04685c6282b1b2f9
peaceandiago/TRIEC_project
/PycharmProjects/TRIEC_data_analysis/comparing_csv_files_outcome_mentees.py
7,321
3.84375
4
""" This program aims to answer the question "Compare mentee occupation to employee outcome - do some occupations have better outcomes?" -this needs to compare two rows from each csv to make sure it is the same row - then take the necessary rows for data analysis """ import csv import datetime def MenteeInformation():...
a25485b1ac13e4cd720d5e254156f0da5e3650b9
Bobbygirl/Algorithm
/paixu/Paixu/shellSort_test.py
422
3.703125
4
""" 希尔排序 """ def shellsort(alist): gap=len(alist)//2 while gap>0: for i in range(gap,len(alist)): j=i temp = alist[i] if j>=gap and alist[j]<alist[j-gap]: alist[j]=alist[j-gap] j=j-gap alist[j]=temp gap=gap//2 ...
3d73f43d003a10d6218b07bf1bf7278a205ffa55
Bobbygirl/Algorithm
/paixu/sousuo/Hashtable.py
1,847
3.765625
4
""" 散列表:使用+1线性探测法 hashfunction:散列值 rehash:寻找下一个槽 put(key,data)添加数据 get()获取数值 def __getitem__(self,key):可使用[]访问数值 def __setitem__(self,key,data):可使用[]添加数值 """ class HashTable: def __init__(self): self.size=11 self.slots=[None]*self.size self.data=[None]*self.size def hashfunction(self,key...
70702decfd108efc218ef689ed3952290798251f
Bobbygirl/Algorithm
/paixu/Paixu/shellSort.py
982
3.6875
4
""" 希尔排序:是插入排序的改进 """ # def shellSort(alist): # sublistcount=len(alist)//2 # while sublistcount>0: # for startpos in range(sublistcount): # gapInsertionSort(alist,startpos,sublistcount) # sublistcount=sublistcount//2 # return alist # # # def gapInsertionSort(alist,start,gap): # ...
038bbadefb8ccaaf28176a9be0fdcb135beed703
ben-64/led_matrix
/led_matrix/animation/matrix.py
2,231
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Credit: https://github.com/gineer01/matrix-rain/blob/master/matrix.py import random import time from led_matrix.animation.animation import Animation #How fast the rain should fall. In config, we change it according to screen. FALLING_SPEED = 2 #The max number of fall...
557b663c4b352b35ea5e8eb57d8020c4a72b1960
scofield1991/tasks
/piechart.py
1,423
4.0625
4
__author__ = 'user' from turtle import * from collections import defaultdict import random def counter(txt): d = defaultdict(int) words = txt.split() for word in words: d[word] +=1 dict_words=dict(d) len_txt=len(words) for word in dict_words: dict_words[word] = round(float(di...
e76dad4423a5210048eb85748040778544cd609a
mainiwaer/hb-guessing-game-redo
/game.py
1,862
4.0625
4
"""A number-guessing game.""" from random import choice def get_user_name(): """Greet player and return their name input.""" return input("Howdy, what's your name? > ") def replay_game(name, best_score): """Prompts user to play again after completing a round of the game.""" replay_prompt = input("W...
8eafbb1accae94addf5bfb52fb9781b04d363f59
flyyuyuan/pythonlearn
/PythonTest/wiki.py
480
3.609375
4
# -*- coding:utf-8 -*- from urllib.request import urlopen #from urllib.request import Request #from urllib import parse from bs4 import BeautifulSoup import re resp = urlopen("https://en.wikipedia.org/wiki/Main_Page").read().decode("utf-8") soup = BeautifulSoup(resp,"html.parser") data = soup.find_all("a",href=re....
18d3c8b8ed5b72f22cc12dcd2d81b83f85e9c622
DaveshSharma/test_repo
/try1.py
506
4.03125
4
#def func_generator(n): # for i in range(n): # yield (i**3) #for x in func_generator(5): # print (x) #def string_generator(n): # for i in xrange(n): # yield (i) #for y in string_generator(101): # print (str(y)) # print (type(y)) # y=a #z=''.join([`x` for x in xrange(101)]) #print z #print (type(z)) #def square(x): #...
74a511b406682ca225814f944bf7a67344b449a1
hilaryonianwa/MY-CODING-FILES
/words from word done.py
1,339
3.609375
4
ask_word=input('Input a word: ').lower() a=list(ask_word) space=[' ',' ',' '] List=['it','by','go','they','on','to','boom','boxer','lame','board','bit','board','game','rain','battery','at','pat','pit','come','shift','one','pill','kneel','off','of','time','gene','dim','heat','bear','dog','run','ten','tell','or','a...
250aaa13de0944d78fc6f7a6083c5413ea1961e5
KhallilB/Tweet-Generator
/Code/practice_code/sampling.py
1,731
4.125
4
import random import sys import histograms def random_word(histogram): '''Generates a random word without using weights''' random_word = '' random_index = random.randrange(len(histogram)) random_word += histogram[random_index][0] return random_word def weighted_random_word(histogram): '''Gen...
40154e037f45f9a9c5983660385fff7ee3da90f9
voutilad/udacity-project1
/media.py
3,186
3.515625
4
# -*- coding: utf-8 -*- """ This module defines the `Movie` class for use in Project 1. """ _DEFAULT_POSTER_URL = 'Fox_movietone_2.jpg' _DEFAULT_TRAILER_URL = 'https://www.youtube.com/watch?v=5uZr3JWYdy8' class Movie(object): """ Represents a movie for display in the Fresh Tomatoes web application Attr...
65c92e42407e5fee4babff617cb9145ffa50f6c7
sumnerevans/wireless-debugging
/server/helpers/util.py
601
3.765625
4
""" Utility Functions """ import json from datetime import datetime def serialize_to_json(data): """ Serialize an object to JSON, ensuring that the datetimes are formatted according to RFC 3339. Args: obj: the object to serialize to JSON """ # Define the actual datetime serializer # ...
ed31ad710ae70b9439616aa3eacdf1ea1346c74e
Jessyka/primeiros-exercicios-python
/exercicios/3_equacao.py
593
3.859375
4
from math import sqrt def delta(a, b, c): return (b ** 2) - (4 * a * c) def primeira_raiz(a, b, c): dividendo = (-b) + sqrt(delta(a, b, c)) divisor = 2 * a return dividendo / divisor def segunda_raiz(a, b, c): dividendo = (-b) - sqrt(delta(a, b, c)) divisor = 2 * a return dividendo / div...
31e1846565d2eb0a0bdaee3b8c775bcb5dc09b83
qcl643062/leetcode
/8-String-to-Integer.py
1,871
3.53125
4
""" Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You are responsible...
79ec249c78604d85bf5612da0d597d41c39214e3
qcl643062/leetcode
/110-Balanced-Binary-Tree.py
1,730
4.15625
4
#coding=utf-8 """ Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. """ class TreeNode(object): def __init__(self, x, left = None, right = None): ...
9bb50043c7796a099cc0415571431064891e8fdc
qcl643062/leetcode
/141-Linked-List-Cycle.py
890
3.890625
4
""" Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? """ class ListNode(object): def __init__(self, x, next = None): self.val = x self.next = next class Solution(object): def hasCycle(self, head): """ :type head: Li...
1ff567ef527146768a285cf5059b2db46aed3625
qcl643062/leetcode
/16-3Sum-Closest.py
1,605
3.921875
4
""" Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. For example, given array S = {-1 2 1 -4}, and target = 1. The sum that is closest to the t...
aeda5a238a884df192001a687ddac16a58e92344
qcl643062/leetcode
/56-Merge-Intervals.py
1,404
3.96875
4
""" Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. """ class Interval(object): def __init__(self, s=0, e=0): self.start = s self.end = e class Solution(object): def merge(self, intervals): "...
459e4c4da4c862346a206d92561a7d0c58295a6c
qcl643062/leetcode
/64-Minimum-Path-Sum.py
912
3.828125
4
""" Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time. """ class Solution(object): def minPathSum(self, grid): """ :type grid: List...
54e75aafb08425d7d8f7e78adf9b6f148a936e88
312080367/TallerDeHerramientasComputacionales
/Clases/Clases/Programas/Ulam.py
973
3.765625
4
def paridad(x): # if x/2 == d and 2*d == x : # return(si) # else: # return(no) #def sucULAM(x): # a = x/2 # b = 3*x+1 # while : # if paridad(si): # print(a) # else : # print(b) def ulam(x): #if (x/2)*2-x== 0:(tambien se puede usar esto) if ...
d70adc828b0f2c748ffa56d4d55984ddf0188aee
ArpitSharma2800/leetcode_arpit
/addTwoNumber.py
1,070
3.90625
4
# You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. # You may assume the two numbers do not contain any leading zero, except the number 0 itse...
efcc5f732ed3571af8aa6f04a38e2b2a64fe832e
elenaryan/QuoridorPy
/quoridor.py
1,206
3.546875
4
import sys from QuorBoard import GameBoard ''' Quoridor driver. Takes as input a file of (HOPEFULLY) valid quoridor moves splices them into moves and then updates the game board. At present we're working pulling the moves into something the updateFunction will understand and be able to check...
84fb89787f80198ac98f5ed9fd08a7e4cf545b75
sivashanmugamo/Computer-Vision
/Edge & Character detection/Character Detection.py
3,801
4
4
""" Character Detection The goal is to find all of the coordinates where a specific character appears using template matching. There are 3 sub tasks: 1. Detect character 'a'. 2. Detect character 'b'. 3. Detect character 'c'. """ import argparse import json import os import utils from task1 import * def parse_args(...
1f1529473302b02d543365662b5ea486c153d200
EngrDevDom/Everyday-Coding-in-Python
/ToLeftandRight.py
422
4.125
4
# ToLeftandRight.py nums = [] num_of_space = 0 current_num = int(input("Enter a number: ")) nums.append(current_num) while True: num = int(input("Enter a number: ")) if num > current_num: num_of_space += 1 elif num == current_num: continue else: num_of_space -= 1 current_num = num nums.a...
a2f10d28828b2fe43054860554e2915bbe1a3e13
EngrDevDom/Everyday-Coding-in-Python
/Distance.py
379
4.25
4
# File : Distance.py # Desc : This program accepts two points and determines the distance between them. import math def main(): x1, y1 = eval(input("Enter first coordinate.(x1, y1): ")) x2, y2 = eval(input("Enter second coordinate.(x2, y2): ")) distance = math.sqrt((x2-x1)**2 + (y2-y1)**2) pri...