blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2411fd121ebe80d0983fe0230697879bf23248e2
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/7dfed2d8-675b-4e87-b28d-6a0ad1781636__square_roots.py
3,149
3.9375
4
#! usr/bin/env python """ http://programmingpraxis.com/contents/themes/ UNFINISHED """ THRESHOLD = 0.000001 def within_threshold(val): return val <= THRESHOLD def bisection(x): lower_limit = 1 upper_limit = x prev_midpoint = 0 midpoint = (upper_limit + lower_limit) / 2 candidate_square = midpoint ** 2 whil...
6157a9d2ef53c3f6cc953c5bfad47fd1be6f246a
anujitm2007/Hackerrank-Codes
/Problem Solving/Lily'sHomework.py
1,880
4.125
4
""" Whenever George asks Lily to hang out, she's busy doing homework. George wants to help her finish it faster, but he's in over his head! Can you help George understand Lily's homework so she can hang out with him? Consider an array of distinct integers, . George can swap any two elements of the array any number o...
67ca84103c0080ef9badf212be95273908264d67
yfl-fengzifei-se/DNN_Estimation
/dijkstra/dijkstra.py
4,895
4.34375
4
# -*- coding: utf-8 -*- # %% define the dijkstra function def dijkstra(graph_dict, start, end): """ This is a recursive function that implements Dijkstra's Shortest Path algorithm. It takes as its inputs: i. a graph represented by a "dictionary of dictionaries" structure, ...
be6e38b09105770faac3dbb38f96918314442395
Osama-Yousef/data-structures-and-algorithms-2
/sorts/insertion_sort/insertion_sort.py
524
3.984375
4
def insertion_sort(ints): ''' Traverse from 1 to len(ints) J starts one spot behind i (i-1) While j >=0 and the value at i is less than the value at j, the value at j+1 gets reassigned to the value at j, and j+1 becomes the value at i ''' for i in range(1, len(ints)): temp = ints[i] j = i-1 ...
287389c369b79af4938e186668eed4d86ff05ec0
JMRBDev/1DAW
/Programacion/Workspace Folder - Jose Rosendo/Ejercicios de clase/Ejercicios 2.0 (II) - Bucles/2.10_50_primeros_nums.py
278
3.5625
4
# Muestra los 50 primeros números pares a partir del 0, separados por comas y en orden creciente. nList = [] for i in range(0,50,2): nList.append(i) print(*nList, sep=", ") # El asterisco (*) desempaqueta la lista y devuelve todos sus elementos sin los corchetes.
ea240e32fc5693239aedb9e73913fa2b8e1a7158
wangredfei/nt_py
/Base/ex06/zy3_list.py
886
3.9375
4
# 3. 有一些数字存于列表中,如: L = [1, 3, 2, 1, 6, 4, 2, .....98, 82] # - 将列表中出现的数字存入到另一个列表l2中 # - 要求 : 重复出现多次的数字只能在L2中保留一份(去重) # - 将列表中出现两次的数字存于L3列表中,在L3列表中只保留一份 l = [1,2,2,3,3,3,4,4,5,5,5,6,6,6,6,6,8,9] # 定义三个空的列表 l1 = [] l2 = [] l3 = [] for i in l : count_nub = l.count(i)# 计算本次循环的数有几个 if i not in l1:...
874c314b4b7a612dabbe7c8e79d16c3f7ce6d573
kujin521/pythonObject
/第五章/列表/基本方法.py
407
3.796875
4
# 创建列表 list1=list() list2=[] # 添加元素 list1.append('第一个元素')# 添加到末尾 list2.insert(1,'inset')# 添加到指定位置 list1.extend(list2)# 添加列表 list1.append("再添加一个") list1.append("再添加二个") list1.append("再添加个") # 修改列表 list1[0]='修改元素' # 删除元素 del list1[1] list1.pop(1) list1.remove("再添加二个") print(list1,list2)
d22039d8ae2a018b85a1ed3bec9110308c746c63
nikita-chudnovskiy/ProjectPyton
/00 Базовый курс/053 Sort vs Sorted/01 sort vs sorted.py
1,617
4.25
4
# sort -метод только списков сразу изменит его # sorted - встроенная функция можно передавать любую последовательность и она изначально не меняется чтобы изменить нужно сделать присвоение a =[3,-2,-5,-7,4,15,11] # sort применить можем только к списку a1=[2,5,1,6] b ='hello world' c =('hi','zero','abrakadabra') # Есл...
c6b5160b3fe36eedc5b08e5e0f9ba7ea5c48fd44
colin-broderick/genetic_algorithm
/genetic.py
2,721
3.921875
4
import random import matplotlib.pyplot as plt def error(candidate, dataX, dataY): """ This function computes the sum of vertical square distances of a data set from a line. param: candidate: Dictionary containing gradient "m" and y-intercept "c", defining a line. return: The sum of vertical square dis...
2bc0589b8ed735770da056ed9ed7f71069a49351
mkukar/Covid19SanDiegoUpdater
/data_analyzer.py
3,525
3.515625
4
# analyzes the latest data for trends and patterns # Copyright Michael Kukar 2020. MIT License. import sqlite3 import statistics class DataAnalyzer: LATEST_ENTRY_QUERY = "SELECT DATE, TOTAL_CASES, NEW_CASES, NEW_TESTS, HOSPITALIZATIONS, INTENSIVE_CARE, DEATHS from DATA ORDER BY strftime('%Y-%m-%d', DATE) DESC" ...
0a9f54f5fc8ba014d5f9abb0f8ccce04205acb91
betty29/code-1
/recipes/Python/196890_Spawned_Generators/recipe-196890.py
1,597
3.5625
4
from __future__ import generators import threading class SpawnedGenerator(threading.Thread): "Class to spawn a generator." def __init__(self, generator, queueSize=0): "Initialise the spawned generator from a generator." threading.Thread.__init__(self) self.generator = generator ...
9d3716dd640a02870c851d4609be5275ea2ccbf9
TyroneWilkinson/Python_Practice
/angry_prof.py
1,083
3.796875
4
# https://www.hackerrank.com/challenges/angry-professor/problem def angryProfessor(k, a): """ Given the arrival time of each student and a threshhold number of attendees, determine if the class is cancelled. Note: Arrival times <= 0 are early or on time. Arrival times > 0 are late. Param...
910cd6bfdb56c45970ad0e6f2456730648ac8cc2
vinzdef/Algorithms
/Fractal.py
244
3.625
4
from turtle import * def f(length, depth): if depth == 0: forward(length) else: f(length/3, depth-1) right(60) f(length/3, depth-1) left(120) f(length/3, depth-1) right(60) f(length/3, depth-1)
069bc221ddde3a98814acda70e5a40f16c6be5e2
faisalabuzaid/snakes-cafe
/snakes-cafe/snakes_cafe/snakes_cafe.py
1,258
4.09375
4
menu = { 'Appetizers': {'Wings': 0, 'Cookies': 0, 'Spring Rolls': 0}, 'Entrees': {'Salmon': 0, 'Steak': 0, 'Meat Tornado': 0, 'A Literal Garden': 0}, 'Desserts': {'Ice Cream': 0, 'Cake': 0, 'Pie': 0}, 'Drinks': {'Coffee': 0, 'Tea': 0, 'Unicorn Tears': 0} } print("""************************************** ** ...
56870dd61008504213d5472820bb951f9a2bb73e
anithavedantam/LeetCode-Programs
/BST_LevelOrderTraversal.py
1,137
4.09375
4
''' Author: Anitha Kiron Vedantam Description: This is a program get the Level-Order Traversal of a Binary Search Tree. ''' # Node is defined as class node: def __init__(self, data): self.data = data self.left = None self.right = None def LevelOrderTraversal(root): i...
b5899a74a7f9c69d1e3c71d662258750f6378f76
tassianunes/Exercicios_Python-adicionais-
/SoftwareEngineeringChallenge/des053.py
106
4.0625
4
frase = str(input('Digite uma frase: ')).strip if frase[:] == frase[::-1]: print('É um polindrono')
442847413ad03c78c386efb43f3fda1e5b5a921a
alexgian1/Password-Generator
/pw_gen.py
2,681
3.890625
4
#Password Generator import random numbers = ['1','2','3','4','5','6','7','8','9','0'] letters_lowercase = ["a","b","c","d","e","f",'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] letters_uppercase = [letter.upper() for letter in letters_lowercase] characters = ['!','@','#','$','%...
6bbae80cb15f50c7ee34cc20a814d2208f06b1af
kreier/T400
/micropython/motor/motor_pwm.py
777
3.65625
4
import machine from machine import Pin, PWM import time pwm1 = PWM(Pin(5), freq=1000, duty=0) pwm2 = PWM(Pin(4), freq=1000, duty=0) M1 = machine.Pin(0, machine.Pin.OUT) M2 = machine.Pin(2, machine.Pin.OUT) M1.on() # forward M2.on() # forward print("Motor on") speed = 10 while speed < 1030 : speed += 10 time.sl...
a3d73a3372c0e872f2a72c3776fa93c5311eac31
shamikbose/python_examples
/Coding Interview Qs/kClosest.py
1,131
3.59375
4
# K-closest points import random from typing import List import heapq from time import time x_range = 10000 y_range = 10000 point_count = 5000000 points = [ (random.randint(0, x_range), random.randint(0, y_range)) for i in range(point_count) ] def kClosest(points: list, k: int) -> List[List]: closest_points ...
a4b1b5f4551408091b01db09bdbfd2e134ebf7d7
JulianCabreraS/thecompletepythoncourse
/DataStructures/List/Comprehension.py
501
4.3125
4
numbers = [0, 1, 2, 3, 4] doubled_numbers = [] for num in numbers: doubled_numbers.append(num * 2) print(doubled_numbers) # -- List comprehension -- numbers = [0, 1, 2, 3, 4] # list(range(5)) is better doubled_numbers = [num * 2 for num in numbers] # [num * 2 for num in range(5)] would be even better. print(dou...
1aa35937ae4000814cd479e73a0734be81510b62
fakepp/RabbitGame
/key_capture.py
996
3.765625
4
from msvcrt import getch class KeyCapture: def __init__(self): return def input(self): key = ord(getch()) if key == 3: return 'ESC' if key >= 48 and key <= 57: return str(key-48) if key == 27: #ESC return 'ESC' ...
ea607e7bf997efa64e4e16489dc5c1903b365030
vkuppu/NLP-Natural-Language-Processsing-Implementation
/HtmlParserTokenize.py
2,230
3.6875
4
#!/usr/bin/env python # coding: utf-8 # ### 30July 2019 # ### Snippet to pasre html and read text and create tokens. # ### Needs few more modifications # In[1]: import urllib.request # In[2]: response = urllib.request.urlopen('file:///C:/reut2-002.html') # In[3]: html = response.read() # In[5]: #print ...
9f6659cb75c42c371fdf51425cc84ab237a1fd20
fraserweist/euler
/0xx/001-multiples.py
262
3.671875
4
import sys def main(): if len(sys.argv) != 2: print "usage:\npython 001-multiples.py n" quit() script, n = sys.argv result = 0 for i in range(int(n)): if i % 3 == 0 or i % 5 == 0: result += i print "result = "+str(result) main()
280f56d61905df5f285e14671de4648974171d61
xerifeazeitona/PCC_Basics
/chapter_10/exercises/01_learning_python.py
1,005
5.03125
5
""" 10-1. Learning Python Open a blank file in your text editor and write a few lines summarizing what you’ve learned about Python so far. Start each line with the phrase "In Python you can. . . ." Save the file as learning_python.txt in the same directory as your exercises from this chapter. Write a program that read...
9bb9b92dbb96034f4bc134b5eb96c4ab030e193c
timstevens1/go_fish
/Go_Fish_Final.py
15,689
3.75
4
import random from deck import Deck import time # initialize global variables for player hands, score and end game statistics. # AUTHORS: EMMA TAIT and TIM STEVENS PLAYER_HAND = [] COMPUTER_HAND = [] PLAYER_SCORE = 0 COMPUTER_SCORE = 0 LIES = 1 TOTAL_CARDS_PASSED = 0 # for stats GF_COUNTER = 0 SUCCESS_COUNTER = 0 STAR...
5b38779a3dd38498c00735cb4bab8976d6b043c6
28ACB29/HackerRank-Solutions
/Python/Strings/Capitalize!.py
273
3.953125
4
# Enter your code here. Read input from STDIN. Print output to STDOUT def capitalize(old_string): return old_string[0].upper() + old_string[1:] if len(old_string) > 0 else old_string S = raw_input().strip() words = S.split(" ") print(" ".join(map(capitalize, words)))
391f416cc8cb7ab3addbe8b44cf801ba420a9f2d
viraco4a/SoftUni
/PythonBasics/Conditional-Statements-Lab/ToyShop.py
698
3.703125
4
first = 2.6 second = 3 third = 4.1 fourth = 8.2 fifth = 2 discount = 0.25 discount_amount = 50 rent = 0.1 excursion_price = float(input()) first_num = int(input()) second_num = int(input()) third_num = int(input()) fourth_num = int(input()) fifth_num = int(input()) profit = first_num * first + second_num * second + t...
78f16b17fa2dd0c571293019f9c5ee04c0c14197
vinodkkumarr/PythonBasic
/Assignment operators.py
313
4.25
4
print("assignment operators") a=5 print("Value of a is " + str(a)) a+=2 print ("Value increament by 1 using a+=1 is " + str(a)) a-=2 print ("Value decreased by 2 using a-=2 is " + str(a)) a*=2 print ("Value multiplied by 2 using a*=2 is " + str(a)) a/=2 print ("Value divided by 2 using a/=2 is " + str(a))
0964932ad9ce2e76abb80846f5a6029395983712
www111111/A1804_02
/get.py
511
3.984375
4
''' class Yl(object): def __init__(self,name): self.name=name def get(self): print(self.name) def set(self,name): self.name=name print(self.name) yl1=Yl('yl') yl1.get() yl1.set('sb') print(yl1.name) ''' class Animal(object): def dong(self,a): print('111',a) ...
5c39f58cc936cdc03b2d43fe13931181300e3390
prannb/CS671_assign2
/doc2vec/stopwords.py
533
3.703125
4
from nltk.corpus import stopwords from nltk.tokenize import word_tokenize import re example_sent = "This is a sample sentence, showing off the stop words br filtration." stop_words = set(stopwords.words('english')) word_tokens = word_tokenize(example_sent) # filtered_sentence = [w for w in word_tokens if not w in...
93867a655df365a26af7b7768d11f307a2a713db
protivofazza/studies
/hw_1_2.py
2,953
3.90625
4
print("Завдання №1.2\nПрограма для виводу результатів різних операцій над двома числами") print("_" * 65) value_1 = int(input('Введіть перше число: ')) value_2 = int(input('Введіть друге число: ')) print("\nРезультати арифметичних операцій над двома числами", value_1, "та", value_2) print("-"*57) result = v...
8112a3e208dc2dbf03aac548067f2dbd4bb8aaf6
zoeyangyy/algo
/jump_step2.py
309
3.5625
4
# -*- coding:utf-8 -*- class Solution: def jumpFloorII(self, number): # write code here li = [0, 1, 2] if number <= 2: return li[number] for i in range(3, number+1): li.append(sum(li)+1) return li[-1] c = Solution() print(c.jumpFloorII(5))
c027122d9acd8590cae810aee51e6a301981ee03
IngArmando0lvera/Examples_Python
/Condicionales/15 Ejercicio 1 son par.py
452
4
4
'''Ejercicio N.1 Crear un programa que pida 2 numeros y obtener como resultado cual de ellos es par o si ambos son par ''' #obtenemos datos dato1 = int(input("Ingrese dato 1: ")) dato2 = int(input("Ingrese dato 2: ")) #procesamos if dato1%2 == 0 and dato2%2 == 0: print("Ambos datos son par!") eli...
e7192153b93fe1609f026160277e73e263278f54
Manikantas1729/PythonPrograms
/Decorators/simple_decorator-1.py
398
3.59375
4
def my_decorator(func): def wrapper_my_decorator(*args, **kwargs): # args and kwargs to accept fn with args and kwargs print("Something before fucntion is called") func(*args, **kwargs) print("Something after funciton is called") return wrapper_my_decorator @my_decorator # called pie sy...
42d784590c5a8f27f913d5d17e2c2721f08db59c
LeiLu199/assignment6
/yx887/interval/exceptions.py
620
3.53125
4
class Error(Exception): """Base class for exceptions in this module. Attributes: msg (str): Explanation of the exception. """ def __init__(self, msg): self.msg = msg def __str__(self): return self.msg class NotAnIntervalError(Error): """Raised when user input ...
3bc6767a45ecd330a81a93f84c15f429badc2f2c
gistable/gistable
/all-gists/733643/snippet.py
3,819
3.796875
4
import math import random class Statistic(object): """ Hookin' it up with the seven descriptive statistics. """ def __init__(self, sample): self.sample = sample def size(self): return len(self.sample) def min(self): return min(self.sample) def max(self): ...
a0d1896c552d41fc803dc3bdd2dd9e5d885449eb
Yakobo-UG/Python-by-example-challenges
/challenge 12.py
392
4.1875
4
#Ask for two numbers. If the first one is larger than the second, display the second number first and then the first number, otherwise show the first number first and then the second. First_No = int(input("Entaer the first number: ")) Second_No = int(input("ENter the second number: ")) if First_No > Second_No: ...
57608405c9e638cc483b6f492a5cef133de8ee42
priscillashort/priscillashort.github.io
/Samples/Python/Loan/LoanPaymentCalculator.py
1,041
4.03125
4
def is_number(s): try: float(s) return True except ValueError: return False print('Welcome to the loan payment calculator. Please input the rate per period, present value, and number of periods and the loan payment will be printed') x = input("Rate per period as a percentage (eg. 8 for ...
0011e7aa3eb483adaba88932c5ca491853cf2796
aagray33/Bank-System
/bank-app1.py
975
4.03125
4
from Bank import BankAccount print("Welcome to App1\n===============\n") salary,initial_cbalance,initial_sbalance = map(float, input("Enter salary and initial balances for Checking and Saving accounts: ").split()) #create accounts acc1 = BankAccount("Checking",initial_cbalance) acc2 = BankAccount("Saving",init...
738afdff536b7cd924f91f121aa6e3b2d87f84ab
nbveroczi/holbertonschool-higher_level_programming
/basic_oop_with_python/circle.py
1,322
4.0625
4
# -*- coding: utf-8 -*- """ Created on Tue May 17 21:22:02 2016 @author: nbveroczi """ """ Script Circle: This is a script that describes a Circle Class with Private attributes, Public attributes and Public method. Return: the area of the circle(float) """ #start from math import pi ''' Class ''' class Circle(): ...
ac60110f2450a6961917a3959d5fbf1ad1b1f39b
pageinsec/genericScripts
/python3/simpleClient.py
361
3.53125
4
# Simple client, will connect, send a message, and close import socket # Get info for server hostIP = input("Host IP: ") hostPort = int(input("Host Port: ")) client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect((hostIP, hostPort)) print("Connected") message = input("What's the message? ") client....
ea6884339ab45af836ec9c3245e3c952e4dca0cf
mkmathur/Projects
/Numbers/factorial.py
188
4.09375
4
def factorial(n): result = 1 for i in range(2,n+1): result = result * i return result def recursive_factorial(n): if n <= 1: return 1 else: return n * recursive_factorial(n-1)
22ef110810841aee1e94165558669042e64fe4d7
pulkitmathur10/FSBC2019
/Day 05/regex3.py
314
3.875
4
#Regular Expression 3 import re while True: em_str = input("Enter the card number ") if not em_str: break card_val = re.findall(r'^[456]{1}[\d]{3}-?[\d]{4}-?[\d]{4}-?[\d]{4}', em_str) if card_val: print("Valid") else: print("Invalid")
24e3bafc93f78b29ba58e379534a3dc692eb1af0
maryyang1234/hello-world
/string/9.计算元音数量.py
202
3.703125
4
def calcuVowel(str): set_vowel = set("aeiouAEIOU") count = 0 for i in str: if i in set_vowel: count+=1 return count str = "GeeksforGeeks" print(calcuVowel(str))
fa95db05e5b2a11122249ebc62d2e028bfd5cb39
sandykramb/PythonBasicConcepts
/Divisible_by_5.py
111
3.875
4
numero = int(input("Digite um numero inteiro:")) if numero %5 == 0: print ("Buzz") else: print (numero)
993fb31b390398fd379feea6d40e0a0b4655db4c
kbutler52/Teach2020
/valueOf_i.py
58
3.625
4
i=0 while i<5: print('The value of i =',i) i=i+1
91e4be9f0e5c38425441cdb13bd75d7422b250d6
Hyperparticle/lct-master
/charles-university/2018-npfl104/hw/coding-bat/simple_class.py
244
3.515625
4
class SimpleClass: def __init__(self): self.name = 'SimpleClass' self.methods = ['add', 'mul'] self.simple = True def add(self, a, b): return a + b def mul(self, a, b): return a * b
1437a4699704fedf33f9703a54a069820929c917
andreaslillevangbech/AoC-2020
/day18/solve.py
720
3.5
4
#!/usr/bin/env python3 import re import itertools lines = open('input').read().strip().split('\n') class Num: def __init__(self, num): self.num = num def __add__(self, other): return Num(self.num * other.num) def __sub__(self, other): return Num(self.num + other.num) def __mul...
11f86ff14963c148a094bdf9bb80433823313e67
giovannyortegon/holbertonschool-machine_learning
/math/0x00-linear_algebra/5-across_the_planes.py
467
3.796875
4
#!/usr/bin/env python3 """ Adds two matrices element-wise """ add_arrays = __import__('4-line_up').add_arrays def add_matrices2D(mat1, mat2): """ add_matrices2D mat1: First matrix mat2: Second Matrix Return: Result of elements of matrix """ new_mat = [] len_mat = len(mat1) if len(mat1[...
cdfa44f95373939e342fe1021a1fc1b7ff3f6880
NovaPlusCoding/Infytq-Assignment-Solution
/Programming-Fundamentals-Using-Python/Day9/Practice-Exercise/Level2/problem21.py
352
3.609375
4
#PF-Prac-21 def check_numbers(num1,num2): num_list = [] count = 0 for i in range(num1, (num2 // 2) + 1): num_list.extend([x for x in range(i + 1, num2 + 1) if x % i == 0]) print(num_list) num_list = set(num_list) count = len(num_list) return [num_list, count] num1=2 num2=20 p...
7de0083aecebb52fc9ee9316a291eafcf846489a
kiselevskaya/Python
/experiments/32_biology_meets_programming/hamming_distance.py
918
3.578125
4
def hamming_distance(p, q): mismatches = [] if len(p) != len(q): return 'Input strings must be equal' for i in range(len(p)): if p[i] != q[i]: mismatches.append(i) return len(mismatches) def approximate_pattern_matching(text, pattern, d): positions = [] last_check...
6b13ecb095f8c9a9d5bed414ab31776baddcee6f
ztnewman/python_morsels
/fix_csv.py
367
3.65625
4
#!/usr/bin/env python3 import csv import sys input_file = sys.argv[1] output_file = sys.argv[2] csv.register_dialect('pipes', delimiter='|') with open(input_file, 'rt') as f1, open(output_file, 'wt') as f2: reader = csv.reader(f1,dialect='pipes') writer = csv.writer(f2) for row in reader: ...
1dfe57869fe165e4424c5c178e08108a14d1190f
liketheflower/mypy_practise
/code/basic_checking/wrong_type.py
725
3.828125
4
from typing import List # correct ib:int = 1 # wrong ia:int = 1.3 # correct is_trueb: bool = True # wrong is_truec: bool = 1 is_truea: bool = 1.2 # correct a:List = [] # wrong aa:List = {} """ wrong_type.py:5: error: Incompatible types in assignment (expression has type "float", variable has type "int") wrong_type.py:7...
172428ace0812eb494df7f22839f9b7fb402b9af
nekapoor7/Python-and-Django
/Python/Python Concepts/StringPrograms/StringLength.py
138
4.21875
4
"""Write a Python program to calculate the length of a string.""" import re text = input() l = re.findall(r'[a-zA-Z]',text) print(len(l))
3f54a0975a77e2810975147f09c003d7c63db848
ryugahidiky/my_utils
/Codejam/Qualification Round 2020/Parenting Partnering Returns/ParentingPartneringReturns.py
754
3.734375
4
def solve(unsorted_list): sorted_list = sorted(unsorted_list, key=lambda tup: tup[0]) res="C" c=sorted_list[0] j=[0,0] for i in sorted_list[1:]: current_task=i if current_task[0]>=c[1]: res+="C" c=current_task else: if current_task[0]>=j[1]: res+="J" j=current_task else: ...
3aa86d5a44e69d55973b9aca1cae2c7a54fe7a40
AnchitSajalDhar/python-course
/study2.py
257
4.1875
4
# -*- coding: utf-8 -*- """ Created on Sun Aug 23 20:18:23 2020 @author: Hp """ str1=input("input the string to be reversed") word=str1.split() word.sort() #str1.sort() print(str1) print("the sorted string is ") for i in word: print(i)
d7d37d8798eb9b90875f3c431d4f5df2562b037a
Du-Arte/AprendiendoPython
/Tablas.py
327
3.859375
4
for i in range(1,11): Titulo="Tabla del {}" print(Titulo.format(i)) #usamos for y else for j in range(1,11): #i es numero base y j el elemento de la tabla salida="{} x {} = {}" print(salida.format(i,j,i*j)) else: #al acabar saltamos de linea print() ...
263095dd0d51156d096ca9b1515a95c0703342d3
rahul-art/computer_vision_classification
/cnn.py
3,018
3.5625
4
from keras.models import Sequential from keras.layers import Conv2D from keras.layers import MaxPooling2D from keras.layers import Flatten from keras.layers import Dense ''' # Initialising the CNN classifier = Sequential() # Step 1 - Convolution classifier.add(Conv2D(32, (3, 3), input_shape = (64, 64, 3), activation =...
dc3b8d9262c21fa4b0ddd6189dbf91296005c82f
marko-knoebl/python-course
/einheit6/bank_account.py
992
3.53125
4
import datetime class BankAccount(object): def __init__(self, acc_nr, owner, inital_balance): self.acc_nr = acc_nr self.owner = owner self.inital_balance = inital_balance self.transactions = [] def add_transaction(self, date, amount): # create new transaction ne...
ae0d6dec6ddc7a8fdc2262f841332cd25e20f98b
DavidBitner/Aprendizado-Python
/Curso/ExMundo3/Ex115Modulo.py
2,087
3.96875
4
def linha(): print('-' * 40) def limpar(): return print('\033[m', end='') def verde(): return print('\033[32m', end='') def vermelho(): return print('\033[31m', end='') def menu(): linha() print('MENU PRINCIPAL'.center(40)) linha() while True: print(f'1 - Ver pessoas cada...
9cc5c7f8e13b5dd37f9a968f59ac535ded89d3d8
DreamingLi/Blog-back-end
/test.py
363
3.90625
4
def is_between_and_even(test_value, low_value, high_value): if low_value <= test_value <= high_value: if not test_value % 2: return True else: return False else: return False print(is_between_and_even(23, 22, 24)) print(is_between_and_even(22.0, 22.0, 24.5)) pri...
0d1a1176a9bbc701b20828596b174dcc1751cac0
nickdinhh1998/password-generator
/Password generator.py
542
4
4
import string import random user_choice = None while user_choice == None: try: user_choice = int(input('How many characters you want to have in your password:')) if user_choice < 6: print('Password must be with 6 characters at least') user_choice = None except ValueError: ...
8a60ec7dd14afad2a51fbcd98320c024d132b0a9
zingpython/Intro_python_1
/units_of_time_again.py
488
3.671875
4
# In this exercise you will reverse the process # described in the previous exercise. # Develop a program that begins by reading a number # of seconds from the user. Then your program should # display the equivalent amount of time in the # form D:HH:MM:SS, where D, HH, MM, and SS represent # days, hours, minutes ...
4fb907cf9eb8ff79126fc2505cf8423460a01a33
19platta/misguided-the-game
/game.py
19,643
3.71875
4
import pygame import character import environment import os from pygame.locals import ( K_ESCAPE, KEYDOWN, QUIT, ) class Game: """ Class representing the Game state, controlling the interactions between the other classes, and running the game. Attributes: screen: the window to dr...
abff64a57d80c7a204433579db61ebf73313e0e6
IngridDilaise/programacao-orientada-a-objetos
/listas/lista-de-exercicio-02/questao4.py
250
3.859375
4
print("Digite suas quatros notas bimestrais") nota1=int(input("primeira nota:")) nota2=int(input("segunda nota:")) nota3=int(input("terceira nota:")) nota4=int(input("quarta nota:")) media=(nota1+nota2+nota3+nota4)/4 print("A sua média é:",media)
85977f09ab0cf9286a06155cededcf1d21d1e386
a18499/Python
/nest_list.py
425
3.90625
4
movies = ["The Holy Grailliam","1975","Terry Jones & Terry Gilliam","91", ["Graham Chapman",["Michael Palin","John Cleese","Terry Gilliam","Eric Idle","Terry Jones"]]] print(movies) for each_item in movies: if isinstance(each_item,list): for each_nest_item in each_item: if isinstance(each_nest_item,l...
bb15daa5d2b4c52c1db4cd08ef8d03b5fbdca876
h-jaiswal/mini-projects
/TCS OOPS based on py3/main.py
1,263
3.71875
4
class Table: def __init__( self, tableNo, waiterName, status): self.tableNo = tableNo; self.waiterName = waiterName; self.status = status def findWaiterWiseTotalNoOfTables(tableList): waiterNameList = {} for table in tableList: if table.waiterName not in waiterNameList: ...
712579cf85063e55aae683ed768fb3e71f190026
danielfess/Think-Python
/binomial.py
504
3.828125
4
def binomial_coeff(n,k): """Compute the binomial coefficient "n choose k". n: number of trials k: number of successes returns: int """ #x = 1 if k==0 else 0 return binomial_coeff(n-1,k) + binomial_coeff(n-1,k-1) if k>0 and n>0 else (1 if k==0 else 0) print(binomial_coeff(0,0)) print(binomial_coeff(0,1)) prin...
ed8d4a9f7521c340309d725b4eb33c4a423a508c
rpiga/Runestone
/thinkcspy/ch08/Excercise 11 - ex_7_19.py
975
3.609375
4
import image FACTOR = 2 def enlargeImage(origImage, factor = FACTOR): origW = origImage.getWidth() origH = origImage.getHeight() #print(">", origW, origH) enlargedImage = image.EmptyImage(factor * origW, factor * origH) new_index = 0 for w in range(...
dde04a82e454bdad6300b902cd733c761cf1d93a
vishukamble/Python-Practice
/Basics/stringCompression2.py
568
3.953125
4
# __author__ = Vishu Kamble # """ A python program to find how many times a character is repeated in sing """ def compressed(s): length = len(s) result = "" if length == 0: return if length == 1: return s+"1" else: count = 1 i = 1 while i < length: ...
7e32eafb41375b19703517dfe956cf81aced8d4a
KevinCodez/Snake-Game
/main.py
1,117
3.515625
4
from turtle import Screen from snake import Snake from food import Food from scoreboard import Scoreboard import time screen = Screen() h = 600 w = 600 screen.setup(height=h, width=w) screen.bgcolor("black") screen.title("Snake") screen.tracer(0) snake = Snake() food = Food() scoreboard = Scoreboard() screen.listen(...
92c8728b9333869c8f9d073264f93d796340f9b9
Geoffrey-Kong/CCC-Solutions
/'06/Junior/CCC '06 J1 - Canadian Calorie Counting.py
556
3.546875
4
a = int(input()) b = int(input()) c = int(input()) d = int(input()) if a == 1: c1 = 461 elif a == 2: c1 = 431 elif a == 3: c1 = 420 elif a == 4: c1 = 0 if b == 1: c2 = 100 elif b == 2: c2 = 57 elif b == 3: c2 = 70 elif b == 4: c2 = 0 if c == 1: c3 = 130 elif c == 2: c3 = 160 elif c == 3: c...
e143d7f6a0b63609e1866f29f54cffac806c4c14
shmehta21/DS_Algo
/bt_to_bst.py
1,115
4.0625
4
''' 1.) Create an array after In-order traversal 2.) Sort the in-order traversal array 3.) Iterate over the in-order array and sorted in-order array together and replace elements from sorted_arr to in_order arrat ''' class Node: def __init__(self, data): self.data = data self.left = None self.right = None...
a058efdfcef74e6abbb46f30f9d24c66355a0ed0
anipshah/geeksforgeeks_problems
/CommonElements.py
535
4.0625
4
# Find common elements in three sorted arrays def common(l1,l2,l3): n1=len(l1) n2=len(l2) n3=len(l3) i,j,k = 0,0,0 res=[] while i<n1 and j<n2 and k<n3: if l1[i] == l2[j] and l2[j] == l3[k]: res.append(l1[i]) i+=1 j+=1 k+=1 eli...
4672744d0eac8a92369e9bc272e83af87235aae5
fang-ren/algorithm_practice
/CareerCup/4.py
480
3.875
4
""" 8/17/2017 Author: Fang Ren """ """ divide 2 numbers without using / or % """ def dividing(a, b): ans = 0 if b == 0 and a != 0: return "Infinity" if a == 0: return 0 if a*b > 0: sign = '+' elif a * b < 0: sign = '-' a = abs(a) b = abs(b) while a >= b:...
424e65ec4c65d7da6e7903d30eff9401405c65f2
gabo-cs-zz/Python-Exercism
/Side Exercises/darts/darts.py
297
3.75
4
from math import sqrt def score(x, y): distance = sqrt(x**2 + y**2) if landed(distance, 0, 1): return 10 if landed(distance, 1, 5): return 5 if landed(distance, 5, 10): return 1 return 0 def landed(number, min, max): return min <= number <= max
033750a6e734a68421b532b43d35407374f69a74
brianchiang-tw/leetcode
/2020_November_Leetcode_30_days_challenge/Week_3_Search in Rotated Sorted Array II/by_binary_search.py
2,612
4.25
4
''' Description: Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]). You are given a target value to search. If found in the array return true, otherwise return false. Example 1: Input: nums = [2,5,6,0,0,1,2], target ...
1b6a7d2cdf65f6c2cafa1761c0af8117e6755478
WillPowerCraft/my-first-repository
/int_float_min_max_abs.py
2,478
3.703125
4
# Целочисленный тип данных # x = 1 - целочисленный литерал, питон присваивает ему int # Ниже представлены все целочисленные операторы # a = 13 # b = 7 # # total = a + b # diff = a - b # prod = a * b # div1 = a / b # div2 = a // b # mod = a % b # exp = a ** b # # print(a, '+', b, '=', total) # print(a, '-', b, '=', dif...
b910f02a8b1d0d1bdfab05f0894bb261011d4874
s3cret/py-basic
/process/multi-process/multiprocessing1.py
638
3.90625
4
'''multiprocessing1 doc os.fork() will copy the current process using which to create a child process 1> in parent process os.fork() returns the child process id 2> in the forked child process os.fork() returns 0 in this case, child process can retrieve parent process id by calling os.getppid() function ''' impo...
88590a5aa1c39ee64b6fdc2fe0725862c0dad696
MarcusRainbow/Maze
/DijkstrasRats.py
4,396
3.796875
4
import random from typing import List from RatInterface import Rat, MazeInfo from SimpleMaze import SimpleMaze, random_maze, render_graph from Localizer import OneDimensionalLocalizer class DijkstrasMazeInfo(MazeInfo): def __init__(self, maze: List[List[int]]): self.maze = maze self.positi...
450c06a1c85ec20557945559273ca1a3349df48e
FrankieZhen/Lookoop
/LeetCode/otherQuestion/小米/Q1.py
1,828
3.640625
4
#!/bin/python # -*- coding: utf8 -*- import sys import os import re """ 小米之家有很多米粉喜欢的产品,产品种类很多,价格也不同。比如某签字笔1元,某充电宝79元,某电池1元,某电视1999元等 假设库存不限,小明去小米之家买东西,要用光N元预算的钱,请问他最少能买几件产品? 输入 第1行为产品种类数 接下来的每行为每种产品的价格 最后一行为预算金额 输出 能买到的最少的产品的件数,无法没有匹配的返回-1 样例输入 2 500 1 1000 样例输出 2 """ #请完成下面这个函数,实现题目要求的功能 #当然,你也可以不按照下面这个模板来作答,完...
9e9fccfb40951024d44f8ec778015f40aa6cda71
mave89/Python_Random
/retrieveTags_insideTags_BeautifulSoup.py
993
3.8125
4
import urllib from BeautifulSoup import * inp_url = raw_input('Enter web address:') #position of the hyperlink from the top inp_position = int(raw_input('Enter position:')) #number of times the links need to be surfed inp_count = int(raw_input('Enter count:')) #loop to parse links depending on the inp_count given b...
e10e59df79a2f33026e413062438f4f71309ca22
Krishna2709/DataStructures-and-Algorithms
/MergeSort.py
664
4.0625
4
# Merge Sort # TimeComplexity - O(nlogn) def Merge(a,b): mergedArray = [] while len(a) != 0 and len(b) != 0 : if a[0] < b[0]: mergedArray.append(a[0]) a.remove(a[0]) else: mergedArray.append(b[0]) b.remove(b[0]) if len(a) == 0: mergedA...
e4bb1a73d77abf18d69a2360913eebbf7dfe4871
wats1787/pig_latin-
/pig_latin.py
265
3.921875
4
def pigLatin (word): ww = word list1 = ['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U', 'y', 'Y'] if ww[0] not in list1: ww = ww[1:] + ww[0] + 'ay' else: ww = ww + 'yay' return ww print(pigLatin('input string here')
0de523f7218eb921e33b08a5053b5a0830224408
szmn90/22.01.2021
/zadanie2.py
309
3.71875
4
def ostatnielinie(f,n): with open(f) as file: print('Ostatnie ',n, 'linijek pliku to: ',f) for line in (file.readlines()[-n:]): print(line,end='') name = input('Nazwa pliku tekstowego: ') n=int(input('Ile ostatnich linijek? ')) print(ostatnielinie(name,n)) #działa
1b0a1f19d5c47add41b338731462ed2b0655d54b
zhou-yi-git/PAT
/BasicLevel/1061 判断题.py
441
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019-03-20 10:12 # @Author : zhou # @File : 1061 判断题 # @Software: PyCharm # @Description: n,m = map(int,input().split()) score = list(map(int,input().split())) correct = input().split() for i in range(n): stu_score = 0 ans = input().split() ...
09ac8953b26598270878d5d54b50639a1351f282
EdwinKato/Space-Allocator
/src/fellow.py
580
3.625
4
"""Class definition of Fellow It inherits directly from Person """ from .person import Person class Fellow(Person): """Fellow """ def __init__(self, first_name, last_name, wants_accommodation, person_id, has_living_space=None, has_office=None): super( Fellow, ...
d9fec576532335eae7f88fd233efd8093c830b22
SkillfulGuru/Webscraping-BeautifulSoup-NZX
/web1.py
872
3.625
4
from urllib.request import urlopen from bs4 import BeautifulSoup #html = urlopen('http://www.pythonscraping.com/pages/page1.html') #bs = BeautifulSoup(html.read(), 'html5lib') # print(bs.h1) from urllib.error import URLError from urllib.error import HTTPError # try: # html = urlopen('https://pythonscrapingt...
3a3d002ecc5f9268651a22f57201db73709a9bc6
RankeTao/pythontest
/tuplex.py
6,373
4.375
4
# !/usr/bin/env python # -*- coding: utf-8 -*- #ex12.1 def most_frequent(s): """Sorts the letters in s in reverse order of frequency. s:string Returns: list of letters """ hist = make_histogram(s) t = [] for x, freq in hist.items(): t.append((freq, x)) t.sort(reverse = ...
6423e10c90048532f098824a4f0c7d4a626dc327
dhellmann/commandlineapp
/docs/source/PyMagArticle/Listing5.py
1,172
3.59375
4
#!/usr/bin/env # Base class for sqlite programs. import sqlite3 import commandlineapp class SQLiteAppBase(commandlineapp.CommandLineApp): """Base class for accessing sqlite databases. """ dbname = 'sqlite.db' def optionHandler_db(self, name): """Specify the database filename. Defaults...
b314bbf40b5ea86eae4429d3d0319b931ee1da3c
xxxmian/CodingTime
/jiuzhang-reinforcement/numofIsland.py
2,147
3.546875
4
class UnionFind: def __init__(self, num): self.num = num self.rec = [i for i in range(num)] def find(self, a): assert a < self.num while a != self.rec[a]: a = self.rec[a] return a def union(self, a, b): assert a < self.num assert b < self...
0d92df85218fd0d86c7fb8465d7fb7815a144912
bam6076/PythonEdX
/midterm_part7.py
488
3.828125
4
## Write a function called pattern_sum that receives two single digit ## positive integers, (k and m) as parameters and calculates and ## returns the total sum as: k + kk + kkk + .... ## (the last number in the sequence should have m digits) def pattern_sum(k, m): total = 0 for i in range (1, m+1): tot...
af4f28e3d7907c639c3d28f04d3f1d84e8221dc0
raochuan/LintCodeInPython
/set_matrix_zeroes.py
1,635
3.71875
4
# -*- coding: utf-8 -*- class Solution: """ @param matrix: A list of lists of integers @return: Nothing """ def setZeroes(self, matrix): # write your code here if not matrix: return rows = len(matrix) cols = len(matrix[0]) # 确定第1行是非有0要处理 z...
d4221d2a381d050ba860e6fbdbcc6eb631fabf96
mot12341234/Couresa_AlgorithmToolBox
/week3_greedy_algorithms/7_maximum_salary/largest_number.py
734
3.875
4
#Uses python3 import sys def IsGreatOrEqual(max_digit, digit): # max_digit = 23 # digit = 3 # 323 and 233, then max_digit = 3 return int(str(digit) + str(max_digit)) >= int(str(max_digit) + str(digit)) def largest_number(a): # res = "" # for x in a: # res += x # return res r...
6212a9c1840f1864260f34d3beb7b709007072aa
cloudmesh-community/sp19-222-89
/project-code/scripts/split_data.py
2,158
3.765625
4
#this function correctly formats the input data into a 2D numpy array import numpy as np def format(data): #variable to store # of features, in this case we have 8 nfeatures = 8 #get the values from the list of dictionaries, put them into #a new list list_data = [] for i in data: ...
436d7ba10fc2d9350300c9facbf8decf11bbee1d
diegoami/hackerrank-exercises
/30days/nested_logic.py
1,348
3.609375
4
inputarray = [ "9 6 2015", "6 6 2015" ] inputarray2 = [ "31 8 2004", "20 1 2004" ] inputarray3 = [ "2 6 2014", "5 7 2014" ] inputarray4 = [ "31 12 2009", "1 1 2010" ] from tools import input, initArrayInputter initArrayInputter(inputarray4) import sys d1,m1,y1 = map(int,input().split()) d2,m2,y2 = map(int,input().s...
c6f6c0f75e5eefc8cb593fd431b96a4896986aec
MTset/Python-Programming-Coursework
/Python 04: Advanced Python/Lesson 02: Data Structures/arr.py
969
3.546875
4
""" Class-based dict allowing tuple subscripting and sparse data """ from collections import defaultdict class array: def __init__(self, X, Y, Z): "Create an defaultdict subscripted to represent a 3D matrix." self._data = defaultdict(int) self._x = X self._y = Y ...
a2ebd3129a58d0cbc3e6f277aae3abf565140984
linhptk/phamthikhanhlinh-fundamental-C4E27
/Session01/HW/turtle_multi circles.py
143
3.90625
4
from turtle import * shape("turtle") color("green") for i in range(100): for j in range (10): left(1) forward(1) mainloop()
1fb05582f903045a97f766415feab6e8709056c1
saraducks/Python_interview_prep
/Leetcode/Strings_python/str_to_integer.py
451
3.703125
4
def myAtoi(str): """ :type str: str :rtype: int """ if len(str) == 0: return 0 set_negative = False if str[0] == '-': set_negative = True start_range = 1 if set_negative == True else 0 for i in range(start_range, len(str)): if not str[i].isdigit(): ...
1af5f2285ee0e0e17642fa70ce250afaacf4075f
daniel-reich/ubiquitous-fiesta
/BokhFunYBvsvHEjfx_9.py
130
3.640625
4
def seven_boom(lst): for num in lst: if "7" in str(num): return "Boom!" return "there is no 7 in the list"