blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
69e5a631bd60c020499e7d5eda95bb63bb5430a3
cfcmarc/PythonSandbox
/coinflip.py
844
3.875
4
import random heads = 1 tails = 0 valid_guesses = [heads, tails] correct_statement = "Correct! The coin flip landed " incorrect_statement = "incorrect! The coin flip landed " guess_list = [] coin_flip_otcme = random.randint(0,1) for guess in valid_guesses: def coin_flip(user_guess): if coin_flip_otcme == us...
fe718d73634e8fa02f5064aaeecfac26edafa6c0
joelmontpetit/us-states-game-start
/main.py
1,964
3.796875
4
import turtle import pandas screen = turtle.Screen() screen.title("U.S States Game") image = "blank_states_img.gif" screen.addshape(image) turtle.shape(image) data = pandas.read_csv("50_states.csv") all_state = data.state.to_list() guessed_states = [] while len(guessed_states) < 50: answer_state = screen.textinp...
d96abaa8b65525a7a3cea60f6e224ac6e2e939f3
fergatica/python
/rubiks_cube_contest_average.py
539
3.953125
4
def list_function(): my_list = [] for i in range(5): x = float(input("Enter the time for performance " + str(i+1) + ": ")) my_list.append(x) i += 1 my_list.sort() my_list = my_list[1:-1] return my_list def main(): my_list = list_function() index = 0 total = 0...
48090935c800fcf07ff12597adc8d943a9fbcfc0
byfuls/python
/namedtuple/namedtuple-dict.py
982
4.125
4
from collections import namedtuple class data: def __init__(self, name): self.__name = name; self.__value1 = 1; self.__value2 = 2; @property def name(self): return self.__name @property def val1(self): return self.__value1 @property def val2(self): ...
836898b7409c3b83c17c2d471d8c759853bf30e7
gajanlee/leetcode
/python/840. Magic Squares In Grid.py
1,297
4.1875
4
""" A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Given an N x N grid of integers, how many 3 x 3 "magic square" subgrids are there? (Each subgrid is contiguous). Example 1: Input: [[4,3,8,4], [9,5,1,9],...
2bff1ef8bddbd0ac6c7d77982e2b03fa6cd42c71
lanl/BEE
/beeflow/data/cwl/cwl_validation/ml-workflow/machine_learning/read_dataset.py
1,054
3.546875
4
"""Read Data Set.""" import pickle import click # import json import pandas as pd # import numpy as np # from sklearn.linear_model import LinearRegression @click.command() @click.argument('y3', type=str) # y3 is the input argument for path to dataset def reader(y3): """Reader.""" dataset = pd.read_csv(y3) ...
53a0b8fb02bb3f556aeaa7182d41c558fefa2479
jsonw99/transfer_learning_inceptionv3_shoes
/download_image.py
2,178
3.59375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import os import urllib.request import sys import getopt ''' the script may read the url lists from the directory ./imageUrl . and download the images to corresponding folders within the directory ./imageDownload . ''' def main(total_number, size): url_dir = "./imageUr...
dd24745bd07c3a47a73133546e2095ff00792808
AndrePina/Python-Course-Work
/factorial.py
167
3.96875
4
def factorial(n): result = 1 for x in range(1,n): result = result + (result * x) return result for n in range(0,10): print(n, factorial(n ))
c792fcf3b9f86cdbd19fa9f8129aaf3be618dca0
simongarisch/pxtrade
/tests/test_strategy2.py
4,212
3.765625
4
""" Here we test a basic strategy that includes an indicator and FX rate movements. We'll start with an ($100K) AUD denominated portfolio and buy 100 shares of SPY only if the VIX < 26. Also, buying in SPY will make us short USD. Generate funding trades, to be executed the day after we buy SPY, so that we aren't shor...
22266770a90936862cd11fd0d7a00c641c8f4426
davidstaab/AOC17
/04_passphrase.py
1,490
3.6875
4
# series of all-lower chars # sep='\s' # no duplicate words if __name__ == '__main__': with open('./passphrases.txt') as file: unique_ct = 0 no_perm_ct = 0 for line in file: words = line.rstrip().split(sep=' ') # Remove '\n' from `line` so it doesn't show up in words[-1] ...
1d014995f0751a956ec713efdbdc5767035f226f
17PcNani/Nani-Python
/largeststring@task-8.py
276
4.125
4
str1=input("Enter first string:") str2=input("Enter second string") count1=0 count2=0 for i in str1: count1+=1 temp1=count1 for i in str2: count2+=1 temp2=count2 if temp1>temp2: print("str1 is larger") else: print("str2 is larger")
aaa5643d5667ae6676f738daa41a03b60ee9c644
Raul92x/University
/512/midterm/midterm_toh.py
7,678
3.6875
4
# midterm_toh.py # Kerstin Voigt, Nov 2014; to be used for CSE 512 midterm; import copy import random # some global variables ... MAXNODES = 10000 # MIDTERM (possibly having something to do with # the size of the toh problem) TOH = 5 TOHTW = range(TOH+1)[1:] TOHTW.reverse() # do not change def init_toh(): toh = ...
f988c50d7c150c78b5386dd396b219b73c0f0ae0
Adegbenga1/Election_Analysis
/Pypoll.py
6,436
4.09375
4
import csv import os # Add a variable to load a file from a path. csvpath = os.path.join("Resources","election_results.csv") # Add a variable to save the file to a path. txtpath = os.path.join("Analysis","election_analysis.txt") #Initialize a total vote counter. total_votes = 0 # Candidate Options and candidate...
c702972a71a9d07fcc3042b3ff29d72294bb1180
JeongHanJun/BOJ
/Python 3 PS Code/BOJ/11050.py
534
3.53125
4
# 11050 이항 계수 1 # math 모듈의 factorial 이용하는 방법 ''' from math import factorial n, k = map(int, input().split()) print( factorial(n) // (factorial(k) * factorial(n-k)) ) ''' # math module 사용하지 않고 dp로 이항계수 값을 구하는 방법 def com(n, k): if k == 0 or k == n: return 1 if dp[n][k] != 0: return dp[...
19d011763478abd3458a5d5833bc86e46e607a44
candytale55/lambda-challenges-Py_3
/ends_in_a.py
256
4.03125
4
# named ends_in_a takes an input str and returns True if the last character in the string is an a. Otherwise, return False. ends_in_a = lambda string : string[len(string)-1] == "a" print ends_in_a("data") # True print ends_in_a("aardvark") # False
29c5fc8094e5a2109a22b3c408e35cdb0d14e255
majard/prog1-uff-2016.1
/Trapezium.py
212
3.890625
4
a = eval(input('A: ')) b = eval(input('B: ')) c = eval(input('C: ')) if a > 0 and b > 0 and c > 0: area = (a + b) / 2 * c print('The area is', area) else: print('All numbers must be positive!')
af6caac8b4345546a1c970ade1714f41daf7278e
mooksys/Python_Algorithms
/Chapter32/file_32_4_1.py
382
3.71875
4
ROWS = 5 COLUMNS = 7 a = [ [None] * COLUMNS for i in range(ROWS) ] for i in range(ROWS): for j in range(COLUMNS): print(i, ",", j, "의 요솟값을 입력하여라: ") a[i][j] = float(input()) for i in range(ROWS): for j in range(COLUMNS): if a[i][j] != int(a[i][j]): print(i, ",", j, "위치에서 실...
12c9999006b101433c091630d1182d7b7c4b4652
HarshadGare/Python-Programming
/Operators/06 Identity.py
55
3.8125
4
a = '5' z = a is 5 print(z) y = a is not 5 print(y)
c2a2fee06ea493a9cebcbe846fba4da28db57e68
ant642507com/my-python-foundation
/investigate texts and calls/ZH/Task2.py
3,603
3.75
4
""" 下面的文件将会从csv文件中读取读取短信与电话记录, 你将在以后的课程中了解更多有关读取文件的知识。 """ 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) """ 任务2: 哪个电话号码的通话总时间最长? 不要忘记,用于接听电话的时间也是通话时间的一部分。 输出信息: "<telephone number>...
1a06130f73292c6edf9fb953196917c056388544
rollersteaam/maths-graphs-and-all-things-holy
/src/Section1.py
849
3.953125
4
# This is done as a convention! 'np' is just easier to refer to then 'numpy' all the time. import numpy as np # Note here that I use 'one' and 'three'. Your variables in Python can't start with a number, such as '1'. one_dimensional_matrix = np.array([1, 5, 9]) print(one_dimensional_matrix) one_dimensional_matrix = o...
6cc52832b6bad48b57c0c7f85a70052c15b7ba4d
AndrewWei-Colosseum/basic-algorithms
/stack_and_queue..gyp
194
3.765625
4
queue1 = [1,2,3,4,5,6] queue2 = [1,2,3,4,5,6] # FIFO, the functionality of queue. called queue. print(queue1.pop(0)) # LIFO, like the stack, even though the name is queue. print(queue1.pop())
1934b5ad7966c2cbb647fcdaf04f430a883416ce
oarthurvictor/codigos
/Python/Atividade 2 - Salarios e Abonos - Arthur Victor.py
999
3.71875
4
#Aluno: Arthur Victor recebe_salarios = [ [],[] ] teste = 1 while teste != 0: teste = float(input("Digite o salário: ")) if teste != 0: recebe_salarios[0].append(teste) if (teste*0.2) >= 100: recebe_salarios[1].append(teste*0.2) else: recebe_salarios[1].append(100) print ('\nSalário...
65dd7cde04cf127dfc4d4d1b0fb8e29f56a3eae7
DevNathanM/Python-IA
/IA-py/aula.py
464
3.796875
4
#-*- coding: utf-8 -*- from math import sqrt #a = input("Digite o valor para A:") a = float(input("Digite o valor para A = ")) b = float(input("Digite o valor para B = ")) c = float(input("Digite o valor para C = ")) b2 = b**2 delta = b2-(4 * a * c) try: raiz_quadrada = sqrt(delta) x1 = (-b - raiz_quadra...
524db43cbbedee998719e2b67b7aada85c88c28d
Aasthaengg/IBMdataset
/Python_codes/p03738/s026660485.py
238
3.765625
4
# import sys input=sys.stdin.readline def main(): A=int(input()) B=int(input()) if A>B: print("GREATER") elif A==B: print("EQUAL") else: print("LESS") if __name__=="__main__": main()
9c1945ceda4f1205cc35136d0e2fb3be01d94ed9
effectivemadness/ct_exercise
/H-index/solution.py
940
3.578125
4
# def solution(citations): # answer = 0 # max_ci = -1 # print(sorted(citations)) # citations = sorted(citations) # # for i, value in enumerate(citations): # # if len(citations) - i >= value and max_ci < value: # # max_ci = value # for i in range(len(citations)): # if ...
faa0d36ba2dae19a09d88d71b5b52a2db48989f6
Wakeel03/Sudoku-Solver-using-Backtracking
/main.py
3,485
4.25
4
### The SUDOKU Solver Using Backtracking ### #This is the sudoku to be solved sudoku = [[5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6...
031ffcb495a4bde563feaac9327a4768c0a8fb90
weronikaolejniczak/porter-stemmer
/porter stemmer/stemmer.py
2,429
3.53125
4
import re import tools import pandas as pd # FILENAME = "tests/test1.txt" # FILENAME = "tests/test2.txt" FILENAME = "tests/test3.txt" CSV_FILE = "data/stems.csv" def clear_file(filename): open(filename, 'w').close() def print_table(filename): column_names = ["word", "stem", "inflection", "steps_taken", "p...
179e0f161624e011a55f15f614ceff75419f11d1
jjcrab/code-every-day
/day22_lengthOfLastWord.py
532
4.09375
4
# https: // leetcode.com/problems/length-of-last-word/ # Given a string s consists of some words separated by spaces, return the length of the last word in the string. If the last word does not exist, return 0. # A word is a maximal substring consisting of non-space characters only def lengthOfLastWord(s): # list...
b5486a5435c06fe395dae36a31408a0499c26659
TheoBafrali/UAVSAR-MIT-1
/Python/FastLinInt.py
3,913
3.5625
4
''' Performs backprojection using Numpy operations to generate SAR image. Plots in logarithmic and linear scale. @author: David + Mason ''' #Import required modules import matplotlib.pyplot as plt import numpy as np from numpy import real, arange, reshape def FastBackProjection(aligned_data,radar_data,Left...
fe23b414ed79492df7923e775890038f909abb1a
schatfield/StudentExercises
/reports.py
4,471
4.09375
4
import sqlite3 from student import Student from cohort import Cohort from exercise import Exercise class StudentExerciseReports(): """Methods for reports on the Student Exercises database""" # function definition to create a student, # def create_student(self, cursor, row): # return Student(row[...
5cef1fd9a1f080c2f7509d43bfc5ce6140b2335c
RyujiOdaJP/python_practice
/ryuji.oda19/week01/c15_random_loop.py
122
3.71875
4
import random GivenNumber = input('Enter a number: ') for i in range(int(GivenNumber)): print(random.randrange(0, 2))
a105646b1642988f469d1facad8ccf4972a8655e
kBarbz/jotto
/data management scripts/create-isos.py
1,030
3.578125
4
import sys def main(): iso = [] try: with open("portuguese-dict.txt", "r") as file: line = file.readline() while line: if is_isogram(line): iso.append(line) line = file.readline() except IOError: sys.exit("Could n...
bc0e561dd7abb6688bcc71511281bfa5a6198b16
benbendaisy/CommunicationCodes
/python_module/examples/839_Similar_String_Groups.py
2,259
4.3125
4
from typing import List class UnionFind: def __init__(self, n): self.parent = list(range(n)) self.rank = [0] * n self.cnt = n def find(self, x): if self.parent[x] != x: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def union(self, ...
8406d7f34995d59f3a60e42e87a4ef07869494bb
swapnilnandedkar/Python-Assignment
/Assignment3/Assignment3_3.py
650
4.0625
4
# 3.Write a program which accept N numbers from user and store it into List. Return Minimum # number from that List. # Input : Number of elements : 4 # Input Elements : 13 5 45 7 # Output : 5 import functools def main(): List = [] print("Enter total number you want to insert in List") li...
1234f6dda89db3be30779baf792e5e14464ad397
care1e55/algotithms
/fibo.py
220
3.875
4
def fibo(n): f = 1 f1 = 1 f2 = 1 for i in range(1, n+1): if i < 3: continue else: f = f1 + f2 f2 = f1 f1 = f print(f) fibo(int(input()))
45871078e6275f635d4d4f8245213aaf40448dc3
JohnBomber/mon_python
/Chapitre 12 - exercice 2.py
194
3.578125
4
import math class Circle(): def __init__(self, r): self.rayon = r def area(self): print((self.rayon ** 2) * math.pi) cercle1 = Circle(5) Circle.area(cercle1)
fcfcd915ada057bb6fedaf9ed0441a4eaafe3aa5
ealmestica/CS-200
/Sorting_Movie/Lab6-Sorting_Movie.py
2,346
4.15625
4
# SNHU - CS200 # Elijah Almestica # Program name: Sorting Movie # Dictionary of movie collection Movie_Collection = { 1:[2005, 'Munich','Steven Spielberg'], 2:[2006, 'The Prestige','Christopher Nolan' ], 3:[2006, 'The Departed', 'Martin Scorsese'], 4:[2007, 'Into the Wild', 'Sean Penn'], 5:[2008, 'The Dark K...
c25ffbbb04479a63aedfcb18bb81b3eda1475e45
Lackman-coder/tkinter_projects
/agecalculatortk.py
1,229
3.90625
4
from tkinter import * from datetime import * root = Tk() root.geometry("700x500") root.title("age calculator") photo = PhotoImage(file="/sdcard/python_projects/tkinter_proj/calc.png") myimage = Label(image = photo) myimage.grid(row=0,column=1) def calculateage(): today = date.today() birthdate = date(int(Yearentr...
391f73ca36e99f7fa9b316abeeac27e84ef7fcc5
VitalyVorobyev/MultibodyAnalysisTools
/examples/linear_fit_l2.py
2,388
3.828125
4
#! /usr/bin/python2 """ # L2 regularization tutorial # Based on tutorial 8.1 from # http://ipython-books.github.io/cookbook/ """ import numpy as np import scipy.stats as st import sklearn.linear_model as lm import matplotlib.pyplot as plt plt.style.use('seaborn-white') plt.rc('font', size=26) plt.rc('text', use...
4abc2e9967d5cc38f54b3cbb1185a5be954dc7ff
AAAKgold/My-test
/python/py_pr/hj黄金分割法.py
1,208
3.6875
4
#黄金分割法确定单峰函数在区间的极小点 import numpy as np import matplotlib.pyplot as plt import math #定义目标函数 def func(x): return pow(x,4)-14*pow(x,3)+60*pow(x,2)-70*x #print(func(1)) #for test #def func(x): # return pow(x,3)-2*x+1 #定义主函数 黄金分割法计算 def main(a0,b0,l):#区间和精度 global x_opt global f_opt global k #初值...
cd5dbaf0a9eb9362f095e89ae72c2d0976827cbf
rohanaggarwal7997/terrier
/script/testing/oltpbench/reporting/utils.py
341
4.15625
4
#!/usr/bin/python3 def get_value_by_pattern(dict_obj, pattern, default): """ This is similar to .get() for a dict but it matches the key based on a substring. This function is case insensitive. """ for key, value in dict_obj.items(): if pattern.lower() in key.lower(): return val...
a632f98a04cb0c1f2102678bfc729c5509a55b0e
bairaju/accumulator
/convolution.py
412
3.578125
4
import matplotlib.pyplot as plt import numpy as np n=input("enter x length:") k=input("enter h length:") x=[] for i in range(n): z=input("enter elements:") x.append(z) print(x) h=[] for i in range(n+k-1): b=input("enter elements:") h.append(b) print(h) s=0 a=[] for i in range(n+k-1): for j in range(n): s=s+((x...
9a9df25bdcaafb88a54b87369b2eb529550bcfff
vineettiwari456/mnstr_projects
/machine learning/Machine_LearningPractice/Part 2 - Regression/Section 5 - Multiple Linear Regression/pract_multi.py
730
3.65625
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt dataset = pd.read_csv("50_Startups.csv") X = dataset.iloc[:,:-1].values y = dataset.iloc[:,4].values # print(y) from sklearn.preprocessing import LabelEncoder, OneHotEncoder X_labelencoder = LabelEncoder() X[:,3] = X_labelencoder.fit_transform(X[:,3...
4c5887d63982a6c4e7f46f4a516afc5fa82c396b
andre2w/webserver
/server/request_parser.py
1,739
3.5625
4
def parse_request(request): """Parse the entire request request to a dict""" request_lines = request.split('\r\n\r\n') # Get the first line with the request info # and parse the rest has headers header_lines = request_lines[0].split('\r\n') request_info = __parse_request_info(header_line...
9675c151f85d9f85ccf62ffeae4ff4bc43f73000
aidan-coward/python
/learn-python/ex33-1.py
256
3.875
4
numbers = [] def while_loop(x, y): for j in range(0, x + 1): print "At the top i is %d" % j numbers.append(j) j = j + y print "Numbers now: ", numbers print "At the bottom i is %d" % j print while_loop(20, 4)
5d81fc53bb3414cb48ee8396965dcd8b3ab9fda0
JamesGilsenan/Python-3
/Function_Arugments/Project_The_Nile.py
1,825
3.5625
4
from Nile import get_distance, format_price, SHIPPING_PRICES from Test import test_function from Test import Driver from Test import Trip def calculate_shipping_cost(from_coords, to_coords, shipping_type="Overnight"): from_long, from_lat = from_coords to_long, to_lat = to_coords #distance = get_distance(*f...
09b8f18a72e0f28be0dfaf740567f0aa510001e8
marksikaundi/python-Overview
/func.py
1,042
4.03125
4
#function execution in python #user_input calculation_to_units = 24 name_of_units = "hours" def days_to_units(num_of_days): print(f"{num_of_days} days are {num_of_days * calculation_to_units} {name_of_units}") user_input = input("hello can you enter something!\n") print(user_input) calculation_to_units =...
0600c50ef90ae1c0ab1dbf70d926ae36297ca2f7
amandamorris/codewars
/memoized_fib.py
300
4.03125
4
def fibonacci(n): """Returns the nth fibonacci number, works for large n""" fibs = [0, 1] # start with first two numbers, stored in fibs for i in range(2, n+1): # for each successive number fibs.append(fibs[i-1]+fibs[i-2]) # add 2 previous, append to fibs return fibs[n]
30b98ea4765ea671cfa75ce0db3d44a455cec443
SoraShiro03/pythonPratices
/stack.py
245
3.640625
4
stack = [1,2,3,4,5] # LIFO last in first out stack.append(7) print(stack) stack.pop() print(stack) newStack = [9,0] stack.extend(newStack) print(stack) stack.reverse() print(stack) stack.sort() print(stack) stack.insert(3, 11) print(stack)
28eb38c9be8b6bcde8306006b73bf235622c0b64
notricky-7709/hangman-py
/hangman.py
357
3.9375
4
from random_word import RandomWords as get_word import math def welcome(name_input): print("Hello," , name_input) def get_word(): return get_word.get_random_word(hasDictionaryDef = True ,min_Length = 4) def main(): name = str(input("Hello, what's your name? I'm ")) \ welcome(name) loop_status = True while Tr...
265c508362b1b13246d3a9fadf344cc8a195277d
juandab07/Algoritmos-y-programacion
/ejercicio_4.py
205
3.71875
4
""" entradas valorcompra->float->c salidas valortotal->float->t """ #entradas c=float(input("digite valor de su compra " )) #cajanegra t=c*0.15 #salidas print("el valor total por su compra es: " +str(c-t))
53c20ef34129674051fc4f8e796ef87e8b4acb96
JUANPER-GITHUB/EJERCICIOS-30-DE-ABRIL
/PUNTO26.py
189
3.921875
4
# PUNTO 26 x = float(input("Digite un numero: ")) if x >= 10: print("El triple del valor ingresado es:", x * 3) else: print("La cuarta parte del numero ingresado es:", x / 4)
a81e3ce357470dccb42b942f2a559edbe0ff16c2
diandraygp/slides
/python-programming/examples/tk/tk_demo.py
3,143
3.59375
4
import tkinter as tk from tkinter import messagebox, filedialog import os def scary_action(): messagebox.showerror(title = "Scary", message = "Deleting hard disk. Please wait...") def run_code(): text = "" text += "Name: {}\n".format(name.get()) text += "Password: {}\n".format(password.get()) text...
ade2ab74de0090cf17ccf0e28d61e763a2cf35f9
jincurry/LeetCode_python
/705_Design_HashSet.py
2,053
3.84375
4
# Design a HashSet without using any built-in hash table libraries. # To be specific, your design should include these functions: # add(value): Insert a value into the HashSet. # contains(value) : Return whether the value exists in the HashSet or not. # remove(value): Remove a value in the HashSet. If the value does ...
1253c01a036fca4288293d334f63f4d825c8b3b5
Ramakanth001/CyberSec-Blogs-Bombe
/bombe/logic.py
4,952
3.6875
4
# Implementation of Affine Cipher in Python from PIL import Image # Extended Euclidean Algorithm for finding modular inverse # eg: modinv(7, 26) = 15 def egcd(a, b): x,y, u,v = 0,1, 1,0 while a != 0: q, r = b//a, b%a m, n = x-u*q, y-v*q b,a, x,y, u,v = a,r, u,v, m,n gcd = b return gcd, x, y def modinv(a, m)...
222afba2846e3e956afa4cbb0c3e810995470c20
Aayan-Not-Foundatgit/Greater-Lesser-Guessing-Game
/main.py
1,929
4.09375
4
import random print('Welcome to the Greater Lesser Guessing Game\n') numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] print('How many times do you want to play this game: ') no_chances_input = int(input()) no_chances = no_chances_input no_chances_used = 0 user_points = 0 co...
a057826f025143b2bbae11cb07773b03ffb36208
Maxi100a/pong
/game.py
5,803
3.609375
4
""" sys - system random - for random numbers pygame - for GUI Player - the necessary player Class Ball - the necessary ball class Utilities: TEXT_FONT, HEIGHT, WIDTH """ import sys import pygame from Utilities import TEXT_FONT, HEIGHT, WIDTH, MENU_FONT from Player import Player from Ball import Ball from Button import ...
dfabed759c2d58ecbe026103e57eb455f99e2d15
Patrick-Ali/PythonLearning
/Lucas.py
492
3.5625
4
def lucas (n): if n == 0: return (2) elif n == 1: return (1) else: return(lucas(n-1)+lucas(n-2)) l = 30 n = lucas(l) while n > 1: print (n) l = l - 1 n = lucas(l) print ("for") L = [2,1] n = 31 for i in range (1): m = (n-n)+2 ...
fb59dbdc13bb6fead1bc8c0a45288eca619ec34e
javedbaloch4/python-programs
/01-Basics/004-largest_number.py
291
4.09375
4
a = 345 b = 234 c = 456 if (a >= b) and (a >= c): largest = a elif (b >= a) and (b >= c): largest = b else: largest = c print("The largest number between",a,b," and ",c," is ", largest) print("<hr>Your task is invert - Write a program to find the smallest number among three")
cd5ac2516f32eb835d2244dd521242bb2451b473
tempflip/fin_playground
/learn_regr_polynomi2.py
3,181
3.578125
4
import pandas as pd import matplotlib.pyplot as plt import numpy as np from sklearn import linear_model from sklearn.preprocessing import PolynomialFeatures def read_stock(stock, usecols = ['Date', 'Adj Close']): df = pd.read_csv('{}.csv'.format(stock), index_col='Date', parse_dates=True, usecols = usecols, ...
3ff9a75ae116add64759faa399ccd03ddbacd201
lixianjian/brush
/algorithm/sorts.py
6,739
3.875
4
#!/usr/bin/env /usr/local/bin/python3 # -*- coding: utf-8 -*- ''' Created on 2017年8月30日 @author: lixianjian ''' def quick_sort(a, low, high): # 快速排序 if low > high: return a mid = a[low] i = low + 1 head, tail = low, high while head < tail: if a[i] > mid: a[tail], a...
bf3b1a0b01eb35a3ce152770b19b02c30c0fff8d
zxycode-2020/python_base
/day06/9-关键字参数/关键字参数.py
207
3.625
4
''' 概念:允许函数调用时参数的顺序与定义时不一致 ''' def myPrint(str, age): print(str, age) #使用关键字参数 myPrint(age = 18, str = "sunck is a good man")
deeed8d288208bfc68cc4d7fd11bc3ae55e886c5
BugChef/yandex_alghoritms
/sprint5/balanced_tree.py
596
3.515625
4
class Node: def __init__(self, value, left=None, right=None): self.value = value self.right = right self.left = left def solution(root: Node) -> bool: return is_balanced_helper(root) > -1 def is_balanced_helper(root: Node): if root is None: return 0 left_height = is_...
70c868543ad5c2f5951915ff6dcef59008c01df4
sandeep-iitr/WebAPI_Databases_Cool_Project_2017
/LAAC/Assignments/graphs.py
1,863
4.125
4
#!/usr/bin/python2.6 # Graph Theory easy exercises for Social Networks module # LACC 2016 #************************************* # This is where you write your code # # matrix_load() # # Loads an adjacency matrix for a graph from a file # # input: none # output: matrix containing each node # # Note: You can open ...
ed072ebf47ba43265ca7ab043f7980cf748263ca
kentronnes/python_crash_course
/python_work/Python Crash Course Chapter 8/8-5 cities.py
234
3.890625
4
def city(city_name, country='the united states'): """Diplays a city and the country it is in.""" print("\n" + city_name.title() + " is in " + country.title() + ".") city('denver') city(city_name='austin') city('barcelona', 'spain')
3b6f4d36144a6c1f48930a76089935dda1d1a988
Srizon143005/Python-Basic-Learning-Codes
/Numpy/All Exercises (1-9).py
1,694
3.609375
4
# All exercises for numpy import numpy as np # Exercise - 1 print("Exercise - 1:") v = np.array([0,1,2,3,4,5,6,7,8,9]) print(v) print(), print(), print() # Exercise print("Exercise - 2:") p = [] for i in range(len(v)): if i%2 != 0: p.append(v[i]) p = np.array(p) print(p) print()...
43797ed4ffce33cf52d52c62a7f32869ba7bc324
karghar/Cracking
/chapter2/task3.py
358
3.515625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def deleteMiddle(self, node): if not node or not node.next: return node node.val = node.next.val nodeNext = node.next node.next = None, node.next.next #garbage c...
aadfae08372e7d487a396c1e767b39e82cc1d0a4
Bishopbhaumik/python_test
/guess.py
341
3.921875
4
import random wi=random.randint(0,9) a=int(input("Guess the no:--")) if wi==a: print("YOU WIN THE GAME\n CONGRATS!!!") elif wi<a: print("you entered a higher no than actual number>") elif wi>a: print("You enterd a lower no than the actual no") print(f"The actual no is {wi}") print("nic...
ebc095b8d48c85dfa674510054be65fb75c290b0
marotoku/multi-agent-simulator
/multi-agent-simulator/PsychologicalModel.py
1,166
3.828125
4
import random from math import tanh class AbstractModel(): ''' this class provides an abstract model of person's psychological model to decide whether to buy a product. ''' def __init__(self, market, product): self.market = market self.product = product def purchaseProbability(sel...
96bf8b9ee0cfbf6d7af3ab98c628cbcfd88c3efa
BenRStutzman/kattis
/Open Kattis/cetvrta.py
327
3.640625
4
x_coords = [] y_coords = [] for i in range(3): coords = input().split() x_coords.append(coords[0]) y_coords.append(coords[1]) for x_coord in x_coords: if x_coords.count(x_coord) == 1: print(x_coord, end = ' ') for y_coord in y_coords: if y_coords.count(y_coord) == 1: print(y_coord...
7fdb9274732f3ce61015515d208423981751182d
NicholasFay-CIS/Algorithms
/HW02/hw06Mem.py
2,787
3.765625
4
import sys import string from decimal import Decimal #using Memoization def get_options(inputfile): """ FILE obj->int This gets the amount of options from the input file """ return int(inputfile.readline()) def get_amount(inputfile): """ FILE obj->int This gets the budget from the input file """ return int(...
719b2cb1b207dfc27058dc1094c6656d0fea2720
AIHackerTest/nanshanpai_Py101-004
/Chap0/project/ex37.py
642
3.609375
4
print(True and True) a = [1,2,3] del a[0] print a from sys import exit print(not True) #while a != '0': 循环语句 #with class as b: #elif 条件语句 # global 全局 变量定义 global x # or逻辑运算 #assert 断言语句 如果发生错误按约定方式提醒 # if elif else #pass 让程序什么也不做 #yield 是一个生成器 可以用next() 调用其值 #break 跳出当前条件缩进部分 而非全局exit #coutinue如果条件为真则继续执行 条件下的动作, ...
1c2b6435fc5b5fc88fb6aa037591c61aed44a8ff
mountlovestudy/leetcode
/ProductOfArrayExceptSelf.py
1,051
3.953125
4
""" Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O(n). For example, given [1,2,3,4], return [24,12,8,6]. Follow up: Could you solve it with constant space complexity? (N...
395ad6767ae5b01b7ea346758f8ae7f093c1238d
Arjun2001/coding
/hackerrank/hackerrank Super Reduced String.py
216
3.546875
4
s = "aaabccddd" index = 1 while index < len(s): if s[index] == s[index - 1]: s = s[:index -1] + s[index +1:] index = 0 index += 1 if len(s) == 0: print("Empty String") else: print(s)
0b7ac723cba81ed8d2b9dac4fe143766295485ed
maskedoverflow/project_euler_lib
/python/problem3.py
694
3.75
4
def factorize_odd(n): if not isinstance(n, int): raise TypeError if n % 2 == 0: yield 2 for x in range(3, int(n ** .5), 2): if n % x == 0: yield x reverse = n // x if reverse != x: yield n // x def is_prime(n): if not isinstan...
63b3a3011e71fc5fd46f9c314b767daf266c5760
Rafaelbarr/100DaysOfCodeChallenge
/day021/003_multiplying_table.py
422
3.796875
4
# -*- coding: utf-8 -*- from __future__ import print_function def run(): length = int(raw_input('How may steps long you want the stairs?: ')) for j in range(1, length): print(' ') for i in range(1, length): k = i * j if k > 10: print(k, end=...
cf6203d17839172a369186b79a58669be2518da7
outsider4444/python-turtle
/zd10.py
169
3.796875
4
import turtle t = turtle.Turtle() t.shape('turtle') n = 6 x = 1 def flower(x): while x <= n: t.circle(50) t.left(360 / n) x += 1 flower (x)
09a976a2911093bfdd547ab28aa940c166086cba
bhavishya18/Let-s-Code-Python-
/Palindrome.py
701
4.15625
4
#!/usr/bin/env python # coding: utf-8 # In[7]: def palindrome(num): if num<0: return False num=str(num) n=len(num) low=0 high=n-1 while low<high: if num[low]==num[high]: low+=1 high-=1 else: return False return True num = input...
d3ce114f01932d8b6ce0830d17e2da55fd1bdc6d
1Lopez/examrem
/menuCONS.py
927
3.65625
4
j = 1 Asx = [] while j == 1: print print("Seleccione una opcion") print("1)Nueva Tarea") print("2)Listar Tarea") print("3)Tareas Hechas") print("4)Eliminar Tareas") op = input("Ingrese la opcion:") if op == "1": print("NUEVA TAREA") des = input("Ingrese la descripcion ") ...
afdb89732a7f993f1c795858d3d443fee7c8511b
MasatakaShibataSS/lesson
/AI/examples/04/4.2.5-1-multiple_orderly.py
1,156
3.734375
4
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np ### y = 3x_1 - 2x_2 + 1 のデータを作成 x1 = np.random.rand(100, 1) # 0 〜 1 までの乱数を 100 個つくる x1 = x1 * 4 - 2 # 値の範囲を -2 〜 2 に変更 x2 = np.random.rand(100, 1) # x2 についても同様 x2 = x2 * 4 - 2 y = 3 * x1 - 2 * x2 + 1 ### 学...
2d98663a23c9176ca5c831f0251e26574a2e4095
grantwilk/barndles
/barndles_assembler/basm/pipeline/disassemble.py
832
3.546875
4
def disassemble_instruction(binary_instr): """ Disassembles a binary instruction :param binary_instr: the binary :return: the disassembled instruction as a dictionary """ # initialize dictionary with universal fields instr_dict = { "opcode": binary_instr >> 19, "imm_flag": b...
4fc52493bee716dfdb4adcb2f0cc804fad4d8d0d
ToryTechs/calendar
/scheduled_task.py
3,581
3.5
4
#!/usr/bin/env python3 import argparse import datetime import os import subprocess def create_date_range(startdate, N, prev): base_date = startdate range_of_dates = [] if prev is True: range_of_dates = [base_date - datetime.timedelta(days=x) for x in range(N)] else: range_of_dates...
263d7b8ed2af32856886a4519b03909a3d7881ae
AnhquanNguyenn/PythonPracticeScripts
/Designing a Cash Register/change.py
2,106
4.0625
4
import sys nameValue = {0.01: 'PENNY', 0.05: 'NICKEL', 0.1: 'DIME', 0.25: 'QUARTER', 0.5: 'HALF DOLLAR', 1.00: 'ONE', 2.00: 'TWO', 5.00: 'FIVE', 10.00: 'TEN', 20.00: 'TWENTY', 50.00: 'FIFTY', 100.00: 'ONE HUNDRED'} # Array of Values holding each individual change value to loop through to find the change ...
db4a77ff64b44456850c73c5a47d4178e2ead3be
huebschwerlen/Python
/Python_Review/objects.py
4,750
3.703125
4
#lottery_player = { # 'name': 'sam', # 'numbers': (12, 45, 67, 88) #values can be list, sets, tuples, dicts #} #print(lottery_player['name']) #print(len(lottery_player['numbers'])) #print(sum(lottery_player['numbers'])) # # # # # # # # #class LotteryPlayer: # def __init__(self): # self...
5702ab9e61ef2d140c8a19c6aa0e2a7f11e038ed
806334175/pystudy
/05_常用模块/13_re模块/re补充.py
1,309
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import re print(re.findall("<(?P<tag_name>\w+)>\w+</(?P=tag_name)>", "<h1>hello</h1>")) # ['h1'] print(re.search("<(?P<tag_name>\w+)>\w+</(?P=tag_name)>", "<h1>hello</h1>").group()) # <h1>hello</h1> print(re.search("<(?P<tag_name>\w+)>\w+</(?P=tag_name)>", "<h1>hello</h...
1074fc023a93a361d5f48889cf1bf43102058a2d
fabiobarretopro/Aprendendo-Python
/equi-isos-esca.py
508
4.0625
4
l1 = int(input(f"Digite um lado l1 do triângulo:")) l2 = int(input(f"Digite um lado l2 do triângulo:")) l3 = int(input(f"Digite um lado l3 do triângulo:")) if l2 - l3 < l1 < l2 + l3 and l1 - l3 < l2 < l1 + l3 and l2 - l1 < l3 < l2 + l1: print("É um triângulo!") if l1 == l2 == l3: print("Triângulo equil...
34944cb24205a173c02b021b0a14a7d5ed2d69b7
momentum-cohort-2018-10/w2d1-currency-converter-Komor-RP
/currency.py
1,056
3.921875
4
def convert(rates, value, from_currency, to_currency): if from_currency == to_currency: return value available_rates = [] for conversion in rates: available_rates.append(conversion[0]) available_rates.append(conversion[1]) if (from_currency in convers...
77e1acdd0c2fa7b2932554c24c107428e117b914
tryingtokeepup/Whiteboard-Pairing
/CountingVotes/kais_first_pass.py
1,803
4.3125
4
def count_votes(arr): candidate_vote_tracker = {} current_winner_votes = 0 current_winner = '' # so, basically, we have a bunch of candidates who have votes inside the array that is passed to us. # we need to iterate over the choosen candidates, and everytime they recieve a vote, if they don't have ...
e3252fc240b461813f91ce45826f9945ad7e1784
chukycheese/learning-materials
/python-101/data-structure/performQuickSort.py
592
3.640625
4
import random N = 10 firstNumbers = list(range(N)) random.shuffle(firstNumbers) print(firstNumbers) def performQuickSort(seq, pivot = 0): if len(seq) <= 1: return seq pivotValue = seq[pivot] less = [] greater = [] for itr in range(len(seq)): if iter == pivot: co...
6d11fd956434d519b5a5372dabe17f786e73b2ac
boswellgathu/py_learn
/12_strings/longest_word.py
297
3.671875
4
# Program to display the longest word in a given sentence # The sentence should be given as an input from the key board by the user # If there are two words of equal length, it displays the first longest word # for more info on this quiz, go to this url: http://www.programmr.com/longest-word-3
5f4f753f88a052ce63afac7cfa2c8610a88139cb
taraspyndykivskiy/python-laboratory
/laboratory7/task1.py
3,342
3.734375
4
#D:\Taras Pyndykivskiy\kpi\programming\programming_1\laboratory_works\#7 """ Є текстовий файл. Надрукувати:  його перший рядок;  його п'ятий рядок;  його перші 5 рядків;  його рядки з s1-го по s2-ий;  весь файл. """ import sys import re pattern=re.compile(r"^[+]?\d+$") def init(): print("\nЛабораторна робота №7...
5592a15e618f17846735f02d1cf1fcc69d90e644
radoaller/learnpython
/max from input.py
321
4.25
4
a = int(input("Please input the first number.")) b = int(input("Please input the second number.")) c = int(input("Please input the third number.")) my_list = [a, b, c] max_number = my_list[0] for element in my_list: if my_list[0] < element: max_number = element print ('The biggest number is', max_number)...
9144464409140d0be6bff0973c67013e2caf737b
maksympt1/adventure-game
/game.py
4,388
3.859375
4
# Import modules import time import random # Define functions def print_pause(s): print(s) time.sleep(2) def print_pause_long(s): print(s) time.sleep(3) def main(): global items items = ["dagger"] global enemy enemy = random.choice(enemies) # Introduction ...
d66161d0a93fecc6f127f6a34e0f884c4baa1586
MarvelousJudson12/judson-s-project
/flowers.py
2,961
4.25
4
input("what is juds favorite flower? rose, goldenrod, or sunflower?") def juds_favorite_flowers(flower, color): if flower == "rose": print("pick some for my mom and grandma for mothers day") elif flower == "goldenrod": print("thats cool, its KY's state flower") elif flower == "sunflower": ...
1124c0c044053478f1d0ef6822ef68d2cc47f0ac
Peteliuk/Python_Labs
/lab4_2.py
257
3.90625
4
import sys import math print('Enter 3 real numbers') numA = float(input('')) numB = float(input('')) numC = float(input('')) res = (1/numC*math.sqrt(2*math.pi))*math.exp((-1*math.pow((numA-numB),2))/(2*math.pow(numC,2)) print('Result:',res)
05024a2c8bd9784bac7daf118dc0c6cb5f2240f7
ahmetfarukyilmaz/leetcode-solutions
/algorithm/two_sum.py
260
3.515625
4
def twoSum(nums, target): result = [] for i in range(len(nums)): for j in range(len(nums)): if nums[j] + nums[i] == target and i != j: result.append(i) result.append(j) return result
2d8d2b6c6a107b42040ddf743bcfd8094be82982
norskovsen/Python-og-Pita-2019
/eksempler/del2/lister_for.py
272
3.890625
4
def all_positive_even_numbers(lst): for numb in lst: if numb % 2 != 0: return False if numb <= 0: return False return True print(all_positive_even_numbers([2, 4, 10, 12])) print(all_positive_even_numbers([4, 6, 11, 13]))
13862f949ba19b6290aed7d4f914d88372d3ae00
indie-tuna/Vampy-2017-cs
/numGuess.py
414
4.0625
4
lower = 1 upper = 0 guess = 1 ans = "" while ans != "yes": ans = input("Is "+ str(guess) +" your number/ is your number more or less? (yes/more/less)").lower() if ans == "more": if upper == 0: guess *= 2 else: lower = guess guess = int((lower + upper)/2) elif ans == "less": if upper == 0: lower = i...
7f1c5622f5b69403b6a7d040894e8aadca15079c
yakubpeerzade/repo1
/calculator.py
889
4
4
def add(n1,n2): res=n1+n2 return res def sub(n1,n2): res=n1-n2 return res def mul(n1,n2): res=n1*n2 return res def div(n1,n2): if n1==0 or n2==0: print("We cannot divide with zero") calculator() else: res=n1/n2 return res def calculator(): num1=int(inp...
9512199580e2b69c7ace7cea5b053900cc8c80c2
JosephT8ertot/FruitPunch
/Member.py
1,779
3.671875
4
""" Creator: Joseph A Tate Last Edit: 7/5/2021 The purpose of this class is to store the Player and User classes, which are used throughout the application to give the user a involved experience """ # imports from Database import db # Player class class Player: def __init__(self, email_or_ID): self.em...