blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9591f0da88d535004da3f46a2eaf7c46c7c9574d
fletchto99/CSI4133
/labs/lab 4/lab4a.py
716
3.53125
4
# Matthew Langlois # Student # 7731813 #!/usr/local/bin/python3 import numpy as np import cv2 img = cv2.imread('./images/hand.png') hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) # We don't need to do anything on change def change(value): #read the image as grayscale threshold = cv2.inRange(hsv, np.array([valu...
832eadede1e668bf593246b2a5364b2037c933b2
regnart-tech-club/programming-concepts
/course-2:combining-building-blocks/subject-2:functions/topic-5:Higher-Order Functions/lesson-6.0:product puzzle.py
459
4.125
4
# Write a function or lambda using the implementation of fold below that will # return the product of the elements of a list. def or_else(lhs, rhs): if lhs != None: return lhs else: return rhs def fold(function, arguments, initializer, accumulator = None): if len(arguments) == 0: return accumulator else: r...
48d4d93c7c17b66a095f81ff9c9c825a7b7742d4
hearecho/pycommon
/MapStudy.py
931
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/8/28 18:58 # @Author : hearecho # @Site : # @File : MapStudy.py # @Software: PyCharm ''' Map会将⼀个函数映射到⼀个输⼊列表的所有元素上 list元素可以是一组函数 map(func,list) type--><class 'map'> ''' class MapStudy(): def __map(self): items = [1,2,3,4,5,...
c4b9bcc397c9f56a3a5f04f0941b7cf4b797a8ac
matiasconde/Courses
/37_Building a data pipeline/Multiple Dependency Pipeline-266.py
5,005
3.609375
4
## 2. Intro to DAGs ## cycle = [4,6,7] ## 3. The DAG Class ## class DAG: def __init__(self): self.graph = {} def add(self, node, to=None): if node not in self.graph: if to: self.graph[node] = [to] if to not in self.graph: s...
0555d22fb21face14e7190ad098672e415e35507
alephist/edabit-coding-challenges
/python/sum_of_vowels.py
436
3.875
4
""" Sum of v0w3ls Create a function that takes a string and returns the sum of vowels, where some vowels are considered numbers. Vowel Number A 4 E 3 I 1 O 0 U 0 https://edabit.com/challenge/6NoaFGKJgRW6oXhLC """ def sum_of_vowels(sentence: str) -> int: vowel_dict = { 'a': 4, 'e': 3, 'i...
3dfe7bc5cfdd6ff9178ea70b73b0242f484a855d
paladino3/AulasPythnoPOO
/DevMediaPythonCompleto65Horas/Aula49.03.py
210
3.828125
4
import re inputEmail = input(str("Digite seu email: ")) myDomain = re.search("@[\w.]+", inputEmail) if myDomain: print("Seu email dominio é: ",myDomain.group()) else: print("Email whitout domain")
9575fc41deb68face924541421bcb2ef4859eaf9
mandarmakhi/DataScience-R-code
/1. Practice/basic statistics1/Datatypes.py
6,129
3.921875
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 26 07:44:04 2019 @author: Mukesh """ #######Strings############### #syntax for string is " string or text " or ' text ' #Accesing Value in Strings or slicing the values Name = "excelr" #positive and negative formats # e x c e l r # 0 1 2 3 4 5 # -5 -4 -3 -2 ...
799a959779f1d4accab8e71de00a132f57a487bb
calanoue/GFIN_Data_Work
/get_numpy_dtype.py
3,067
3.546875
4
""" Functions to help with data formatting and analysis. """ from re import search def format_creates(sql_statements): """ Format DDL Create Statements """ create_strs = [] for i in sql_statements: i = i.replace("]", "") i = i.replace("[", "") create_str = "" for j i...
56b3f4d90c4306dfb5dcf696f58cfe17eadd533d
driellevvieira/ProgISD20202
/Dayana Vieira/Atividade 5 e 6/Aula 5/aula 5.py
794
3.8125
4
lista = [] print(lista) lista = ["Ó carro", "peixe", 123, 111] print (lista) lista = ["Ó carro", "peixe", 123, 111] nova_lista = ["pedra", lista] print (nova_lista) lista = ["O carro", "peixe", 123, 111] nova_lista = ["pedra", lista print (lista [0]) print (lista [2]) print (nova_lista [1]) print (nova_lista [1][2])...
0c607f6a8b20a1287a300d08b2a9ca4163cdcbe4
Frensis7153/python
/1_6.py
204
3.5625
4
a = int(input("a = ")) b = int(input("b = ")) i = 1 while a < b: i += 1 a += a / 10 print(f"На {i}-й день спортсмен достиг результата - не менее {b} км")
6506268d9c4e92f0c9fa9c4ca01806fdfab96b8e
pratikshas8080/PYTHON_Daily_Code_2021
/functions.py
195
3.6875
4
#functions def greet(): print("Gm Sir") greet() #function2 a=int(input("Enter First Number")) b=int(input("Enter Second Number")) def sum(a, b): c=a+b return c d=sum(a,b) print(d)
4e7a35cd157b7a83c0f1617d1acd77f844bdc045
KuptsovYa/Face-Detecter
/camera.py
885
3.546875
4
"""Камера без создания отдельного процесса.""" import cv2 import numpy as np class CameraError(IOError): pass class Camera: filter = lambda x: x def __init__(self, cam_num=0, cam_wh=(320, 240)): self.cam_num = cam_num self.cam_wh = cam_wh self.cam = cv2.VideoCapture(self.cam_nu...
7e05341635851a93944090bd1fdba22d5fe9dac6
wai030/Python-project
/3Missionaries 3Cannibal.py
4,957
3.84375
4
import copy #Missionaries and Cannibals (Missionaries and Cannibals) ####################### ## Data Structures #### ####################### # The following is how the state is represented during a search. # A dictionary format is chosen for the convenience and quick access LEFT=0; RIGHT=1; BOAT_POSITION=2 Missi...
f7783b2f9f5bb16757983369a7018c423f1cb9e1
naru380/AtCoder
/ABC/149/C/source.py
794
3.515625
4
import math # エラストテネスの篩 def eratosthenes(limit): A = [i for i in range(2, limit+1)] P = [] time = 0 while True: prime = min(A) if prime > math.sqrt(limit): break P.append(prime) i = 0 while i < len(A): if A[i] % prime == 0: ...
b155eebedbd982a904ceecc83921369107909199
ericmuzz/itc110
/ITC110/pumpkincanon.py
846
4.125
4
import math def main(): angle = float(input("Enter the launch angle(in degrees): ")) speed = float(input("Enter the initial velocity (in m/s): ")) initial_height = float(input("Enter the initial height(in m): ")) time = 0.1 #pumkin start position pumpkin_x = 0 pumpkin_y = initial_height #pump...
1ffdc7c130c40f1f1f51c83b8131fde5214e4bad
xNiallC/DQSCoursework2
/Archive/GuiTest.py
2,240
3.546875
4
from Tkinter import * import ttk import csv def returnSurname(*args): with open('MOCK_DATA.csv') as csvfile: reader = csv.reader(csvfile) nameinput = str(name.get()).lower() for row in reader: if nameinput == row[0].lower(): answer1.set("--> " + row[1]) ...
b1aee0cd2e3ecb9b562fea554810eed112b29152
Aasthaengg/IBMdataset
/Python_codes/p03079/s358392293.py
204
3.78125
4
import sys # 標準入力を読み込み,float型へ変換 s = input().split() f = [ float(x) for x in s] # 正三角形の条件 if (f[0]==f[1] and f[1]==f[2]): print('Yes') else: print('No')
bf854aeba6852a13cfbcb4d78f326fb5f64c86eb
NiklasMelton/research_code
/Unified SL-RL/PreGitCopies/newTrack.py
1,955
3.5
4
#ready! set! race! import pygame, math pygame.init() size = width, height = 1000, 600 screen = pygame.display.set_mode(size) white = 255,255,255 black = 0, 0, 0 color = 255,255,0 font = pygame.font.SysFont("Comic Sans MS", 12) track = [] print('StartLine!') xa = int(input('x1')) xb = int(input('x2')) ya = int(input('...
2a2d71c618ff4e64910fb4a8f05b9db136701471
IliaLiash/python_start
/lists/google_search_1.py
268
4.0625
4
#Displays all entered lines in which search word occurs n = int(input()) my_list1 = [] for i in range(n): s = input() my_list1.append(s) keyword = input().lower() for element in my_list1: if keyword in element.lower(): print(element, end='\n')
320d5930f8b313c71ff297ae6d354e791cdb712d
593413198/DataStructure
/Python/queue.py
635
4.125
4
#!/usr/bin/python3 # @brief: 队列的python实现 # @date: 2019,5,5 # @author: luhao class Queue(object): def __init__(self): self.Q = [] def isEmpty(self): return True if self.Q==[] else False def size(self): return len(self.Q) def push(self,x): self.Q.append(x) d...
71851fc9eaa33460e31ddafe4f06a6ed5ae0dd19
Poornaprasad/ProtoThon01
/text formatter.py
408
4.15625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: print("Enter the Sentence") a=input() n=len(a) print("1.all caps") print("2.small caps") print("3.title case ") print("4.start case") choice=int(input("type 1/2/3/4: ")); if(choice==1): print(a.upper()) if(choice==2): print(a.lower()) if(choice==3): print(a....
504944745a63384d263acd94e8949ef029a73b99
anilreddy2896/hard
/Python/Advanced_python/multi_threading/multi15.py
295
3.53125
4
# why synchronization from threading import * import time def wish(name): for i in range(10): print("good morning: ",end='') time.sleep(3) print(name) t1=Thread(target=wish,args=('dhoni',)) t2=Thread(target=wish,args=('anil',)) t1.start() t1.join() t2.start()
6d8c1c68cd2aa67c1f996080c92314cae10aaa94
ayanchyaziz123/AI-Assignment
/AI_LabAssign_03_DLS_181-115-086.py
1,462
3.734375
4
from collections import defaultdict import sys mx = [] def dfs(node, parent, height, vis, tree, dest): # calculate the level of every node # if node is not equal to parent if node != parent: height[node] = 1 + height[parent] parent = node print("Explored", node ,"at dep...
665e5a725407a4c355c79d428c80e1556ba53a79
anwarch0wdhury/SoftwareTesting
/test.py
7,292
3.984375
4
import unittest from itertools import * import numpy as np from decimal import Decimal from fractions import Fraction import operator def lzip(*args): return list(zip(*args)) class Test_itertools(unittest.TestCase): ''' Make an iterator that returns evenly spaced values starting with number start...
24c1b7e242fa4dc5474cdca2c4c61e2caac41cde
ThomasZumsteg/project-euler
/problem_0042.py
1,534
4.03125
4
#!/usr/bin/env python3 """ The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangle numbers are: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. ...
a10655a6d5f299819028f220765000db0a73d673
danielgu88/coffee-machine
/stage5.py
3,922
3.96875
4
water = 400 milk = 540 beans = 120 cups = 9 money = 550 ESPRESSO_WATER = 250 ESPRESSO_BEANS = 16 ESPRESSO_MONEY = 4 LATTE_WATER = 350 LATTE_MILK = 75 LATTE_BEANS = 20 LATTE_MONEY = 7 CAPPUCCINO_WATER = 200 CAPPUCCINO_MILK = 100 CAPPUCCINO_BEANS = 12 CAPPUCCINO_MONEY = 6 DRINK_CUPS = 1 def coffee_machine_state(): ...
ac0fedf2a9dfe237b8669b9e536ca75957214711
coderman9/AdventOfCode
/1/soln_2.py
184
3.609375
4
with open("input", "r") as f: input = f.readlines() def f(x): q = x//3 - 2 if q > 0: q += f(q) return max(q, 0) r = sum([f(int(x)) for x in input]) print(r)
aae210462db52ebc63d1157df9ff253c067e622a
melo4/jianzhioffer
/礼物的最大价值.py
695
3.625
4
# -*- coding: utf-8 -*- # @Time : 2019/4/15 下午8:29 # @Author : Meng Xiao class Solution: def getMaxValue(self, values, rows, cols): if not values or rows <= 0 or cols <= 0: return 0 max_value = [0] * cols for i in range(rows): for j in range(cols): ...
fb5db037b4e1858a44a78f58bfa8b9fd6621af21
BlackPokers/Black_Poker
/Python_Server/bp/Deck.py
1,883
3.609375
4
import random import Card class Deck: def __init__(self, card_list: list): """ デッキ :param card_list: カードのリスト """ self.card_list = card_list def first_step(self): """ ターンの最初のドロー :return: ドローしたカード """ return self.get_top() def ...
a86fb238467352e382900f729e7e6e5335155390
ArtemFrantsiian/algorithms
/trees/traversals/Binary Tree Postorder Traversal/python/solution.py
1,088
3.859375
4
import unittest from typing import List class Node: def __init__(self, val=None, left=None, right=None): self.val = val self.left = left self.right = right def postorder(root: Node) -> List[int]: if not root: return [] result = [] stack = [(root, False)] while s...
fd090b4e4b659a74dcfd0c1fb837e35be5ae5230
anirudhbandi96/Project-Euler-Solutions
/10001st_prime_number.py
687
3.921875
4
import math import time def is_prime(integer): """Returns True if input is a prime number""" if integer < 2: # remove long if using Python 3 return False if integer == 2: return True if integer % 2 == 0: # which can also be written as -> if not integer & 1: return False for ...
f500f7e69fa4287b3a20a2af6b4c0cdf4ab99fb1
possibleit/LintCode-Algorithm-question
/maximumSwap.py
1,749
3.734375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- ''' @Author : possibleit @Date : 17:10 2019/3/29 @Description : 给定一个非负整数,你可以交换两个数位至多一次来获得最大的合法的数。 返回最大的合法的你能够获得的数。 1.给定的数字在 [0, 10^8] 内。 @Example : 样例1: 输入: 2736 输出: 7236 解释: 交换数字2和数字7. 样例2: 输入: 9973 输出: 9973 解释: 不用交换. @Solution : ...
c912d8a378c4a08b1f119ee17017a7f792742e6b
arnika13/Fun_With_Python_Graphics
/rainbow.py
358
3.53125
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 3 13:44:40 2018 @author: LocalUser """ import turtle turtle.bgcolor("black") colors=["yellow","blue","red","green","orange","purple","pink"] t = turtle.Turtle() t.speed(20) for x in range(360): t.pencolor(colors[x%len(colors)]) t.width(x/150+1) t.forward...
02bf55e56b9948cd7d5151a44070d7713a4878e7
programhung/learn-python
/PythonCode/Maths/ex3.py
623
3.59375
4
# Calculate function def ecal(enumber): money = 0 if enumber < 0: print("The electrical number cannot be negative!") return 0 if enumber <= 50: money = enumber * 4 return money if enumber <= 100: money = 50 * 4 + (enumber - 50) * 3 return money else: money = 50 * 4 + 50 * 3 + (enumber - 100) * 2 re...
7902f291a8dc1fac5dc0c5549e79c8a3717a1c2f
theMkrv/Deses
/Sam_rab_5.py
409
3.609375
4
class Value: def __init__(self, val=0): self.val = val def __get__(self, obj, obj_type): return int(self.val) def __set__(self, obj, value): self.val = value - value * obj.commission class Account: amount = Value() def __init__(self, commission): self.commission = ...
be891202c9ed8d469ba9cb58ad15d01a09656f1c
RancyChepchirchir/AI-1
/week3/__init__.py
16,736
4.09375
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt def calc_posterior_p(): # GRADED # Given the values in the tables above, calculate the posterior for: # "If you know a user watches Youtube every day, # what is the probability that they are under 35?" # Assign float (posteri...
f40bf6c35a51536c365f49519e516e955baa423a
CorCobLex/UniumWork
/RectangleAndCircles.py
857
4.15625
4
while(True): print("Введите длину прямоугольника:") lenght=int(input()) print("Введите ширину прямоугольника:") height=int(input()) print("Введите радиус 1 окружности:") radius1=int(input()) print("Введите радиус 2 окружности:") radius2=int(input()) SRec=height*lenght ...
39e852db11760733c076461841c6b9c9c9cce06a
Charleina/cs_362
/hw3/leapyear.py
857
4.09375
4
#to run the file please type: python charlene_wang_hw1.py #it should print out the values #years for user input y = input("Enter year: ") #checking the values in the array to see if they match the criteria for leap years, if they do i will print true and their value if not i will print false and their v...
32a37585aeb9d5f357074d190436dab4c29cccdc
leomarkcastro/Arithmetic-Progression-Project
/yield.py
128
3.703125
4
def fun(): x = 0 while True: x += 1 yield x x = fun() for i in range(30): print next(x)
32b5d863b1fcf585f6b90b9c22d9c941978c7f71
akimi-yano/algorithm-practice
/lc/581.ShortestUnsortedContinuousSuba.py
1,691
4.03125
4
# 581. Shortest Unsorted Continuous Subarray # Medium # 3431 # 165 # Add to List # Share # Given an integer array nums, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order. # Return the shortest such subarray and ou...
a8f2e7f5ed2d4c5c2742497c77a8105ece6353e4
WeaselE/Small-Programs
/List Squared.py
281
3.96875
4
def num_squared(num): return int(num ** 2) lst = [int(i) for i in input("Enter numbers to square them (spaces between numbers): ").split()] if lst: sqr_lst = [num_squared(i) for i in lst] else: lst = range(11) sqr_lst = [num_squared(i) for i in lst] print(sqr_lst)
02e46c01a9a647d2563f1a507c709046f2c37fe0
khalid-hussain/python-workbook
/01-Introduction-to-Programming/031-units-of-pressure.py
364
3.921875
4
pressure = float(input('Input pressure (kilo-pascals): ')) poundsPerInchSquare = pressure * 0.145 mmHg = pressure / 0.1333223684 atm = pressure / 101.325 print('Pressure in pounds per square inch is {:.2f}.'.format( poundsPerInchSquare)) print('Pressure in millimeter mercury is {:.2f}.'.format(mmHg)) print('Press...
069eb2c5c87376609c6befae31676ca0122670b3
vijulondhe/Weather_Data_Storage_Retrieval
/database.py
1,578
3.53125
4
# Imports MongoClient for base level access to the local MongoDB from pymongo import MongoClient class Database: # Class static variables used for database host ip and port information, database name # Static variables are referred to by using <class_name>.<variable_name> HOST = '127.0.0.1' PO...
e420142492b65b26ee0cb1e9c13ba610e8e9ecc0
tejas-rane/pyground
/Lambda-Map-Filter/2_check_even.py
118
3.515625
4
def check_even(num): return num % 2 == 0 my_nums = [0, 1, 2, 3, 4, 5, 6] print(list(filter(check_even,my_nums)))
5a0976a84a8d17e6d1735b99e3cee311a91aa8bc
inishchith/GithubTools
/GithubIssues.py
1,139
3.640625
4
import requests import sys #getting url response using requests API def get_responses(url): r = requests.get(url) response = r.json() return response['total_count'] #main function if __name__ == '__main__': statistics = {} username = (input("\nEnter github username\n")) url = "https://api.github.com/search/is...
ba0760b5ed1310de8fbe4d5ad924c7d0e21a0bf2
ikki2530/holberton-system_engineering-devops
/0x16-api_advanced/2-recurse.py
1,098
3.625
4
#!/usr/bin/python3 """ queries the Reddit API and prints the titles of the first 10 hot posts listed for a given subreddit. """ import requests def new_recurse(subreddit, hot_list=[], page=''): """Adding new recursion""" titles = [] if page is None: return hot_list if subreddit: try: ...
a402a8172f68c5f238bb6c0b2eb98f58a60f0169
Moelf/S19-129L
/Zach/hw2/ex2.py
727
4.125
4
#!/usr/bin/env python3 sent=input("Please input a sentence: ") list1=[len(x) for x in sent.split()] #Count all characters excluding only spaces; includes punctuation in 'characters' sent=sent.replace(',',' ') #separates words by commas, etc sent=sent.replace(';',' ') #Francesco said this was the punctuation that mat...
4be6438b7bffe1276a9570756eab4912019814fa
srijaniintm/Code-Combat
/Python/01-Alan's-Number-Game.py
353
4.125
4
# function to reverse the number. def reverse(n): temp,rev,rem = n, 0, 0 while temp != 0: rem = temp % 10 if temp < 0: rem = rem - 10 rev = rev*10 + rem temp = int(temp/10) return rev n = int(input()) # taking input. print(n+reverse(n)) # printing the additio...
5e9f3b87b96f468e7bb28b32dbd49c6494b0841a
Garen-Wang/ai-learning
/ch02/02-2.py
1,252
3.625
4
import numpy as np import matplotlib.pyplot as plt def forward(x): a = x ** 2 b = np.log(a) c = np.sqrt(b) return a, b, c def backward(x, a, b, c, y): loss = c - y delta_c = c - y delta_b = 2 * np.sqrt(b) * delta_c delta_a = a * delta_b delta_x = delta_a * 0.5 / x ...
a4cdf390f0df7bb95e5a5e979d5c2f84fa465720
YulanJS/Advanced_Programming_With_Python
/HW5.py
4,986
4.125
4
# ---------------------------------------------------------------------- # Name: HW5 # Purpose: Practice lambda, decorator, and generator # # Date: Spring 2019 # ---------------------------------------------------------------------- """ Five questions to practice lambda, decorator, and generator. For ...
504017f5fdd51c17701331aab358d5cea2a22e69
sjindal22/python-programming
/csv-parse-condition.py
336
4.03125
4
import csv def csvParser(file): with open(file, 'r') as f: csvFile = csv.reader(f, delimiter=",") header = next(csvFile) print(header) for people in csvFile: if(int(people[1]) >= 30): print("Name: {name}, City: {city}".format(name=people[0], city=people[2])) csvParser("sam...
9e6cb1cb56799eb64a080227a71d1db17941f1f2
Kingcitaldo125/Python-Files
/src/colors.py
1,550
3.90625
4
#Color Library class ColorLibrary(object): def __init__(self): """ """ self.colors = {"red":(255,0,0),"green":(0,255,0), "blue":(0,0,255),"cyan":(0,225,255),"yellow":(236,236,17), "orange":(234,122,7),"purple":(228,29,212),"white":(255,255,255), "black":(0,0,0)} def ret...
cb902c25e21843a6be43beff67a2cb12aca4a3a4
Aasthaengg/IBMdataset
/Python_codes/p02263/s885602482.py
385
3.640625
4
rp = [ele for ele in input().split()] op = ['+','-','*'] stack = [] for ele in rp: if ele not in op: # ele is number stack.append(eval(ele)) else: # ele is operator num_2 = stack.pop() num_1 = stack.pop() if ele == '+': stack.append(num_1 + num_2) elif ele == '-': stack.append(num_1 - num_2) els...
7d7573627f9bd7b1362daa634996fe8847098398
jeffreyegan/DataScience
/Unit2_Pandas/lambda.py
2,896
4.125
4
'''Create a lambda function named contains_a that takes an input word and returns True if the input contains the letter 'a'. Otherwise, return False.''' #Write your lambda function here contains_a = lambda word : 'a' in word print(contains_a("banana")) print(contains_a("apple")) print(contains_a("cherry")) #Write yo...
ca98172abbc4eb2435cd53c558d0a529ea8dfeba
padymkoclab/python-utils
/utils/number.py
9,067
4.3125
4
"""Utils for numbers.""" import math def get_count_digits(number: int): """Return number of digits in a number.""" if number == 0: return 1 number = abs(number) if number <= 999999999999997: return math.floor(math.log10(number)) + 1 count = 0 while number: count +=...
0a8d9e158e118d952a535ba6bc4a2cdc37defbd3
aish2028/labquestion
/q12.py
235
3.875
4
str=input("enter the sentense:") lst=['does','do','is','are'] res=filter(lambda x:x.startswith(lst),str) if res: print("interogative") else: print("assertive") question=input("enter the question:") if question.endswith
12343fc4e83a7b97baa9ad33b00d44ac4a388d6d
LazyDog1997/LazyDog-Belajar
/ifelse.py
406
3.890625
4
print("Latihan If Elif Else") print(15*"-") nilai = float(input("Masukkan Nilai :")) if nilai >= 80: print ("Nilai", nilai, "Adalah A") elif 68 <= nilai < 80: print ("Nilai", nilai, "Adalah B") elif 55 <= nilai < 68: print ("Nilai", nilai, "Adalah C") elif 40 <= nilai < 55: print ("Nilai...
a64ad2f57ab0bd1bced210f6b3597fcec1c6c0b4
offbr/Python
/pybasic/pack2/func7.py
276
3.671875
4
''' Created on 2016. 10. 25. 재귀함수 : 함수가 자신을 호출 - 반복처리 ''' def Countdown(n): if n == 0: print('처리완료') else: print(n, end= ' ') Countdown(n - 1) #이게 재귀 Countdown(5) print() print('다음 작업')
f84cc3a059957b556c09890da4146edc8ffcf735
RogerMCL/PythonExercises
/Ex091.py
683
3.609375
4
# EXERCÍCIO 091: from random import randint from time import sleep from operator import itemgetter dic_jog = dict() for c in range(0, 4): dic_jog[f'Jogador {c + 1}'] = randint(1, 6) for k, v in dic_jog.items(): print(f'{k} tirou {v} no dado!') sleep(1) print('\n\t', '=' * 10, 'RANKING', '=...
24c62a0bcb513fe71da3bb33cb01c7822fb40f93
liuyanhui/leetcode-py
/leetcode/total-hamming-distance/total-hamming-distance.py
2,164
3.9375
4
class Solution: """ https://leetcode.com/problems/total-hamming-distance/ 477. Total Hamming Distance Medium """ def totalHammingDistance(self, nums): return self.totalHammingDistance_2(nums) def totalHammingDistance_1(self, nums): """ 暴力法,必然会导致超时 :param num...
9ccb5f46a8dd38443d3193f4bd634d31f471fd30
wenziyue1984/python_100_examples
/016输出日期.py
617
4.0625
4
# -*- coding:utf-8 -*- __author__ = 'wenziyue' ''' 输出指定格式的日期 ''' from datetime import datetime def print_date(date_str): try: date = datetime.strptime(date_str, '%Y-%m-%d') print(date.strftime('%Y--%m--%d')) print('{}年{}月{}日'.format(date.year, date.month, date.day)) except ValueError as e: print(e) if __...
2d7fdd490841744f6f41618a8645284d73204807
whitegreyblack/Spaceship
/spaceship/classes/point.py
1,546
3.765625
4
import math class Point: __slots__ = ('x', 'y') def __init__(self, x, y): self.x, self.y = x, y def __repr__(self): return f"{self.__class__.__name__}: ({self.x}, {self.y})" def __iter__(self): return iter(tuple(getattr(self, var) for var in self.__slots__)) def __add__(se...
11563165481f331051f21fee2ec1e9e0e1a46d12
rhenderson2/python1-class
/chapter08/hw_8-8.py
702
4.25
4
# homework assignment section 8-8 def make_album(artist_name, album_title): """Return an artist and album neatly formatted.""" album = {'name': artist_name, 'title': album_title} return album while True: print("\nPlease tell me an artist's name and album title: ") print("(enter 'q' at any time to q...
93d91b404b260563f6acd5aec5265a7e3778241b
Regulator13/Blackjack
/Milestone_Project2.py
5,281
3.828125
4
''' Blackjack Game By Isaiah Frey Allows the user to play a one-on-one blackjack game vs. a dealer The player will place bets on their initial hand and then hit or stay The dealer will then hit until it beats the player or busts Finally the player will recieve compensation for his bets ''' #-----------------L...
a18dfdafd706cb68d82d45b4529e6335eaeb486d
isennkubilay/pythontricks
/tr1.py
193
4
4
#Write a Python program to calculate number of days between two dates. from datetime import date f_date = date(2019, 5, 29) l_date = date(2019, 6, 1) delta = l_date - f_date print(delta.days)
d9930672ea07b91ed61695a45cb0478470532d7f
LundAtGH/Reva_Proj_0_Bank_API
/daos/bank_acct_dao.py
873
3.546875
4
# Data Access Object (Bank Account) from abc import abstractmethod, ABC class BankAcctDAO(ABC): @abstractmethod def create_bank_acct(self, bank_acct): pass @abstractmethod def get_bank_acct(self, bank_acct_id): pass @abstractmethod def all_bank_accts(self): pass ...
d24d2dd097d3be88b22f0b337ba3b5a162e29622
roottor38/Algorithm
/programmers/python/최대공약수와회소공배수/solution.py
611
3.609375
4
# def solution(n, m): # answer = [] # for i in range(n, 0, -1): # if m%i == 0 and n%i == 0: # answer.append(i) # break # a= (n*m)//answer[0] # answer.append(a) # return answer def solution(n, m): answer = [] test = [] for i in range(n, 0, -1): ...
70db5f481e6d4684426e1d6ab4c55e01e1374a0e
aleksandromelo/Exercicios
/ex062.py
273
3.8125
4
n = int(input('Quantos termos você quer ver? ')) c = 2 anterior = 0 proximo = 1 print(f'{anterior} -> {proximo} ->', end='') while c < n: atual = anterior + proximo print(f'{atual} -> ', end='') anterior = proximo proximo = atual c += 1 print(' FIM')
1ddc59d0b368a2f50097560e20fcb55da15ab06f
federicodc05/Calculator
/__dependencies__/__graphs__/custom_graph.py
940
3.859375
4
import numpy as np import matplotlib.pyplot as plt from tkinter import * def poly_graph(poly, x_range): x = np.array(x_range) y = eval(poly) plt.plot(x, y) plt.title("y="+poly) plt.grid(True) plt.axhline(linewidth=2, color='gray') plt.axvline(linewidth=2, color='gray') plt...
0c84219a48617e8a862ae4eeff99678b70a8fdf8
rafaelperazzo/programacao-web
/moodledata/vpl_data/8/usersdata/88/3801/submittedfiles/imc.py
354
3.53125
4
# -*- coding: utf-8 -*- from __future__ import division peso= input('informe seu peso em kilos: ') alt= input('informe sua altura em metros: ') IMC=(peso)/(alt)**2 if IMC<20: print ('ABAIXO') if 20<=IMC<=25: print ('NORMAL') if 25<IMC<=30: print ('SOBREPESO') if 30<IMC<=40: print ('OBESIDADE') if IMC>...
0de44f6636e43693b52a876fa6f527be6b8e24d5
SeattleTestbed/clearinghouse
/common/util/decorators.py
8,846
3.65625
4
""" <Program> decorators.py <Started> 6 July 2009 <Author> Justin Samuel <Purpose> These define the decorators used in clearinghouse code. Decorators are something we try to avoid using, so they should only be used if absolutely necessary. Currently we only use them for logging function calls (such as th...
0d712a00e7b061b45cc7b9f9a0307b0e01568beb
jikka/pythong
/div2.py
129
3.703125
4
a=int(input("Enter a number ")) d=[] e=0 while(a>0): print(a) d.insert(e,a) e=e+1 a=a/2 print(list(reversed(d)))
f5e4df78f54156f8dc32449b46fe14bb71ee0023
SKREFI/p
/sandbox/python/twitter.py
2,074
4.09375
4
def combinations(list_get_comb, length_combination): """ Generator to get all the combinations of some length of the elements of a list. :param list_get_comb: (list) List from which it is wanted to get the combination of its elements. :param length_combination: (int) Length of the combinations of the eleme...
75002e26b132a696e99a7aa0f718267236564c4c
fiqhyb/Trajectory-Assignment
/traject.py
924
3.671875
4
import matplotlib.pyplot as plt import random if __name__ == '__main__': #Coordinates and Equations numx = list(range(0,26))#range is 26 for display purpose numy = [((x**2)-(3*x)+4) for x in numx] ranx = list(random.randint(0,25) for p in range(4000)) rany = list(random.randint(0,600) for ...
443192c3d7ae69182c83c19b171fd1e4d2c5ec7d
namhee33/doublylinkedlist
/doublyLL.py
2,478
4.03125
4
class Node(object): def __init__(self, value=0, prev=None, next=None): self.value = value self.prev = prev self.next = next class DoublyLinkiedList(object): def __init__(self, first=None, last=None): self.first = first self.last = last def traverse_forward(self): node = self.first while node is not N...
7fc5942a184af626ac6518393b16b6fb2e92c443
jpang023/MH8811-G1901960C
/06/H1.py
248
3.6875
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 18 20:11:07 2019 @author: JIAMPAN """ import mod1 n=input("What is the length of your password:") try: num = int(n) print(mod1.genPassword(num)) except: print("Please type a number")
22290b7f3d3cbd1082c2fee755f7de4ee4ccf8be
mocmeo/algorithms
/find-chalk-replacer.py
203
3.578125
4
def chalkReplacer(chalk, k): modulo = k % sum(chalk) for i in range(len(chalk)): modulo -= chalk[i] if modulo < 0: return i print(chalkReplacer([5,1,5], 22)) print(chalkReplacer([3,4,1,2], 25))
c25b6619c9d05e567bfa5a3cea82ad56b155b267
simonfqy/SimonfqyGitHub
/lintcode/medium/902_Kth_smallest_element_in_a_bst.py
5,354
3.6875
4
""" https://www.lintcode.com/problem/kth-smallest-element-in-a-bst/description Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ # My own solution, using inorder traversal template in jiuzhang.com. class Solution: """ @par...
0389017af033951b98725099cb227bd72ca80625
AlexandraSem/Python
/Python_week2.1/Zadanie2.py
858
4.3125
4
#1.Запросить у пользователя зарплату.Если зарплата от меньше 100, налог - 3.Если зарплата от 100 до 600, налог - 10 . # Если зарплата от 600 до 2000, налог - 18.Если зарпата более 2000, налог - 22.Вывести'чистую зарплату', налог, и 'глязную зарплату' zarplata = int(input("Введите зарплату: ")) if zarplata < 100: ...
05a6d23d6cb10bdfe3a9f277b20f4bd307ac4e93
Mubelotix/tetris_nsi
/square.py
2,410
4.125
4
class Square: """ A class representing a square. """ color_number = 8 x = 0 y = 0 def __init__(self, color_number, x, y): """ Coords 0;0 is the square to the top left. Square colors: 0 => red, 1 => blue, 2 => green, ...
785c5b062fbd8592d9855f99c5dfce764cef5d8a
linseycurrie/GuessMyFavouriteColour
/precourse_recap.py
186
3.953125
4
colour = "Blue" userInput = input("Guess my favourite colour : ") if userInput == colour: print("Well Done! You got it right!") else: print("Opps, sorry it's not " + userInput)
aa6992a8afabacc35eccf9feff4634ceb263bac5
jonzarecki/textual-mqs
/ResearchNLP/util_files/pandas_util.py
9,568
3.796875
4
import numpy as np import pandas as pd # data analysis lib for python from pandas import DataFrame def shuffle_df_rows(df): # type: (pd.DataFrame) -> pd.DataFrame """ returns a new df with $df rows shuffled :param df: the original df :return: shuffled $df """ return df.iloc[np.random.perm...
7a1e8a3597c1803c66980e2229e60040ae15c778
mxquants/quanta
/example.py
4,387
4.0625
4
# -*- coding: utf-8 -*- """ Example file How to use quanta for machine learning. import os; os.chdir("/media/rhdzmota/Data/Files/github_mxquants/quanta") @author: Rodrigo Hernández-Mota Contact info: rhdzmota@mxquants.com """ import numpy as np import pandas as pd import matplotlib.pyplot as plt from dataHandler impor...
a8aab4f6481fcece5c333a1d5acdd5cc28306a85
Aasthaengg/IBMdataset
/Python_codes/p02256/s069709928.py
327
4
4
#! python3 # greatest_common_divisor.py def greatest_common_divisor(x, y): r = None if x >= y: r = x%y if r == 0: return y else: r = y%x if r == 0: return x return greatest_common_divisor(y, r) x, y = [int(n) for n in input().split(' ')] print(greatest_common_divisor(...
9c593b883c3252e3058e121997f84b177e20d1e9
MasatakeShirai/Python
/chap13/13-1.py
2,057
4.21875
4
#インスタンスにかかわる文法 # インスタンスの生成 # クラス宣言.すべてのクラスは'object'を根底に継承する # 構文 class クラス名(継承元のクラス名) class Shape(object): pass # インスタンス生成 # 構文 インスタンス = クラス名() shape = Shape() #インスタンスの属性 # 個々のインスタンスで保持する属性をインスタンス属性と呼ぶ # 属性はオブジェクトにピリオドで紐づくもの # 最初に_がつくものを慣例的にプライベート属性として扱う. # 両端に__がつくものはシステムで内部的に扱われる shape1 = Shape() shape2 = Shape(...
1fc996509abc58e0609d1b1e7e55813e955d920f
savanddarji/Encryption-using-Shift-Cipher
/Encrypt the shift cipher_JMD.py
846
4.0625
4
################### program for forming shift cipher ######################## from __future__ import division import numpy as np import string a = raw_input("Enter the cipher text: ").lower() key=raw_input('Enter the Key:')#enter the required number of shift key=int(key) num = dict(zip(range(0,26),string.ascii_l...
0d1f50172a3573b6dbb5b74139896fdaf6be0d09
enrro/TC1014-Files-done-in-class
/3.-Segundo parcial/TablaMultiplicacion2.py
242
3.796875
4
''' Created on 04/10/2014 Otra forma de hacer la tabla de multiplicacion @author: A01221672 ''' def multiplica(n): for i in range (1,n+1): for e in range (1,n+1): print( e *i, end ="\t") print() multiplica(2)
f5462cf469f65f806044b6ae70f704908c968538
guilhermeribg/pythonexercises
/bhaskara2.py
753
3.984375
4
import math a = float(input("Digite o valor de a ")) b = float(input("Digite o valor de b ")) c = float(input("Digite o valor de c ")) def d (b,a,c): return(b**2 - 4*(a*c)) def x (b, a): return (-b/2*a) def x1 (b, d2, a): return ((-b + math.sqrt(delta))/(2*a)) def x2 (b, d2, a): return ((-b - m...
4b0be9ac21be53419894000087a234d91195af9d
XinZhaoFu/leetcode_moyu
/733图像渲染.py
2,071
3.515625
4
""" 有一幅以二维整数数组表示的图画,每一个整数表示该图画的像素值大小,数值在 0 到 65535 之间。 给你一个坐标 (sr, sc) 表示图像渲染开始的像素值(行 ,列)和一个新的颜色值 newColor,让你重新上色这幅图像。 为了完成上色工作,从初始坐标开始,记录初始坐标的上下左右四个方向上像素值与初始坐标相同的相连像素点,接着再记录这四个方向上符合条件的像素点与他们对应四个方向上像素值与初始坐标相同的相连像素点,……,重复该过程。将所有有记录的像素点的颜色值改为新的颜色值。 最后返回经过上色渲染后的图像。 示例 1: 输入: image = [[1,1,1],[1,1,0],[1,0,1]] sr = 1, s...
e1d30902868ef467c3d68d951c96278b24fe8f9b
igortereshchenko/amis_python
/km73/Savchuk_Ivan/4/Task4.py
246
3.8125
4
n=int(input("Hello, please enter the number of students:",)) k=int(input("Please, enter tne number of apples:",)) d1=k//n d2=k%n print('The number of students which are took apples:',d1) print('the number of apples which are not took:',d2)
31060f5e033ccb1e4cecce707ecc7a7cafe4de0c
Ayselin/python
/name.py
240
3.9375
4
def word_count(string): new_list = string.split() unique = set(new_list) my_dict={} for unique in new_list: my_dict[unique]=new_list.count(unique) return my_dict print(word_count("hello olla hello Hi hi yes Yes no no"))
abe8072cf4309c98beb0c89630a6778497293ede
yyzz1010/leetcode
/461.py
329
3.609375
4
class Solution: def hammingDistance(self, x: int, y: int) -> int: # len('{0:b}'.format(2 ** 31)) = 32 binary_x = '{0:032b}'.format(x) binary_y = '{0:032b}'.format(y) count = 0 for (x,y) in zip(binary_x, binary_y): if x != y: count += 1 retu...
bee6328495ea125dfae3d69bfac24f1bf0848436
ISQA-Classes/3900samples
/11_testing_debugging/complete/p5-2_guesses.py
1,005
4.15625
4
#!/usr/bin/env python3 import random def display_title(): print("Guess the number!") print() def get_limit(): limit = int(input("Enter the upper limit for the range of numbers: ")) return limit def play_game(limit): number = random.randint(1, limit) print("I'm thinking of a number from 1 to ...
97076dd53da98f5c60c38113ab522f7473d97608
blacksheep/blacksheep-mapgeo
/web/distance.py
586
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import math def calc_distances_of(a, b, r =3443.9): # 3963.1 statute miles # 3443.9 nautical miles # 6378 km return math.acos( math.cos(a[0]) * math.cos(b[0]) * math.cos(a[1]) * math.cos(b[1]) + math.cos(a[0])* math.sin(b[0]) * math.cos...
69e010aaf96e5708729d083d5c471ff520f7d324
thesmigol/python
/1013.py
556
3.609375
4
a = None b = None c = None ganhou = None kkkkkkkkk_eh_maior_po = None lista = None valores_de_entrada = None def read_line(): try: # read for Python 2.x return raw_input() except NameError: # read for Python 3.x return input() valores_de_entrada = read_line() lista = valores_de_entrada.split(" ")...
059f332cf6c0eec7b3220af10e8764f52d1705f3
EmandM/ladebug
/commandLine/exercises/tutorial.py
1,281
3.84375
4
''' Use the column on the far left to 'flag' lines in the code that contain errors. Find and flag an error line, then click the Fix Errors tabs above to edit the code. Once you've fixed the error, click the Flag Errors tab to go back and run your code. When all errors are fixed, submit your solution below. Fo...
61360f98175a01562c290bc56dbb15ffa9ed1abb
elj/mailbox-doors
/sound-playback.py
5,878
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Name: 010_sound_only_no_graphic.py Purpose: demonstrate use of pygame for playing sound & music URL: http://ThePythonGameBook.com Author: Horst.Jens@spielend-programmieren.at Licence: gpl, see http://www.gnu.org/licenses/gpl.html works with pyhton3.4 and pyth...
38b393c998de2536289111af29d457dc8bc226ac
dslu7733/functional_python_programming
/chapter1_函数式编程概述/sample.py
2,665
3.671875
4
#!/usr/bin/env python #-*- coding:utf-8 -*- #+--+--+--+--+--+--+--+--+--+-- #author : lds #date : 2020-04-16 #function : #+--+--+--+--+--+--+--+--+--+-- __author__ = 'lds' # sample 1 class Summable_List( list ): def sum(self): s = 0 for i in self: s += i return s sumOfL...
402260456db0d4b2086160fde3810789881bfdff
Nohxy/PyLearn
/lesson.py
427
4.21875
4
# Calculator a = float(input("Inter first number: ")) b = float(input("Inter second number: ")) v = input("Chose +,-,*,/ : ") str(v) if v == '+': c = a + b print("Your number is: ",c) elif v == '-': c = a - b print("Your number is: ",c) elif v == '*': c = a * b print("Your numbe...
d040b42447b41f596b0ab97d0a52d028ed9ac45a
hussainMansoor876/Python-Work
/Python/Random function.py
176
3.515625
4
from random import randint mylist=[] for val in range(0,10): num = randint(1, 10) if (num in mylist): del num else: mylist.append(num) print(mylist)