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
234a8bc6f168afac7ab18c566b0a783e5e9080fd
prabalbhandari04/python_
/labexercise2.py
312
4.28125
4
#Write a program that reads the length of the base and the height of a right-angled triangle and prints the area. Every number is given on a separate line.# length_of_base = int(input("Enter the lenght of base:")) height = int(input("Enter the height:")) area = (1/2)*(length_of_base*height) print(area)
f9d3c49fda6f4419d84f23f8275bcb20e55b9489
prabalbhandari04/python_
/labexercise_12.py
105
4.34375
4
#Given x = 5, what will be the value of x after we run x+=3? x=5 x+=3 print(x) #It's value will be 8.
defc112609510a6b38eeaa5bc84eef640cb62fd7
elikir/algorithms
/sort/insertionsort.py
772
3.578125
4
import time import random def sort(lis): for x in range(1,len(lis)): curVal = lis[x] pos = x while 0 < pos and lis[pos-1] > curVal: lis[pos] = lis[pos-1] pos -= 1 lis[pos] = curVal return lis #run #1 on list of length 100 - 0.000652874565125 seconds...
06fe1661b93a940e28adb9c5fab488df85e19eb8
ankush-phulia/Lift-MDP-Model
/simulator/Elevator.py
2,956
4.25
4
class Elevator(object): """ - state representation of the elevator """ def __init__(self, N, K): self.N = N # number of floors self.K = K # number of elevators # initial positions of all elevators self.pos = [0]*...
09b7ed3aac44b5ec2840d972df3ce8b6ad68d9b3
jonstod/DS-Portfolio-Project
/d_graph.py
11,785
3.90625
4
# Course: CS261 - Data Structures # Author: Jonathon Stoddart # Assignment: 6 # Description: Part 2 - Directed Graph (via Adjacency Matrix) import heapq as heap class DirectedGraph: """ Class to implement directed weighted graph - duplicate edges not allowed - loops not allowed - only positive e...
7e74f5268702ceb4707281805581384dc59d0080
Anshikaverma24/meraki-function-questions
/meraki functions ques/inner function ques/q3.py
528
4.0625
4
# Question 3 # Ek function banaiye jo 3 numbers ka sum aur average print kare.Hum user se 3 number # input karwayenge aur fir unn 3 numbers ka sum aur average print karwayenge def sum(): num1=int(input("enter 1st no.")) num2=int(input("enter 2nd no.")) num3=int(input("enter 3rd no.")) add=num1+num2+...
bc0c4a64a9f71c3a9ae77b1123eeffe48b98d3c5
FefAzvdo/Python-Training
/Exercicios/Aula 10/030.py
506
3.90625
4
# Ano bissexto # Divisível por 4. Sendo assim, a divisão é exata com o resto igual a zero; # Não pode ser divisível por 100. Com isso, a divisão não é exata, ou seja, deixa resto diferente de zero; # Pode ser que seja divisível por 400. Caso seja divisível por 400, a divisão deve ser exata, deixando o resto igual a ...
2af1e2e3ac726d51a31c371483abd2e6d1b6d5b9
FefAzvdo/Python-Training
/Exercicios/Aula 13/051.py
287
4
4
# socorram me subi no onibus em marrocos frase = input("Digite uma frase: ") formatada = frase.replace(" ", "") print("Frase =>", formatada) print("Ao contrário =>", formatada[::-1]) if formatada == formatada[::-1]: print("É PALÍNDROMO") else: print("NÃO É PALÍNDROMO")
f501d353de483ac071efcd002afb39410d8a1a5f
FefAzvdo/Python-Training
/Exercicios/Aula 12/036.py
230
3.953125
4
n1 = int(input("Digite um número :")) n2 = int(input("Digite outro número :")) if n1 > n2: print(f"{n1} é maior do que {n2}") elif n1 == n2: print(f"{n1} é igual a {n2}") else: print(f"{n2} é maior do que {n1}")
608c925a7bb0d43f25cbb24431020093dd0617c4
FefAzvdo/Python-Training
/Aulas/013.py
431
4.21875
4
# Estruturas de Repetição # Output: 1, 2, 3, 4, 5 for count in range(1, 6): print(count) # Executa 3x # Output: * * * for count in range(0, 3): print("*") for count in range(0, 11): if(count % 2 == 0): print(f"{count} é PAR") else: print(f"{count} é ÍMPAR") for count in range(6, 0, ...
cf1d9c20518ca86804c83ffee8fd439b587ee8f3
FefAzvdo/Python-Training
/Exercicios/Aula 09/023.py
84
3.65625
4
nome = input("Digite seu nome completo: ") print(nome.upper().find("SILVA") != -1)
1218eb2a6ac77aecfdef4846500dc1623c58c418
FefAzvdo/Python-Training
/Exercicios/Aula 10/033.py
738
4.25
4
# Condição de existência de um triângulo # Para construir um triângulo não podemos utilizar qualquer medida, tem que seguir a condição de existência: # Para construir um triângulo é necessário que a medida de qualquer um dos lados seja menor que a soma das medidas dos outros dois e maior que o valor absoluto da difere...
1d8df8f0fd6996602088725eaef8fb63429cdf99
mileshill/HackerRank
/AI/Bot_Building/Bot_Saves_Princess/princess.py
2,127
4.125
4
#!/usr/bin/env python2 """ Bot Saves Princess: Mario is located at the center of the grid. Princess Peach is located at one of the four corners. Peach is denoted by 'p' and Mario by 'm'. The goal is to make the proper moves to reach the princess Input: First line contains an ODD integer (3<=N<=99) ...
d4b4d700b8b95d23069a2d8e5f3276854aa77432
rahulkumar1m/exercism-python-track
/darts/darts.py
230
3.953125
4
import math def score(x : int, y : int) -> int: circle = math.sqrt(x**2 + y**2) if circle <= 1: return 10 elif circle <= 5: return 5 elif circle <= 10: return 1 else: return 0
f1d0eed5c88aff33508a9b32e9aaec1a3f962de3
rahulkumar1m/exercism-python-track
/isogram/isogram.py
528
4.3125
4
def is_isogram(string) -> bool: # Tokenizing the characters in the string string = [char for char in string.lower()] # initializing an empty list of characters present in the string characters = [] # if a character from string is already present in our list of characters, we return False for c...
083dff2e186c84f0c113fb4c11b69222102e754e
rahulkumar1m/exercism-python-track
/yacht/yacht.py
1,502
3.984375
4
""" This exercise stub and the test suite contain several enumerated constants. Since Python 2 does not have the enum module, the idiomatic way to write enumerated constants has traditionally been a NAME assigned to an arbitrary, but unique value. An integer is traditionally used because it’s memory efficient. It is a...
ca4a19062fac62c815d2c4a2cafb654f0c7db6a7
jc345932/programming
/task1.py
264
4
4
def main(): x = int(input("Enter x:")) y = int(input("Enter y:")) doMath(x, y) def doMath (x, y): sum = x + y diff = x - y product = x * y quotient = x / y print(sum) print(diff) print(product) print(quotient) main()
423f9c7f03e804adaff03a5936d426b99931c1ac
ammarlam10/evolutionary-Algorithm
/evo.py
13,664
3.859375
4
# Created By: Muhammad Ammar Ahmed 09389 # Running this program will output 12 graphs, 1st 6 will contain avg_avg fitness and avg_best fitness of Function 1 # and last 6 will produce for function 2. # ------------------------------------------ # The values printed on the console are average average fitness of 40 genera...
5d77e9ffd0d437c0d98567cdbd80277f5cbd47af
mrinalmayank7/python-programming
/CLASSES & OBJECTS/M_Overriding.py
326
3.546875
4
class India: def __init__(self): self.value="INSIDE COUNTRY" def globe(self): print(self.value) class Punjab(India): def __init__(self): self.value="INSIDE STATE" def globe(self): print(self.value) o1=India() o2=Punjab() o1.globe() o2.globe() ...
38bb9777c09a1ac702330eccca23e21a270dad2e
mrinalmayank7/python-programming
/FILE HANDLING/File_Handling.py
658
3.8125
4
#MODES #''r' is for read, ti is the default mode #'w' is for write from the first line #'a' write from the end of file , if file doest not exist it will create a new file #'x' is for create a file , if file exist then it will return error #'t' is text #'b' is for binary f= open('file1.txt','w+') #w+ is f...
ee7621808654eae021fdfbe36d3bb796695a032e
mrinalmayank7/python-programming
/PRACTICE WORKSHEETS/worksheet3.2.py
1,452
3.8125
4
print("Name :Mrinal Mayank") print("UID :19BCS1605") class MAGIC: def __init__(self,o): self.o = o def __ge__(self,operator1): #for greater than and equal to return self.o > operator1.o def __mul__(self,operator1): #for multiplication return self.o * opera...
7912b115e12d200e6981cdbe55ca8c3175eba085
fangbz1986/python_study
/函数式编程/03filter.py
1,222
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' Python内建的filter()函数用于过滤序列。 和map()类似,filter()也接收一个函数和一个序列。和map()不同的是,filter()把传入的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素。 filter()的作用是从一个序列中筛出符合条件的元素。由于filter()使用了惰性计算,所以只有在取filter()结果的时候,才会真正筛选并每次返回下一个筛出的元素。 ''' # 例如,在一个list中,删掉偶数,只保留奇数,可以这么写: def is_odd(n):...
8a3d11386042b7c7c67c110f2e255005d8879556
fangbz1986/python_study
/03高级特性/05生成器.py
4,412
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' 生成器 通过列表生成式,我们可以直接创建一个列表。但是,受到内存限制,列表容量肯定是有限的。而且,创建一个包含100万个元素的列表,不仅占用很大的存储空间,如果我们仅仅需要访问前面几个元素,那后面绝大多数元素占用的空间都白白浪费了。 所以,如果列表元素可以按照某种算法推算出来,那我们是否可以在循环的过程中不断推算出后续的元素呢?这样就不必创建完整的list,从而节省大量的空间。在Python中,这种一边循环一边计算的机制,称为生成器:generator。 要创建一个generator,有很多种...
3135ff685de3e016c265c88484827ec95bccea97
projectcollection/Intro-Python-II
/src/adv.py
3,698
3.5
4
import textwrap from player import Player from room import Room from items import * #Make some items samurai = Weapon('samurai', 10, 500, 100) # Declare all the rooms room = { 'outside': Room("Outside Cave Entrance", "North of you, the cave mount beckons", [samurai]), 'foyer': Room...
cabe3b1323ec56f099fb7d22bd2dc5d966455b91
ryancey1/Rosalind
/Algorithmic-Heights/08-heapsort.py
364
3.734375
4
#! /usr/bin/env python3 ''' ''' import sys, os import algorithmic_heights as algs ## METHODS GO HERE ## def main(): file = sys.argv[1] with open(file) as _: line = [lines.strip() for lines in _] arr, n = [int(x) for x in line[1].split()], int(line[0]) print(*algs.heapsort(arr, ...
a3e8aefe45bce23e73caa3bcae8e4054e9b4668b
ryancey1/Rosalind
/Bioinformatics-Stronghold/17-mortal-fibonacci.py
375
3.921875
4
#! /usr/bin/env python3 ''' Given: Positive integers n≤100 and m≤20. Return: The total number of pairs of rabbits that will remain after the n-th month if all rabbits live for m months. ''' import sys memo = {} def mortal_fibonacci(n, m, memo): pass if __name__ == '__main__': n, m = 6, 3 if n > 10...
1997d7b74abb8a6ab5706bfdffb6009da2084891
ryancey1/Rosalind
/Algorithmic-Heights/03-insertion-sort.py
413
3.53125
4
#! /usr/bin/env python3 import sys, os import algorithmic_heights as algs def main(): file = sys.argv[1] # file = os.getcwd() + '/Algorithmic-Heights/rosalind_ins.txt' with open(file) as f: line = [lines.strip() for lines in f.readlines()] n, arr = int(line[0]), [int(x) for x in line[1].sp...
122a3f71dd406d2cea9d838e3fe1260cd0e3adcf
hardlyHacking/cs1
/static/solutions/labs/gravity/solution/system.py
2,283
4.21875
4
# system.py # Solution for CS 1 Lab Assignment 3. # Definition of the System class for gravity simulation. # A System represents several Body objects. # Based on code written by Aaron Watanabe and Devin Balkcom. UNIVERSAL_GRAVITATIONAL_CONSTANT = 6.67384e-11 from math import sqrt from body import Body class System:...
b3c3e255cbffa0ddf0cab275f72643915f39e018
hardlyHacking/cs1
/static/solutions/labs/gravity/solution/body.py
1,498
3.96875
4
# body.py # Solution for CS 1 Lab Assignment 2. # Definition of the Body class for gravity simulation. # Based on code written by Aaron Watanabe and Devin Balkcom. from cs1lib import * class Body: # Initialize a Body object. def __init__(self, mass, x, y, vx, vy, pixel_radius, r, g, b): self.mass = ma...
d45482664ec4e67e88942b98ba6f5eb5a91fa165
hardlyHacking/cs1
/static/solutions/shortassign/rich/solution/portia.py
1,382
3.921875
4
# portia.py # Solution to CS 1 Short Assignment #3, Problem 2 by THC. # Computes the balances of two bank accounts: # Brutus's account starts with $1 in year 0, compounded at 5% annually. # Portia's account starts with $100,000 in year 0, compounded at 4% annually. # Computes the first year in which Brutus's bala...
b33d2944d9bad1577ec4c248fb2c48ddb8cdd1f1
hardlyHacking/cs1
/static/solutions/labs/quicksort/solution/lab3_checkpoint.py
1,807
3.9375
4
# lab4_checkpoint.py # CS 1 Lab Assignment #3 checkpoint by THC. # Reads in a file of information about world cities, stores each line # into a City object, and then writes out the string representation of # each City object into a file. # Each line of the input file has the following fields, separated by commas: # ...
7eed2e54b2fbabb3ef286b12f6595ffb5b47d339
acecpt/PyGames
/runner.py
4,662
3.890625
4
# https://youtube/watch?v=-8n91btt5d8 import random # library for generating random numbers import sys # python window controls import pygame # https://www.pygame.org/docs pygame.init() print(pygame.get_init()) WIDTH = 800 HEIGHT = 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) myFont = pygame.font.S...
beabf3189c86e0e8d2604ef7b6e7bc1c0d6715c1
jpmghyston/advent-of-code-2019
/3/3_part2.py
1,661
3.6875
4
input_file = open("input.txt", "r") path_directions_1 = input_file.readline().strip().split(',') path_directions_2 = input_file.readline().strip().split(',') def coords_for_path(path): _x = 0 _y = 0 path_coords_visited = [] for instruction in path: direction = instruction[0] ...
b9e31fcc8653fb44cb7b98216001542f8dff3f85
terenceshin/modularized-ml-code
/model.py
1,846
3.703125
4
import pandas as pd import xgboost as xgb def xgb_classifier(X_train, y_train, params): """ Creates XGBoost Classifier Inputs: X_train (df): the feature training data y_train (df): the target training data params (dict): the parameters of XGBoost Returns: ...
483d4305953b5bda4c9b7b60a4144068e5d08f46
nikhilkhera/algorithmic_toolbox_assignment
/algorithmic toolbox/week3/fuel.py
714
3.765625
4
# python3 import sys def compute_min_refills(distance, tank,no_stops, stops): # write your code here numrefils=0 stops.append(distance) stops.insert(0,0) current_refill=0 while current_refill <= no_stops: last_Refill = current_refill while(current_refill<=no_stops) ...
3666bb73d265cf9eda5b649eb26297551a20e6d9
nikhilkhera/algorithmic_toolbox_assignment
/algorithmic toolbox/week4/majority_element_3.py
445
3.71875
4
def majority(elements): thisdict = {} for i in elements: if i not in thisdict: thisdict[i]=1 else: thisdict[i]+=1 for i in thisdict.values(): if i > len(elements)/2: return 1 return 0 def main(): num_elements = int(input()) ...
8c1bfdd62dc1552d2fb5b5533a0dd01ebd22d7fd
nikhilkhera/algorithmic_toolbox_assignment
/algorithmic toolbox/week5/primitive_calculator.py
894
3.5625
4
def primitivecalculator(n): if n==1: return [0,0] steps=[0,0] div=[2,3] for i in range(2,n+1): minstep=9999999 if steps[i-1]+1<minstep: minstep=steps[i-1]+1 for j in div: if i% j==0: if steps[i//j]+1<minstep: ...
4594c093fb80bcffec0b301ffaa0bc3c8b7704c8
nikhilkhera/algorithmic_toolbox_assignment
/algorithmic toolbox/week4/lottery.py
2,949
3.78125
4
# Uses python3 import sys import random def merge(A,B): c=[] while(len(A)!=0 and len(B)!=0): if(A[0][0])<=B[0][0]: c.append(A.pop(0)) else: c.append(B.pop(0)) if(len(A)==0): c.extend(B) else : c.extend(A) return c def m...
30b26711fedc988ada22838725fe87edf0a2874b
testuserhehexd/uw-projects
/Movies Project/Top 5 Movies made by Country/top_countries.py
3,078
3.703125
4
""" Nalu Zou, Yuming Tsang, Jerome Orille CSE 163 This file will identify the top five movies with the highest average rating per country. """ import pandas as pd import geopandas as gpd import matplotlib.pyplot as plt def average_ratings_per_country(df, countries): """ This function analyzes the data based o...
490389021ee556bb98c72ae687389445ebb6dcb7
Andras00P/Python_Exercise_solutions
/31 - Guess_Game.py
855
4.46875
4
''' Build a simple guessing game where it will continuously ask the user to enter a number between 1 and 10. If the user's guesses matched, the user will score 10 points, and display the score. If the user's guess doesn't match, display the generated number. Also, if the user enters "q" stop the game. ''...
1312a36aee5ceebbb32beedfef010210a5bb19bb
Andras00P/Python_Exercise_solutions
/18 - Calculate_Grades.py
871
4.21875
4
''' Calculate final grade from five subjects ''' def grades(a, b, c, d, e): avg_grade = int((a + b + c + d + e) / 5) f_grade = "" if avg_grade >= 90: f_grade = "Grade A" elif avg_grade >= 80: f_grade = "Grade B" elif avg_grade >= 70: f_grade = "Grade C" elif...
3607e93c5431e03789f3f980fd2220c4a8dc9b10
Andras00P/Python_Exercise_solutions
/24 - Reverse_String.py
443
4.375
4
""" Reverse a string. If the input is: Hello World. The output should be: .dlroW olleH """ def reverse_string(text): result = "" for char in text: result = char + result return result # Shortcut def reverse_string2(text): return text[::-1] usr_text = input("Wri...
a5fd62036f3dd8a6ec226ffae14b48c6c5ab06ca
Andras00P/Python_Exercise_solutions
/21 - Check_Prime.py
357
4.21875
4
''' For a given number, check whether the number is a prime number or not ''' def is_prime(num): for i in range(2, num): if (num % i) == 0: return False return True usr_num = int(input("Enter number: \n")) if is_prime(usr_num): print("The number is a Prime") else: ...
a063feb62e0fa07e815315aa7f0cead126dabb19
amalathomas3/python
/lab11.1.py
247
3.609375
4
import calendar as c from datetime import * print(c.month(2021,1)) d=datetime.today() print("year; ",d.year) print("month; ",d.month) print("hour; ",d.hour) print("minute; ",d.minute) print("second; ",d.second) print("datetime format:",d)
cbdbb88e82583228c93a75da235a6a4a0baca435
venkat58/basic
/exapmles/basicexamples.py
1,246
3.78125
4
# decorator example def outer_div(func): def inner(x,y): if(x<y): x,y = y,x return func(x,y) return inner @outer_div def divide(x,y): print(x/y) def logo(): thickness = 9 #int(input()) #This must be an odd number ex: 5 c = 'H' #Top Cone for i ...
ac899cc4fe64b3c746a3af49bfe6570695440786
minhbang/vi_gec_bert_transformer
/gen/rules/search_replace/rule.py
2,347
3.53125
4
class Rule(object): """ Rule Base class Một luật Tìm/Thay thế, ví dụ D/GI/V thay thế lẫn nhau """ @staticmethod def get_all_patterns(): return [] def __init__(self, pattern: str = None) -> None: self.search_replace = [] if pattern is not None: ps = pattern.s...
fb8c5dd6ffd12d82b2629ee0b742bc437bf5e8d8
SuiMingYang/leecodeWS
/14.py
550
3.703125
4
class Solution: def longestCommonPrefix(self, strs) -> str: if len(strs)==0: return "" if len(strs)==1: return strs[0] mn=min(len(strs[0]),len(strs[1]),len(strs[2])) k=-1 for i in range(mn): if strs[0][i]==strs[1][i] and strs[2][i]==strs[1]...
cf4f0f430612a88914f6344346318778bdabb691
dyehuty/recipe-app-api
/app/app/old_calc.py
148
4
4
def add(x,y): """Add two numer together""" return x + y def substract(x,y): """Substract x from y and return value """ return y - x
06afe217a85fc98b1689ac6e6119a118fe91f9b5
garciacastano09/pycourse
/intermediate/exercises/mod_05_iterators_generators_coroutines/exercise.py
2,627
4.125
4
#-*- coding: utf-8 -*- u''' MOD 05: Iterators, generators and coroutines ''' def repeat_items(sequence, num_times=2): '''Iterate the sequence returning each element repeated several times >>> list(repeat_items([1, 2, 3])) [1, 1, 2, 2, 3, 3] >>> list(repeat_items([1, 2, 3], 3)) [1, 1, 1, 2, 2, 2,...
014e36604daf04ec73c663fe223cd445fcd01ca5
garciacastano09/pycourse
/advanced/exercises/mod_05_functools/exercise_mod_05.py
585
4.25
4
#!/usr/bin/env python #-*- coding: utf-8 -*- u""" Created on Oct 5, 2013 @author: pablito56 @license: MIT @contact: pablito56@gmail.com Module 05 functools exercise >>> it = power_of(2) >>> it.next() 1 >>> it.next() 2 >>> it.next() 4 >>> it.next() 8 >>> it.next() 16 >>> it = power_of(3) >>> it.next() 1 >>>...
e506aecc46760fd380700bdfc47ee96ab95e193a
garciacastano09/pycourse
/modules/mod_07_multiprocessing/mod_mp_fibonacci.py
1,058
3.609375
4
#-*- coding: utf-8 -*- u""" MOD: Multiprocessing with requests """ import multiprocessing import requests import threading def fibonacci(n): """Return the nth fibonacci number""" if n < 2: return n return fibonacci(n - 1) + fibonacci(n - 2) def get_fibonacci(num): fib = fibonacci(30 + num) ...
351bd55ea95d6cbc8180219ed9729a17bb81f3ee
test-for-coocn/test-back
/pyton/StatOneVar.py
833
3.734375
4
import math def sqr(x): return x * x data = [66, 59, 62, 64, 63, 68, 65, 59, 68, 64, 65, 51, 67, 64, 83, 59, 61, 62, 57, 72, 65, 64, 54, 60, 53, 65, 67, 60, 53, 79, 74, 53, 61, 68, 75, 50, 57, 55, 66, 56, 55, 61, 70, 71, 49, 6...
c3d462c1e5cd9bb28a67ee54f8f80c03ec14f06a
ACEinfinity7/Determinant2x2
/deter_lib.py
792
4.125
4
def deter2x2(matrix): """ function to calculate the determinant of the 2x2 matrix. The determinant of a matrix is defined as the upper-left element times the lower right element minus the upper-right element times the lower left element """ result = (matrix[0][0]*matrix[1][1])-(matri...
6e090a6455cc172865ecf2d0b48110312068a0e4
mitchellflax/lpsr-samples
/3-4FunctionsInTurtle/jennyc.py
760
3.90625
4
# myFractalTemplate.py import turtle def makeRhombus(myTurtle, side): myTurtle.left(120) myTurtle.forward(side) myTurtle.left(120) myTurtle.forward(side) myTurtle.left(60) myTurtle.forward(side) myTurtle.left(120) myTurtle.forward(side) # make our tur...
2cf3df6fe11dd50ef0b28adaea768e1125486be2
mitchellflax/lpsr-samples
/Unit1-2Unordered/discounter.py
301
4.09375
4
# find out price from user print("What is the price?") price = int(input()) # calculate discount price discount_price = .9 * price # if user gets a discount, tell them. # if not, tell them. if price > 1000: print("Your price is " + str(discount_price)) else: print("Your price is " + str(price))
ef80b3131b124c9275235e8b3f2b36902d201380
mitchellflax/lpsr-samples
/3-4FunctionsInTurtle/iris.py
220
3.796875
4
import turtle t = turtle.Turtle() turtle.colormode(255) c = 50 while c > 0: t.speed(10) t.color(128,0,0) t.forward(c * 3) t.color(0,225,225) t.right(135) t.forward(c * 3) c = c - 1 turtle.exitonclick()
e9ab612826132d35b03b98c46fdef6d7bfc3888e
mitchellflax/lpsr-samples
/3-8IntroToObjects/launch2.py
235
3.515625
4
import turtle def drawSquare(ourTurtle): ct = 0 while ct < 4: ourTurtle.forward(100) ourTurtle.left(90) ct = ct + 1 shawn = turtle.Turtle() shawn.backward(200) drawSquare(shawn) turtle.exitonclick()
5cab377556b008ff48dc6b8080f32f9221d9f0f8
mitchellflax/lpsr-samples
/3-3IntroToTurle/square.py
232
3.59375
4
# square.py import turtle # make our turtle rocky = turtle.Turtle() # rocky makes a square lines = 0 while lines < 4: rocky.forward(150) rocky.left(90) lines = lines + 1 # wait to exit until I've clicked turtle.exitonclick()
e354f576673621e8dc851bda02d495a5196f9f7d
mitchellflax/lpsr-samples
/3-6ATkinterExample/remoteControl.py
464
4.28125
4
import turtle from Tkinter import * # create the root Tkinter window and a Frame to go in it root = Tk() frame = Frame(root, height=100, width=100) # create our turtle shawn = turtle.Turtle() # make some simple buttons fwd = Button(frame, text='fwd', fg='red', command=lambda: shawn.forward(50)) left = Button(frame, ...
ed15cbf4fd067d8b9c8194d22b795cb55005797f
mitchellflax/lpsr-samples
/ProblemSets/PS5/teamManager.py
1,525
4.3125
4
# a Player on a team has a name, an age, and a number of goals so far this season class Player(object): def __init__(self, name, age, goals): self.name = name self.age = age self.goals = goals def printStats(self): print("Name: " + self.name) print("Age: " + str(self.age)) print("Goals: " + str(self.goa...
505b7944e773905bd8b1c5c8be4ce6d9a3b58730
mitchellflax/lpsr-samples
/4-2WritingFiles/haikuGenerator2.py
1,548
4.3125
4
# haikuGenerator.py import random # Ask the user for the lines of the haiku print('Welcome to the Haiku generator!') print('Would you like to write your haiku from scratch or get a randomized first line?') print('(1) I\'ll write it from scratch') print('(2) Start me with a random line') user_choice = int(raw_input()...
7e13745a73f6d77bbebcc267c0d4481ba6a86d3a
mitchellflax/lpsr-samples
/3-4FunctionsInTurtle/samplePatternTemplate.py
495
4.25
4
# samplePattern.py import turtle # myTurtle is a Turtle object # side is the length of a side in points def makeTriangle(myTurtle, side): pass # make our turtle kipp = turtle.Turtle() kipp.forward(150) kipp.right(180) # kipp makes triangles centered at a point that shifts # and decreases in size with each loop len...
4a2107cbe21ebb9b44b81c31d82e40d6d309e117
110100100-b2/Goal-Keeping-Agent
/main.py
2,249
4
4
# Main Program can go here, we can load all other modules and run it in this .py file. import turtle # Importing Modules import sys sys.path.insert(0, './modules') import functions import ScoreBoard start = False wn = turtle.Screen() wn.setup(width=839, height=1039, startx = 250, starty = 0) # dimensions and posit...
f9f2cbd0408139865c1cb412a80c1d60b5cc038c
Brian-Musembi/ICS3U-Unit6-04-Python
/array_average.py
1,839
4.1875
4
#!/usr/bin/env python3 # Created by Brian Musembi # Created on June 2021 # This program prints a 2D array and finds the average of all the numbers import random def average_2D(list_2D): # This function finds the average total = 0 rows = len(list_2D) columns = len(list_2D[0]) for row_value in l...
19e082e2f994b16d55ae046ac8c5baf727759888
coreman14/Python-From-java
/CPRG251/Assignment 6/MovieManagementSystem.py
4,716
3.578125
4
from InputVerify import intInputCheck from Movie import Movie from random import shuffle from dotenv import load_dotenv import os import psycopg2 from psycopg2 import OperationalError class MovieManagementSystem(): """Movie Management system redone in python """ def __init__(self): ...
c054b2383fd5b7d7a042d69673d2708aef9be0b1
coreman14/Python-From-java
/CPRG251/Assignment 6/Movie.py
2,090
4.40625
4
class Movie(): def __init__(self, mins:int, name:str, year:int): """Creates an object and assign the respective args Args: mins (int): Length of the movie name (str): Name of the movie year (int): Year the movie was released """ self.mins...
76f4f8296437a2789453406a1dfb4335b00d818c
TomCantrell/Othello-Board-Game
/getLine.py
1,242
3.59375
4
""" Line of opponents pieces """ def getLine(board,who,pos,dir): lst=list() i=pos[0] j=pos[1] if board[i][j]!=0: return lst while True: if i+dir[0]==8 or j+dir[1]==8: ######need to deal with these better break if i+dir[0]==-1 or j+dir[1]==-1: br...
46ba9a68d7ed4616cbdf597f77c9cfcca7c02132
TomCantrell/Othello-Board-Game
/game.py
23,523
4.03125
4
import othello as pf pf.play() """ A Python module for the othello game. This module comprises of many functions which all contribute to the final main function play() which deals with the actual game flow. Full name: Thomas Cantrell StudentId: 10170539 Email:thomas.cantrell@student.manchester.ac.uk """ def new...
c83e073c42b1e784ebad334a97c1399c0083a5a7
MajidSalimi/Python-Learning
/Input/Input.py
236
3.984375
4
name=input('Please Enter Your Name:') number=int(input('Please enter your age:')) height=float(input('Please enter your age:')) print('Name:',name.title()) print('Age:',number) print('Height:',height) print('Age/10=',eval('number/10'))
e71728e73143aafec0819f03fb2cadd550c5de49
84omidreza/jalase8
/complex .py
1,056
4.0625
4
def sum_complex(x , y ): result_calculation={} result_calculation['kamel'] = x["kamel"] + y["kamel"] result_calculation['mohomi'] = x["mohomi"] + y["mohomi"] return result_calculation def sub_complex(x , y): result_calculation={} result_calculation["kamel"] = x ["kamel"] - y ["kamel"] ...
34d705727c44475ce5c1411558760a01969ef75b
Syvacus/python_programming_project
/Session number 2.py
2,246
4.1875
4
# Question 1 # Problem: '15151515' is printed because the chairs variable is text instead of a number # Solution: Convert the chairs variable from text to number chairs = '15' # <- this is a string (text) rather than an int (number) nails = 4 total_nails = int(chairs) * nails # <- convert string to int by wrapping...
320afdfbe5f55615bdbb72e77953a8590e2c840d
NapsterZ4/python_basic_course
/excepciones.py
1,216
3.890625
4
def suma(n1, n2, n3) -> int: return n1 + n2 + n3 def resta(n1, n2, n3) -> int: return n1 - n2 - n3 def multiplicacion(n1, n2, n3) -> int: return n1 * n2 * n3 def division(n1, n2, n3): # Validar division entre 0 try: return n1 / n2 / n3 except ZeroDivisionError: print("No es...
acab7dba850041e5b5283d1a661a00a76b17a8c1
NapsterZ4/python_basic_course
/tuplas.py
492
4.1875
4
# listas que no pueden modificarse a = (1, 4, 5.6, "Juan", 6, "Maria") b = ["Jorge", 5, "Peru", 90] tup2 = 34, "Javier", 9.6, "Murillo" c = tuple(b) # Convirtiendo la lista en tupla d = list(a) # Conviertiendo la tupla en una lista print(tup2) print(a) print(c) # Resultado de la lista convertida en tupla print(d)...
648d64ce99d1259b3be83d322f56eea46af8e5c4
kylemingwong/pytest
/pytest/some-test.py
192
3.734375
4
class MyClass(object): gender = 'Male' def __init__(self,who): self.name = who def sayHi(self): print 'Hello, '+self.name me = MyClass('Tom') me.sayHi()
406ab8c99fbc44eb3d590c6b3c1646d6d0c44ee8
labyrlnth/codeeval
/easy/word_to_digit.py
546
3.84375
4
import sys dic = {'one':'1', 'two':'2', 'three':'3', 'four':'4', 'five':'5', 'six':'6', 'seven':'7', 'eight':'8', 'nine':'9', 'zero':'0'} def word_to_digit(word): return dic[word] def main(): f = open(sys.argv[1], 'r') lists = f...
afe56fea320586725a5e430d8ae2cfafde68fa0c
dipanjank/aws-lambda-simple-forecast
/chalicelib/forecaster.py
1,131
3.8125
4
import pandas as pd def average_forecast(data_dict): """ Take daily data and return the average of the training data as forecast from ``data_dict['start_date']`` and ``data_dict['end_date']``. Dates expected in YYYY-MM-DD format. :param data_dict: The train data and the predict start and end date...
f7e1d7c9e73023370e1a1d6c42d2f372288ab91c
krenevych/ClassWork
/Stat1/OOP4/Car.py
780
3.859375
4
from Mat.OOP4.Figure import Rectangle, Circle, Figure from turtle import * class Car(Figure): def __init__(self, x, y, color): super().__init__(x, y, color) self.properties = [ Rectangle(self._x, self._y, 300, 70, "red"), Rectangle(self._x + 50, self._y + 70, 200, 30, "re...
5bc96545ae14cf28597903acce40e1627537cb68
krenevych/ClassWork
/Stat1/L4/l4_4.py
146
3.765625
4
counter = 0 while True: n = int(input()) if n == 0: break if n % 2 == 0: continue counter += 1 print(counter)
d27062b7f9bc4856251ea85a713c23759f51fc06
krenevych/ClassWork
/Stat1/OOP11/examle.py
719
3.65625
4
from tkinter import * root = Tk() # створюємо головне вікно програми def hello(): res = ent.get() # print("Hello, %s!" % res) lab["text"] = "Hello, %s!" % res # Поле введення ent = Entry(root, font="Arial 18") ent.pack() lab = Label(root, font="Arial 18", bg = "red", ...
c4d001af6e3b30dcd53e358eb4f91a07a32325d7
krenevych/ClassWork
/Mat/L13/t4.py
2,077
3.578125
4
def readMatrix(file_name): try: with open(file_name, "r") as f: matrix = [] for line in f: row = [float(el) for el in line.split()] matrix.append(row) return matrix except FileNotFoundError: return None except ValueError: ...
7a231c32014c5e43a13fb12339b60197ac660660
krenevych/ClassWork
/Mat/L3/l3_2.py
154
3.671875
4
# n = 17 # 2 4 8 16 n = int(input()) res = 2 # 2^1 while res < n: print(res, end=" ") # print(res, end="***") # print(res) res *= 2
3f1ac1cf6059b10139c752dae2f947a297c31d29
krenevych/ClassWork
/Mat/L8/l8_1.py
284
3.59375
4
# 0! = 1 # 5! = 1 * 2 * 3 * 4 * 5 = 4! * 5 # f(n) = n! # f(0) = 1 # f(n) = f(n-1) * n def f(n): if n == 0: # термінальний випадок return 1 else: # рекурсивна гілка prev = f(n - 1) return prev * n print(f(5))
8fe31d5e7a1371e9725898168743b71e9db08b84
krenevych/ClassWork
/Mat/L6/l6_7.py
80
3.65625
4
s = input() lst = s.split() for word in lst: print(len(word), end=" ")
d587eb1da3a6ee2fc2d067a7824e4ac060d2ee8f
krenevych/ClassWork
/Mat/OOP11/t3.py
1,018
3.5625
4
from tkinter import * from tkinter.filedialog import askopenfilename def readFile(file_name, textbox : Text): textbox.delete('1.0', END) with open(file_name, encoding="UTF-8") as f: textbox.insert('1.0', f.read()) def main(): root = Tk() # створюємо головне вікно програми global textbox ...
4fe1ec4fae56b4a2b96ae9daa9e6a5712598707d
krenevych/ClassWork
/Stat1/L4/l4_5.py
275
3.59375
4
n = int(input()) # 2 * 3 * 5 = 30 # 7 , 49, 343 [1, n^0.5] if n % 2 == 0: print(2) else: flag = True for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: print(i) flag = False break if flag: print(n)
c526d4fd974de335e8aa26447a6442bfcdbce4be
krenevych/ClassWork
/Mat/OOP11/t2.py
662
4.0625
4
from tkinter import * root = Tk() # створюємо головне вікно програми entry = Entry( root, width=70, font="Arial 20", ) listbox = Listbox( root, width=70, height = 15 ) def show_words(): global entry, listbox content : str = entry.get() words = content.split() listbox.delete...
65310340928ed2f77db21a4aa8eac35baf562f61
krenevych/ClassWork
/Stat1/L9/l9_6.py
259
3.796875
4
a = input() b = input() freq_a = {el: a.count(el) for el in a} freq_b = {el: b.count(el) for el in b} # # print(freq_a) # print(freq_b) for k in freq_b: if k not in freq_a or freq_a[k] < freq_b[k]: print("No") break else: print("Ok")
3c2def7535feb672ce3dd63fa2e57172c6be7e52
krenevych/ClassWork
/Mat/L6/l6_5.py
112
3.53125
4
"welcome to python" s = input() res = s[0] for c in s[1:]: if c != res[-1]: res += c print(res)
794f303abeb262ed4ece4ba55bc8b21817f187ee
krenevych/ClassWork
/Mat/OOP11/canvas.py
1,369
3.5625
4
from tkinter import * from tkinter.filedialog import askopenfilename def openPicture(): global canvas filename = askopenfilename() photo = PhotoImage(file=filename) id = canvas.create_image(0, 0, image=photo, anchor=NW) pass def main(): root = Tk() # створюємо головне вікно програми glo...
a23d16e55e2697a3e939126d0e067babc0249373
marcotw2school/schoolstuff
/Geometria/Utilities/Calcolatrice.py
4,954
3.546875
4
# Creato da Marco Sisto - 28/11/2020 import math # finput = FiguraInput # minput = MainInput def rettangolo_parallelogrammo(): finput = input('Cosa vuoi calcolare?: ') if finput == 'Area': base = int(input('Inserisci la Base: ')) altezza = int(input('Inserisci l''Altezza: ')) area = b...
95d7dd2afe45d705d1bbb3884245e1258651f0c0
DHANI4/NUMBER-GUESSING-GAME
/NumberGuessing.py
443
4.28125
4
import random print("Number Guessing Game") rand=random.randint(1,20) print("Guess a Number between 1-20") chances=0 while(chances<5): chances=chances+1 guess=int(input("Enter Your Guess")) if(guess==rand): print("Congratulations You Won!!") break elif(guess<rand): p...
d7494be4817349002aff937d8a33a6720e11fd8b
ArDrift/InfoPy_scripts
/9_het/8_dolgozatok.py
824
4.03125
4
#!/usr/bin/env python3 # A rendezéshez felhasználtam: https://docs.python.org/3/howto/sorting.html#key-functions class Hallgato: def __init__(self, neptun, nev, pont): self.neptun = neptun self.nev = nev self.pont = pont def __str__(self): return "Név: {}, Neptun: {}, Pont: {}".format(self.nev, ...
2e3362025d094d18945d069e065e709bc2209f11
ArDrift/InfoPy_scripts
/13_het/3_Charlie.py
560
3.96875
4
#!/usr/bin/env python3 def main(): fagyik = { "pisztácia": 0, "vanília": 3, "tutti-frutti": 8, "karamell": 4, "rumos dió": 5, "kávé": 9, } iz = input("Fagyi? ") while iz != "": valasz = fagyik.get(iz, -1) if valasz == -1: prin...
70da854d8607eca02688e944098cfbd81639e291
ArDrift/InfoPy_scripts
/2_het/11_haromszog_golyokbol.py
208
3.765625
4
#!/usr/bin/env python3 sorszam = int(input("Add meg a háromszög sorainak számát:")) i = 0 while i < sorszam: print(" " * (sorszam - i - 1), end="") print("o" * (1 + i * 2), end="\n") i += 1
cdc79f173212c6828503091bbf27589e136af03e
ArDrift/InfoPy_scripts
/7_het/6_szamtani-sorozat.py
258
3.609375
4
#!/usr/bin/env python3 def sorozat(elso, incr, sorszam): if sorszam == 0: return elso else: return sorozat(elso, incr, sorszam - 1) + incr def main(): for i in range(10 + 1): print(sorozat(0, 12, i), end=" ") print("") main()
049919709c0a7163789dd0186a4ff5210b350ecb
ArDrift/InfoPy_scripts
/10_het/8_beolvasas-adott-szamrendszerben.py
592
3.609375
4
#!/usr/bin/env python3 # A feladat megoldásához felhasználtam: https://docs.python.org/3/library/stdtypes.html def tizesbe(rendszer, szamstr): res = 0 for b in range(len(szamstr)): if szamstr[b].isdecimal(): res += int(szamstr[b]) * rendszer ** (len(szamstr) - 1 - b) else: res += (ord(szamstr[...
5c86b495b677bd18b4e066d8998531bf9e860913
ArDrift/InfoPy_scripts
/szorgalmi/2_kismutato-nagymutato.py
2,516
4.03125
4
#!/usr/bin/env python3 """ A feladat felkészítéséhez felhasználtam a következő forrást: https://docs.python.org/3/library/turtle.html """ import turtle ora = int(input("Add meg az órák számát: ")) perc = int(input("Add meg a percek számát: ")) masodperc = int(input("Add meg a másodpercek számát: ")) szinmix = [255,...
174f8f924bde5b23d1a2eefc1dfe94400e0848b4
ArDrift/InfoPy_scripts
/2_het/9-1_adott_hosszusagu_szakasz_1.py
168
3.96875
4
#!/usr/bin/env python3 hossz = int(input("Mekkora legyen a szakasz?")) i = 0 print("+", end="") while i < hossz: print("-", end="") i += 1 print("+", end="")
68750d9ff369f0a41d6028c2b92d9168caea65a0
ilya1203/SQL
/sqlwriter.py
4,112
3.65625
4
import sqlite3 class SQLwriter: def __init__(self): self.name = 'db' self.table = '' def create_column(self, columns): db = sqlite3.connect(f'{self.name}.sqlite') cursor = db.cursor() try: cursor.executescript(f""" CREATE ...
fe917d7e04cc15418b25bfaba90722b1ca861632
jgendron/boozonians
/Unit Test Scorer/scorer-testing.py
1,752
3.671875
4
#!/usr/bin/python -tt # 'shroom-scorer ''' This scoring program takes as an argument the input ...blah, blah ...finish documentation ''' def scorer(key, predictions): msg = False #----- # normalize input by ensuring all lowercase and remove whitespace submit = [answer.lower().strip() for answer i...