blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
df8d87cc6a8848e2d61742166c14e5ab21e0ab80
Jak1022/FSU-BCH5884-Fall2020
/20nov05/argparse_oldway.py
257
4.15625
4
#!/usr/bin/env python3 import sys import argparse if len(sys.argv) !=3: print("usage: argparse.py <number1> <number2>") print("I'll add two numbers passed from the command line") sys.exit() a=sys.argv[1] c=sys.argv[2] sum=a+c print("the sum is", sum)
30dc6d46845a05d1e03d4118f20911800109ebfe
Jak1022/FSU-BCH5884-Fall2020
/20sep17/round.py
196
3.875
4
#!/usr/bin/env python3 import math x=float(input("Please enter a float and I will round it to the nearest interger: ")) print(x) print (type(x)) y=math.floor(x+0.5) print(x,y) print("done")
0a8bae63e82fc4422b7d891b1e4f39acb1388ee4
Jak1022/FSU-BCH5884-Fall2020
/20nov19/restaurant.py
1,197
4.03125
4
#!/usr/bin/env python3 class Employee: def __init__ (self, name, idnum, salary=0): self.name=name self.salary=salary self.idnum=idnum def work(self): print(self.name,"does stuff") def giveRaise(self,percent): self.salary=self.salary+(self.salary*percent/100) def __mul__(self,num): return (self.sa...
d8ee9c6f2d4a8a9060e8e897bcdbd01eda5acc14
zinary/GUVI-CODE-KATA
/largest.py
249
3.75
4
while True: try: a,b,c=input("").split() a=int(a) b=int(b) c=int(c) break except: print("invalid input ") break if (a>b): if(a>c): print(a) elif c>a: print(c) elif (b>a): if (b>c): print(b) elif c>b: print(c)
1db426c6ad16de8698a3801854170d5d6d841dfe
zinary/GUVI-CODE-KATA
/limitedfactorial.py
115
3.734375
4
x=input('') x=int(x) if(x<=20): fact=1 while(x>0): fact=fact*x x=x-1 print(fact) else: print("INVALID")
9787820d68b45f6029893aa75f57641974cde0a6
bogdansimion31/University
/Semester1/Fundamentals of Programming/probleme/Laborator4_6/Pachet/adaugare.py
849
3.625
4
def adaugareSfarsit(l,x): """ Functia adauga la sfarsitul listei scorul ultimului concurent adaugat in aceasta Parametri: lista l, valoarea x Returneaza: lista in urma operatiei de adaugare la sfarsit """ if x>-1 and x<101: l.append(x) else: print("Introdu o valoare corecta:"...
57eac39834d1f24b8ac34c8c2e402074fa317793
bogdansimion31/University
/Semester1/Fundamentals of Programming/seminarii/seminar12/merge_sort.py
765
4
4
""" @author: Badita Marin-Georgian @email: geo.badita@gmail.com @date: 12/18/2017 09:13 """ def merge(left, right, list): i = 0 j = 0 k = 0 while i < len(left) and j < len(right): if left[i] < right[j]: list[k] = left[i] i += 1 else: li...
ebee3a756baecf22b09ed7a0a2d456209239e82c
bogdansimion31/University
/Semester3/Python_reminder_proj/domain/validator.py
1,566
3.671875
4
""" @author: Badita Marin-Georgian @email: geo.badita@gmail.com @date: 7/23/18 19:35 """ class ValidatorException(Exception): """ Class for Raising Exceptions """ def __init__(self, excs): self.__errs = excs def get_errs(self): """ Returns the errors contain...
a9c982ba9d233461898d98f057ede3784f6c6c12
bogdansimion31/University
/Semester1/Fundamentals of Programming/probleme/Laborator4_6/Pachet/functionalitati.py
1,416
3.734375
4
def listaA(l,x): """ Functia formeaza o lista noua in care se afla participantii care au scorul mai mic decat un scor dat Parametri:lista l, scorul x Returneaza: listA """ listA=[] for i in range(len(l)): if l[i]<x: listA.append(l[i]) return listA def listaB(l): ...
59a6adcf97a584635561655f95b07052f54eb995
bogdansimion31/University
/Semester1/Fundamentals of Programming/probleme/Laborator4_6/Pachet/citire.py
3,146
3.75
4
def citireScor(n): """ Functia citeste scorul corespunzator fiecarui participant Parametrii: n Returneaza: lista l """ l=[] for i in range(1,n+1): x=int(input("Tasteaza scorul participantului i:")) if x>-1 and x<101: l.append(x) else: print("...
bb5e99f5d9877e49444220448d6876bb555a6ae6
bogdansimion31/University
/Semester5/LFTC/Lab2_FA_Analizor/finite_automata/utils.py
2,577
3.9375
4
from finite_automata.finite_automata import FiniteAutomata, Transition def read_fa_from_file(path): """ Function to read a finite automata from file :param path: path to the finite automata :return: the finite automata described in the file :raise: FileNotFound exception if the file could not be f...
c937105a095787b91b7f0424033f78ac6511f814
bogdansimion31/University
/Semester5/LFTC/Regular_Grammars/grammar.py
2,676
3.984375
4
class Production: """ Class for representing a production """ def __init__(self, left_term, right_term): """ Constructor for production class :param left_term: left term of the production :param right_term: right term of the production """ self.__left_ter...
935d6cc35b240dcde35f4174326cec9a2bca837f
bogdansimion31/University
/Semester1/Fundamentals of Programming/cautari/merge_sort.py
935
4.1875
4
""" @author: Badita Marin-Georgian @email: geo.badita@gmail.com @date: 1/27/2018 00:26 """ def merge_sort(list): """ Function that sorts a list of elements :param list: list of elements :return: the list of elements sorted """ if len(list) > 1: mid = len(list)//2 ...
4bd6e1cc21a06eed5bd83ac1b80ccb84edff6f4b
bogdansimion31/University
/Semester1/Fundamentals of Programming/assignment5/controller/DisciplineController.py
2,383
3.53125
4
class DisciplineController: def __init__(self, repository): ''' constructor for DisciplineController class :param repository: repository for disciplines ''' self.__repository = repository def store_discipline_ctr(self, discipline): ''' Add a discipline to...
85cdb6fa8ac51cde9619d5850d6805fa60eae2bd
codeose/python_practice
/Newton2nd.py
359
4.1875
4
def newton_2nd_law(): print('Finding the value for newton Second law of motion using formula') print('S = u*t - 1/2*g*t^2') t = float(input('Enter the value of t: ')) u = float(input('Enter the value of u: ')) g = float(input('Enter the value of g: ')) s = (u * t)-((1/2)*g*(t**2)) print('T...
71f260bb15277dc1c89fcb390ce29de23b81a763
Admarlo/DI
/Pyton/Examen/ej1.py
780
3.9375
4
def mismo_primero_ultimo(L):#Creación de la función """ (lista) -> boleano Precondición: len(L) >= 2 Devuelve True si y sólo si el primer ítem de la lista es el mismo que el último. """ if(len(L) < 2):#if para controlar la comparación de las posiciones de la cadena return False ...
f90f146428c61ecb9998568e3fd0054140afb62a
Admarlo/DI
/Pyton/untitled/Ejercicio06.py
1,021
3.5
4
import tkinter import tkinter.filedialog as dialog class OpenFile: def __init__(self, parent): self.parent = parent self.text = tkinter.Text(self.parent) self.text.pack() self.menubar = tkinter.Menu(self.parent) self.filemenu = tkinter.Menu(self.menubar) self.fileme...
7e0912fc3ddb159c7c96fd797434ba0a644c1bf9
koson/PHMeasureADS1115
/calibration.py
613
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ph7voltage = input("Put in the measured voltage while producing a shortcut between inner pole and outer area of the " "BNC. This presents voltage at pH 7. Format x.xxx: ") ph401voltage = input("Put in the measured voltage while measuring the buffe...
db98bcb44d9cd7bdadfdb86b0d0195ca015d7013
shivam0071/dataSciencePython
/ML_AI_and_Maths/firstNN_cost_function2.py
982
3.53125
4
import numpy as np def NN(m1, w1, m2, w2, b): z = m1 * w1 + m2 * w2 + b print("Z is",z) return sigmoid(z) def sigmoid(x): return 1/(1 + np.exp(-x)) def cost_func(x): """Cost function is squared error""" # if we take w1 and w2 as 0 then cost would be # (b - 4) ** 2 where 2 is the actual output and b is ...
acac997eb1b8fc7e386da26b53e86bcfd10f13a2
AlexGumash/Python-hard-level
/homework3/life.py
4,387
3.53125
4
import random from pygame.locals import * from copy import deepcopy import pygame class GameOfLife: def __init__(self, width=640, height=480, cell_size=10, speed=10): self.width = width self.height = height self.cell_size = cell_size # Устанавливаем размер окна self.scree...
ef605e1ca662f2873971f6027708de8746a86c63
SASLEENREZA/Python_DeepLearning
/ICP-5/Source/LinearRegression.py
674
3.875
4
import numpy as num import matplotlib.pyplot as mat a=num.array([2.9,6.7,4.9,7.9,9.8,6.9,6.1,6.2,6,5.1,4.7,4.4,5.8]) b=num.array([4,7.4,5,7.2,7.9,6.1,6,5.8,5.2,4.2,4,4.4,5.2]) #calc mean for two lists mean_a=num.mean(a) mean_b=num.mean(b) #calc deviations for slope x=num.sum((a-mean_a)*(b-mean_b)) y=num.sum(pow(a-mean...
eb820f2064ad26ca0956cc86958cd61403ddbc7b
arjunycoding/practicePython
/unary.py
12,648
3.59375
4
# Unairy Function def unairy(lst): if isinstance(lst, list) == True: if lst == []: return True else: cLst = lst.copy() if lst[0].lower() == "m": cLst.pop(0) for i in cLst: if cLst.pop().lower() == "o": ...
2625d4540ee8baafbf94f6be2c4b1ebd5dbc00d6
litpuvn/self-boosted-ts
/common/TimeseriesTensor.py
5,045
3.796875
4
from collections import UserDict import pandas as pd import numpy as np class TimeSeriesTensor(UserDict): """A dictionary of tensors for input into the RNN model. Use this class to: 1. Shift the values of the time series to create a Pandas dataframe containing all the data for a single trainin...
aa418107e44b4b0e0f310ba663feff074cdce484
tiepnv281/HelloWorld
/LearnXinYminutes.py
3,168
3.640625
4
"""Chú thích: tất cả sẽ đc viết thành lệch,chạy trực tiếp khi compile bằng python(vì vừa dịch vừa học ^^). Mình sẽ dùng bản Python 3. Được dịch từ trang LearnXinYminutes.com """ # Dùng kí tự (#) để tạo comment """ Dùng 3 dấu ngoặc kép (") để đánh trên nhiều dòng. Hoặc, có thể sử dụng để comment """ ##...
edf76bb8ec332164980c0b0bea1951ebdd1c7148
BYN13K/Learning
/zhiwehu_Python_exercises/Q15.py
773
3.71875
4
""" Question 15 Level 2 Question: Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a. Suppose the following input is supplied to the program: 9 Then, the output should be: 11106 Hints: In case of input data being supplied to the question, it should be assumed to be a console...
e94af95019e48321cc3b01d2ca581218904776df
BYN13K/Learning
/zhiwehu_Python_exercises/Q17.py
1,338
3.9375
4
# ### Question 17 # Level 2 # Question: # Write a program that computes the net amount of a bank account based a transaction log from console input. The transaction log format is shown as following: # D 100 # W 200 # D means deposit while W means withdrawal. # Suppose the following input is supplied to the program: #...
d7a0a0ca36a41f814db0d040cd5af4be44eb1733
BYN13K/Learning
/zhiwehu_Python_exercises/Q22.py
976
4.125
4
# ### Question 22 # Level 3 # Question: # Write a program to compute the frequency of the words from the input. The output should output after sorting the key alphanumerically. # Suppose the following input is supplied to the program: # New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python ...
5396cd0c2ab3fbec3bb20425eee9bb6c48b60091
asing012/Subnet-Calculator
/subnet_calc.py
4,934
3.875
4
#!/usr/bin/env python # Akshay Singh # Program to calculate the broadcast address, network address and number of hosts. import ipaddress def subnet_calc(): try: while True: print("Welcome to the Subnet Calculator \n") ip_input = raw_input("Enter an ip address: " ) ...
8deef3122ffa12cdded1901d948c59e1042c6bb5
ericyuegu/python-sandbox
/find-pair-sum.py
909
3.625
4
# Given a sorted array of n distinct integers a1 < a2 < . . . < an and an integer X, # you want to find if there exist indices i and j (where i != j) such that ai + aj = X. # Give an O(n) comparison algorithm for this task. ''' Returns: (i, j) if ai + aj = X None otherwise ''' def findPair(arr, X): lower = 0 upper...
ad7a4bb32bd2a19c24df896b0900829de7062c2d
irfan87/python_tutorial
/playground/users.py
447
3.796875
4
# make a users list users = ['ivy', 'amanda', 'nina', 'brock', 'jimmy', 'carragher'] # insert new user in the list users.append('james') users.append('colby') users.append('sam') # sorted users as alphabetical users.sort() # get the last four users for user in list(users[4:]): print(user) # checked if certain u...
c250510b1420549d143aeba41aae6895e0aa6f2a
irfan87/python_tutorial
/unit_test/class_test/language_survey.py
518
4.28125
4
from survey import AnonymousSurvey # define a question and make a survey question = "What language did you first learn to speak?" my_survey = AnonymousSurvey(question) # show the question, and store responses to the question my_survey.show_question() print("Enter 'q' to exit") while True: response = input("Langu...
bb12c322eb9d6f8707cb039f0df33d4002d53978
irfan87/python_tutorial
/user_input/three_exits.py
554
4.1875
4
user_input = "Test three exits with while loop" user_input += "\nEnter 'quit' or 'q' to exit the application\n" # exit number 1 # message = "" # while message != 'quit': # message = input(user_input) # print(message) # exit number 2 # active = True # while active: # message = input(user_input) # if...
2564eba8485d80a0268810eb59e3dc2699fbb09a
irfan87/python_tutorial
/classes_python/User/admin.py
608
3.796875
4
from user import User class Admin(User): def __init__(self, first_name, last_name, age, job_title): super().__init__(first_name, last_name, age, job_title) self.privileges = Privileges() class Privileges(): def __init__(self, privileges=[]): self.privileges = privileges def show_p...
66fa7979fef174f85d08811198a0ae78f0f294d7
irfan87/python_tutorial
/conditionals/favorite_fruits.py
360
3.953125
4
# my favorite fruits favorite_fruits = ['banana', 'apple', 'orange'] if 'banana' in favorite_fruits: print("I love banana") if 'apple' in favorite_fruits: print('I love apple') if 'orange' in favorite_fruits: print('I love orange') if 'grape' in favorite_fruits: print('I love grape') if 'lime' in f...
851e1c262384fd004cebb3f87e017f868e9137c2
irfan87/python_tutorial
/conditionals/toppings.py
859
3.9375
4
# make this app efficiently available_toppings = ['mushrooms', 'olives', 'green peppers', 'pepperoni', 'pineapple', 'extra cheese'] requested_toppings = [] requested_toppings.append('mushrooms') requested_toppings.append('extra cheese') requested_toppings.append('french fries') if requested_toppings: for request...
c0122d17503fe5f5999613ef4b91c69a3ebf23da
irfan87/python_tutorial
/user_input/cities_v2.py
268
4.03125
4
prompt_message = "Please enter which city do you like to visit: " prompt_message += "\nEnter 'quit' to exit this program\n" while True: city = input(prompt_message) if city == 'quit': break else: print(f"I like to visit {city.title()}\n")
240779663da33a76735a3d0a7ef27ea949a91fb4
irfan87/python_tutorial
/lists/diy_list_application.py
2,688
4.625
5
# a simple application that show the list of my friends # it will have the existing friends and new friends # TODO: list of my existing friends my_existing_friends = ['ivy', 'nick', 'sol', 'amin', 'sham', 'wan', 'aiman'] print(my_existing_friends) # TODO: send greetings to each friend my_friend = my_existing_friends...
10b38a130e9745d8683857217d64f45f7f144b3d
irfan87/python_tutorial
/numbers.py
133
3.78125
4
first_number = 2 second_number = 3 add_result = first_number + second_number print(f"The result of add is could be: {add_result}")
0784ac4176fa5e3fa410e837d06f09a978c6edc5
irfan87/python_tutorial
/user_input/restaurant_seating.py
168
3.890625
4
message = input("How many sits do you want? ") message = int(message) if message <= 8: print("Your table is ready") else: print("Sorry, sir, you have to wait")
bdae7bc78c850cde1831a5f311db0cd1dcb0a25f
ujjwal9/algo-ds
/stack.py
1,898
3.75
4
#Find next greater element for each array element. NGE def next_larger_element(arr): stak=[] result=[] for i in xrange(len(arr)-1,-1,-1): while stak[len(stak)-1]<arr[i]: stak.pop() result[i] = stak[len(stak)-1] if stak else -1 stak.append(arr[i]) #queue using 2 stacks #making dequeue expensive #queue using 1...
14c172c9fe399b581e567668762e1d384dcfb7cb
ujjwal9/algo-ds
/sort.py
2,657
3.703125
4
#Tim sort #https://medium.com/@george.seif94/this-is-the-fastest-sorting-algorithm-ever-b5cee86b559c #insertion sort (pick up an element arr[i] and insert it in a sorted sequence arr[i-1]) import heapq def insertion_sort(arr): for i in xrange(1,len(arr)): key=arr[i] j=i-1 while j>=0 and key<arr[j]: arr[j+1]=a...
6013c4a0a61d954c95817952602184999e2f3606
ujjwal9/algo-ds
/backtracking.py
4,084
4.0625
4
#make recursion not return the result but whether the current state is correct or not the #terminating condition should be the result bakctracking is_safe should be after for loop #ie it should be first checked if the solution is viable or not. def permutation(str_arr, start, end): #abc, acb, bac, bca, cba, cab if(s...
5b8d0caf2191e5e96c6140df9691243323de848b
dacuster/Data_Analytics
/Assignment1/main_code.py
4,303
4.125
4
#!/usr/bin/python -tt # Credit Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Basic string exercises # Fill in the code for the functions below. main() is already set up # to call the functions with a few different inputs, # printing 'OK' when each function ...
4327db517bf436f54c3fd3c41ccfaa23899a9bce
erkanredzheb/Simple-Python-Calculator
/SimpleCalc.py
1,468
4.34375
4
# Program make a simple calculator that can add, subtract, multiply and divide using functions # This function adds two numbers def add(x, y): return x + y # This function subtracts two numbers def subtract(x, y): return x - y # This function multiplies two numbers def multiply(x, y): return x * y # This...
c81a69c4406abb2c98d0b3fb1ad25544d43d3cc4
Artineer9401/CSL-YOLO
/tools/cfg_parser.py
1,339
3.515625
4
def ParsingList(list_str): if(list_str[0]!="[" or list_str[-1]!="]"): return list_str list_str=list_str[1:] list_str=list_str[:-1] val_list_buf=list_str.split(",") val_list=[] for i in range(len(val_list_buf)-1): if(val_list_buf[i][0]=="[" and val_list_buf[i+1][-1]=="]"):...
6c348bd5fb6b4a1dffdc24291bb31235ba82d11a
9car/IN1000-2
/assignments/assignment_4/funksjoner.py
591
3.625
4
''' Oppgave 1: Parametere og returverdier ''' #1.1 def add(num1, num2): return num1 + num2 print(f"sum: {add(20,10)}") print(f"sum: {add(20,20)}") #1.2 og 1.3 def count_occurrences(my_txt, my_char): occur = 0 #Sjekker hver char i input streng mot brukerinput for char in my_txt: if char == my...
bc1a199e7a31281c74a21023eb414630944adf20
anonymousassist/First-Git
/hellofirst.py
156
3.890625
4
a = print("Hello World") for i in range(11): print(a) print("What are you thinking about? i m pro and i know :) ") for i in range(1,5): print("Yes")
d1c89b9c93b32996140587f506b58544de544c0f
rezoanahmed/uri_solutions_python
/1070.py
80
3.75
4
number = int(input()) for x in range(number,number+12): if(x%2!=0): print(x)
f6adf37e2fb80721fd14ac7057fb66776122d369
rezoanahmed/uri_solutions_python
/1019.py
310
3.984375
4
N = int(input()) seconds = N%60 if (seconds<60): seconds = seconds else: seconds = seconds - 60 minutes = int(N/60) hours = int(minutes/60) if(minutes < 60): minutes = minutes else: minutes = minutes%60 hours = str(hours) minutes = str(minutes) seconds = str(seconds) print(hours+':'+minutes+':'+seconds)
651f219a770261e9eb3493384a8c8281e8d581b2
rezoanahmed/uri_solutions_python
/1002.py
79
3.578125
4
R = float(input()) n = 3.14159 A = n * pow(R,2) print("A=""{0:.4f}".format(A))
c6188a156e72b78cc1565696ff9a25eb659dee98
rezoanahmed/uri_solutions_python
/1010.py
236
3.71875
4
product1 = input().split(' ') product2 = input().split(' ') code1, unit1, value1 = product1 code2, unit2, value2 = product2 total = ((int(unit1) * float(value1)) + (int(unit2) * float(value2))) print('VALOR A PAGAR: R$','%.2f'%total)
7b7a706e289eba50d91800e6f32aaef3a4d308fa
rezoanahmed/uri_solutions_python
/1016.py
65
3.515625
4
distance = int(input()) time = distance * 2 print(time,"minutos")
e5f950ca6627776d174b567e86f4f950c6d9dbae
rezoanahmed/uri_solutions_python
/1012.py
389
3.75
4
A,B,C = input().split(" ") TRIANGULO = 0.5 * float(A) * float(C) CIRCULO = 3.14159 * pow(float(C),2) TRAPEZIO = 0.5 * (float(A) + float(B)) * float(C) QUADRADO = pow(float(B),2) RETANGULO = float(A) * float(B) print('TRIANGULO:','%.3f'%TRIANGULO) print('CIRCULO:','%.3f'%CIRCULO) print('TRAPEZIO:','%.3f'%TRAPEZIO) pri...
8aa04c75e7772bacb9b4cea6c259a76da96a945b
rezoanahmed/uri_solutions_python
/1021.py
1,025
3.5625
4
N = float(input()) dollars = int(N) cents = N - dollars #Dollars hundred = int(dollars/100) fifty = int((dollars%100)/50) twenty = int(((dollars%100)%50)/20) ten = int((((dollars%100)%50)%20)/10) five = int(((((dollars%100)%50)%20)%10)/5) two = int((((((dollars%100)%50)%20)%10)%5)/2) one = int((((((dollars%100)%50)%20...
20f8ade6d5fa2d1238c5c09e59ff4e9790ee8c6a
jhoagland18/util-scripts
/google.py
438
3.625
4
# mapIt.py - Launches a map in the browser using an address from the # command line or clipboard. import webbrowser, sys, pyperclip def main(): if len(sys.argv) > 1: # Get address from command line. query = '+'.join(sys.argv[1:]) else: # Get address from clipboard. query = pype...
ee4d1a266059d88238eda804f3707eb52ab20e31
MilyChen/simple-scatter-plot
/src/library.py
267
3.640625
4
''' Created on Aug 26, 2017 @author: Mily ''' def height_ftiins_to_cm(x): # print x x = x.replace('"', "") heights = x.split("'") ft_to_cm = float(heights[0]) * 30 incs_to_cm = float(heights[1]) * 2.5 return ft_to_cm + incs_to_cm
fc9e270dbed55e6b63a7abdc064badb7cc2a2b22
technogleb/concurency_and_parallelism
/threads/create_thread_native.py
252
3.984375
4
"""This is the most natural way of creating thread in python.""" import time import threading as th def countdown(n): for i in range(n): print(n-i-1, 'left') time.sleep(1) t = th.Thread(target=countdown, args=(3, )) t.start()
2ac407d73373fb088cdb0274ceb5c0ae509433f2
renlliang3/SHERLOCK
/sherlockpipe/search_zones/SearchZone.py
593
3.5
4
from abc import ABC, abstractmethod from lcbuilder.star.starinfo import StarInfo class SearchZone(ABC): """ Abstract class to be implemented for calculating minimum and maximum search periods for an input star. """ def __init__(self): pass @abstractmethod def calculate_period_range(s...
68c7dcc3c5c8329008bdade2112d776668b3ed08
saurabh-kumar88/DataStructure
/algorithms/boyerMoore_voting.py
767
3.828125
4
from collections import Counter def boyer_moore_voting(arr): candidate = None count = 0 # arr.sort() # print(arr) for value in arr: if count == 0: candidate = value count += (1 if candidate == value else -1) # Condition for majority test # if count > len...
fa87e9ec1dcac3fae46ba44f6a7de810bc587c67
saurabh-kumar88/DataStructure
/algorithms/kadanes_algorithm.py
456
4.125
4
"kadane's algorithm" "reference : https://medium.com/@rsinghal757/kadanes-algorithm-dynamic-programming-how-and-why-does-it-work-3fd8849ed73d " def kadane_max(arr): local_max, global_max = 0, float('-inf') for number in arr: local_max = max( number, (local_max + number) ) if local_max > global_max: g...
9c0d632dab70195245510c6fd1ab5eaf785f3bbc
saurabh-kumar88/DataStructure
/Tree/intro.py
1,415
4.03125
4
class Node: def __init__(self, relation, name): self.relation = relation self.name = name self.right = None self.left = None class Family_tree: def __init__(self, relation): self.relation = relation self.right = None self.left = None ...
65818debf30ece5aaea46dd9d09d68e317fa1c6e
saurabh-kumar88/DataStructure
/Tree/tree2.py
4,201
3.9375
4
from collections import deque class Node(object): def __init__(self, value): self.value = value self.left = None self.right = None def depth(self): left_depth = self.left.depth() if self.left else 0 right_depth = self.right.depth() if self.right else 0 retur...
17b3cf663e79a2c5babce5d0df3923909de8c9f3
pil0u/recap_roulette
/roulette.py
809
3.953125
4
from random import choice from time import sleep STUDENTS = [ 'Name 1', 'Name 2', 'Name 3', ] def rien_ne_va_plus(hot_seats, safe_students): if hot_seats == []: hot_seats = STUDENTS.copy() safe_students = [] print(f"Students on the hot seats for the next question:\n\t{', '.join(hot_seats)}\n")...
d3d448d40e29c4138b171aa30367be307aa22752
LuisBarroso37/Movie-Genres-Prediction
/preprocess_data.py
2,815
3.71875
4
""" preprocess_data.py. This script creates a data preprocessing class. """ # Imports import pandas as pd import nltk from nltk.corpus import stopwords from sklearn.preprocessing import MultiLabelBinarizer from tensorflow.keras.preprocessing.text import Tokenizer from tensorflow.keras.preprocessing.sequence import pa...
aaa1bc16a8e3697f70291b99caf2633f576079fb
evgeniitsvetkov/python-project-lvl1
/brain_games/games/progression.py
687
3.765625
4
#!/usr/bin/env python import random START_MIN = 1 START_MAX = 19 STEP_MIN = 1 STEP_MAX = 9 LENGTH_MIN = 5 LENGTH_MAX = 10 INDEX_MIN = 0 TASK_DESCRIPTION = 'What number is missing in the progression?' def get_task(): start = random.randint(START_MIN, START_MAX) step = random.randint(STEP_MIN, STEP_MAX) l...
28e7e6351e38e50b845dfb13beff36ff07c7cb93
wmatzko/astrostats
/astrostats_lecturecode.py
420
3.5625
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 4 18:48:05 2021 @author: William """ import numpy as np import matplotlib.pyplot as plt np.random.seed(42) n= 2 N = 10000 x = np.random.randn(n, N) xbar = np.mean(x, axis = 0) print(x, x.shape, xbar[0]) x2= np.random.randn(N,n) xbar2 = np.mean(x2, axis = 1) print(x2, x...
76efff2f5dad528a370e12b64b5c2e81a37019f3
mikelazzaro/real_python
/sql/sqlh.py
490
3.703125
4
# UPDATE and DELETE import sqlite3 with sqlite3.connect("new.db") as conn: c = conn.cursor() c.execute(""" UPDATE population SET population = 9000000 WHERE city='New York City' """) c.execute("DELETE FROM population WHERE city='Boston'"...
61962b0dd04190428a530b9ffbb5eea8b8d72a05
Team-AiK/TT-Thinking-Training
/Week01/groovypark/4_sum_digit.py
281
3.765625
4
def sum_digit(number): number = str(number) i = len(number)-1 result = 0 while i > -1: result += int(number[i]) i = i - 1 return result # 아래는 테스트로 출력해 보기 위한 코드입니다. print("결과 : {}".format(sum_digit(123)));
88e5dfee187d2a6a73ca8e0cda33291857d72016
Team-AiK/TT-Thinking-Training
/Week03/hong/2.py
407
3.71875
4
def collatz(num): answer = 0 while True: if num==1: break elif answer ==500: answer=-1 break elif num%2==0: #짝수 num=num/2 elif (num-1)%2==0:#홀수 num=num*3+1 answer+=1 return answer # 아래는...
7c2d275eded8bfe44078f9f4261d472c21a01a91
khuang110/Lin_Kernighan_TSP
/euclideanGraph.py
2,710
3.984375
4
import math import itertools # Used to find all possible sets # Disjoint set # Union - Find class Set: # set: disjoint set of vertices # ln: length of set def __init__(self, n): self.set = [-1]*n self.ln = 0 # Create a union of two sets def union(self, v1, v2): ...
502765b724a11c0dbf6744b4fffc18daf1781951
Amelia-Lin/Python-Practice-Respository
/choose_your_storyline.py
3,231
4.3125
4
''' Users can create different versions of a story choosing between given options that results in different scenarios for their named character. Each decision will send the character on a adventurous path that may end in either victory or their demise. ''' character_name = input("Give your adventurer a name: ") ...
d4e62722538a48df5e91dbf1bbb7f6037c1c624d
BuzzDyne/hacktiv8-python
/sesi_6/main_generator.py
360
3.9375
4
def counter(low, high=None): if high: while low <= high: yield low low += 1 else: while True: yield low low += 1 print(type(counter(1))) for x in counter(1,3): # if x % 20 == 0: # print() print(x, end=" ") x = counter(1,3) print...
312563a7f4074b9c76bc5df803dbc509d812666d
sjara/jaratoolbox
/jaratoolbox/extrafuncs.py
3,982
3.71875
4
#!/usr/bin/env python ''' Additional functions often used but not available in python modules. ''' import numpy as np import datetime import importlib def pad_float_list(listOfLists, length=None, pad=np.NaN): '''Pad a list of lists of floats with nan to the same length. Args: listOfLists: a list of ...
5567b041795591bfffdecc08cda8b59dd4836273
sheucke/datascience
/lesson_04_visualisation.py
2,761
3.5625
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt drinks = pd.read_csv('../data/drinks.csv') # bar plot of number of countries in each continent drinks.continent.value_counts().plot(kind='bar', title='Countries per Continent') plt.xlabel('Continent') plt.ylabel('Count') plt.show() # bar plot of ...
6f807a6d73750492f62a07a3d7b2990ab3dc7e76
sheucke/datascience
/lesson_00_basic.py
2,911
4.0625
4
''' Multi-line comments go between 3 quotation marks. You can use single or double quotes. ''' # One-line comments are preceded by the pound symbol # BASIC DATA TYPES x = 5 # creates an object print(type(x)) # check the type: int (not declared explicitly) type(x) # LISTS nums = [5, 5.0, 'five'] # multiple data...
e7ea5ab42a733e60376b84a39652ef683c5a698e
hannah26hannah/TIL
/python-17techs/Chapter_2/08_JSON/json_reader.py
1,944
3.625
4
import json def open_json_file(filename): with open(filename, encoding='UTF8') as file: try: return json.load(file) except ValueError as e: print('JSON 데이터를 파싱하는 데 실패했습니다. 사유={0}'.format(2)) return None json_data = open_json_file('python-17techs/Ch...
d823d315231094c613060d0dbad8f5fd267e2fd1
hannah26hannah/TIL
/python-17techs/Chapter_1/04_RegExp/check_password.py
996
3.703125
4
import re def check_password(password): # len(password) >= 8 코드로도 검사 가능 result = re.search(r'.{8,}', password) if not result: print("최소 8글자 이상이어야 합니다.") return print(password) result = re.search(r'[a-z]+', password) if not result: print("최소 1개 이상의 소문자가 필요합니다."...
bd72104cf37f85c01c5d81f386768245b399d478
isabella-df/bacteria-growth
/bacteria_Growth.py
11,959
3.8125
4
#importing libraries import numpy as np import matplotlib.pyplot as plt import os.path def dataLoad(filename): mat1=np.loadtxt(filename) #Made matrix from txt file t=0 data=np.array([-1,-1,-1]) #set data as an arbitrary array with same no of columns as matrix mat1 for row in mat1: #for loop...
a6c75e0cfa541533ecdf0161eaf149df9506ede1
echrisinger/Blind-75
/solutions/removeNthFromEnd.py
831
3.859375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: if not head or (head.next == None and n == 1): return None ...
77e0b3ab49b02f0f6a904c9f69f199240e3e9cd2
echrisinger/Blind-75
/solutions/encodeDecode.py
1,069
3.578125
4
import re class Codec: def encode(self, strs: [str]) -> str: """Encodes a list of strings to a single string. """ final_strs = [] for s in strs: length = len(s) curr_str = "{},{}".format(str(length), s) final_strs.append(curr_str) ...
ed19ccbe643ae746889cd47b05da6425cd26368f
echrisinger/Blind-75
/solutions/spiralMatrix.py
2,494
3.5625
4
class Solution: # supplying an imperative & recursive solution. # needs to descend the middle: # 2 5 5 # 8 4 2 # 0 1 3 # 1 1 1 # needs to go right across the middle # 2 5 5 1 # 8 4 2 1 # 0 1 3 1 # no action # 1 1 1 # 1 1 1 def spiralOrder(self, matr...
f40e1d6ae60895d424e519a97d4b1ed6afe835a5
echrisinger/Blind-75
/solutions/wordDictionary.py
1,660
3.859375
4
class Node: def __init__(self): self.is_word = False self.children = [None]*26 def _to_i(c): return ord('a') - ord(c) class WordDictionary: def __init__(self): """ Initialize your data structure here. """ self.root = Node() def addWord(self, wo...
3c186c48449719bcd17624bf0dad298256c5aa91
echrisinger/Blind-75
/solutions/countSubstrings.py
719
3.5625
4
class Solution: # initial inclincation is either: # sliding window # dynamic programming # sliding window will not work # abacaba # window: aba => abac => c, would miss whole string # dynamic programming it is def countSubstrings(self, s: str) -> int: count = 0 ...
7d820ed397eb8a1f0eabe7d5b356e99c2868d857
vdschiu/lpthw
/ex5.py
737
3.609375
4
name = 'Vds Chiu' age = 35 # not a lie height = 74 # inches weight = 180 # lbs eyes = 'Black' teeth = 'a littel bit yellow' hair = 'Black' c_height = height * 2.54 k_weight = weight * 0.45 print "Let's talk about %s" % name print "He's %d centimeters tall." % c_height print "He's %d kilograms heavy." % k_weight print...
c98160ffb5cf272279520b04c4cadff637baef3c
vikxun/shiyanlou-code
/thrid_week/8/sumtest.py
272
4.03125
4
#!/usr/bin/env python3 a = int( input('Please enter the first num: ')) b = int( input('Please enter the second num: ')) c = int(input('Please enter the third num: ')) print('{} is {}, {} is {}, {} is {}, {} = {}'.format('a',a, 'b', b, 'c',c,'a + b + c',(a+b+c)))
01f7316da0ff5b77b7c080f683636127e8781511
vikxun/shiyanlou-code
/Sencod_week/calculator.py
1,461
3.6875
4
#!/usr/bin/env python3 import sys salary = () list_salary = [] list_ = [] dict_ = {} def calculator_salary(id_, pay): if pay <= 5000: in_hand_salary = pay - pay * 0.165 else: should_pay = float(pay - pay * 0.165 - 5000) if should_pay > 0 and should_pay <= 3000: sh...
fecd8f59658820a4a0c20f04ea482476213c01f0
Brefew/Moore_CSCI3202_Assignment1
/Moore_Assignment1.py
5,368
4.0625
4
#Ian Moore Assignment 1 import Queue class Queue(): q = Queue.Queue() def __init__(self): pass def queueSize(self): return self.q.queueSize() def empty(self): return self.q.empty() def put(self, integer): self.q.put(integer) def get(self): return self.q.get() class Stack: def __init__...
3e474d97183470b9e934f262e21ea4f0b7d43c46
channiemills/project_work
/practice_exercises/housepw.py
728
3.578125
4
def housepw(data): """ Check passwords for security :param data: :return: True if password is secure else false """ return (len(data) >= 10 and any(i.isdigit() for i in data) and any(i.isalpha() for i in data) and any(i.isupper() for i in data) and any(i.islower() for i in data)) if _...
08841e4a1e607fb01c1d720365772b2e0bcbc178
guidorony/oredenamiento-por-insercion
/script1.py
1,020
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 28 21:58:52 2020 @author: Rony """ numero1=float(input('Ingrese primer valor : ')) numero2=float(input('Ingrese suegundo valor : ')) def suma(a,b): return a+b adicion=round(suma(numero1,numero2),2) def res(a,b): return a-b diferencia=round(res(numero1,numero2),2) ...
77db6a0822f4195355b481fd9b0a84d1c407d156
JadoRob/NCI-AWS-Restart
/Programming/Exercises/main.py
659
3.96875
4
import os import math from os import system from Programming.Exercises.calculate import calculateGallonPrice, displayGallonsNeeded, caclulateWallArea #Ask user for the length width and height length=int(input('Please enter the length of the room: ')) width=int(input('Please enter the width of the room: ')) height=int(...
462b40d1f00b75154a937fb166d288fa117c32ee
wblanken/HackerRank
/Angrams.py
3,335
4.09375
4
""" Strings: Making Anagrams https://www.hackerrank.com/challenges/ctci-making-anagrams Alice is taking a cryptography class and finding anagrams to be very useful. We consider two strings to be anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strin...
774600c5418cadf660c88bb66c980de0e0d19c1f
UnSooNook/nomadcoders-challange_web-scraper
/_assignments/04/main.py
1,248
3.625
4
import os import requests def askStartOver(): answer = input("Do you want to start over? y/n ") if answer == "y" or answer == "Y": return True elif answer == "n" or answer == "N": print("k. bye!") return False else: print("That's not a valid answer") return askStartOver() def isItDown(ur...
38d9eacd8dc83c8dc56a67ff7ea2c6ed4c8a4e8a
Sal4321/Leetcode-solutions
/matrixsum.py
545
3.734375
4
# -*- coding: utf-8 -*- """ Created on Thu May 27 10:05:09 2021 @author: Salehin """ def diagonalSum(mat): n=len(mat) i=0 j=0 k=i l=n-1-(i) total=0 while i<n and j<n: if i==k and j==l: total=total+mat[i][j] else: ...
9faf57214fcd595a94a0e21e5d5a68387a480fa8
tremlab/morseCodeTranslator
/morse_code.py
1,698
4.15625
4
# @tremlab # a python module that builds a populated binary tree for morse code values, with a method to easily translate a morse code string to its letter. # from morse_code import Morse_Code_Bin_Tree # mc_tree = Morse_Code_Bin_Tree() # mc_tree.translate_mc_to_letter("....") => "H" class Morse_Code_Bin_Tree(o...
c067b5b5510433b4ad81809f3fe1ff0119e5432e
parthkpatel/Automate-the-Boring-Stuff-with-Python
/Chapter 19 - Manipulating Images/custom_seating_cards.py
1,458
3.671875
4
# A program that, given a .txt file path, goes through the text file line by line (will assume one guest per line) # and uses the pillow module to create images for custom seating cards for each guest import pyinputplus as pyip, os from PIL import Image, ImageDraw, ImageFont def create_custom_seating_cards(path): ...
ddede33d23dba61c5ca66e1755c00b9a837bc2c5
parthkpatel/Automate-the-Boring-Stuff-with-Python
/Chapter 16 - Working With CSV Files and JSON Data/excel_to_csv.py
1,577
4.0625
4
# A program that takes a path to a directory containing excel files. # The program will create a .csv file for every sheet within every excel file import pyinputplus as pyip, openpyxl, os, csv from pathlib import Path def excel_to_csv(path): p = Path(path) # Skip non-xlsx files all_excel_files = list(p....
5243afae614ce968a735dabd46a09fd59dd76c5c
parthkpatel/Automate-the-Boring-Stuff-with-Python
/Chapter 19 - Manipulating Images/Chapter Projects/resize_and_add_logo.py
1,414
3.78125
4
#! python3 # resize_and_add_logo.py - Resizes all images in current working directory to fit # in a 300x300 square, and adds catlogo.png to the lower-right corner. import os from PIL import Image SQUARE_FIT_SIZE = 300 LOGO_FILENAME = 'catlogo.png' logo_im = Image.open(LOGO_FILENAME) logo_width, logo_height = logo_im...
c881ff397811b242d4510504a6e1f0f1c82f15fe
parthkpatel/Automate-the-Boring-Stuff-with-Python
/Chapter 19 - Manipulating Images/resize_and_add_logo_extended.py
1,754
3.640625
4
#! python3 # resize_and_add_logo_extended.py - Resizes all images in current working directory to fit # in a 300x300 square, and adds catlogo.png to the lower-right corner. import os from PIL import Image def resize_and_add_logo(): SQUARE_FIT_SIZE = 300 LOGO_FILENAME = 'catlogo.png' logo_im = Image.open...
798ad8b7fedb6d1a41bd260706cacc589f5a148d
parthkpatel/Automate-the-Boring-Stuff-with-Python
/Chapter 05 - Dictionaries and Structuring Data/fantasy_game_inventory.py
790
3.921875
4
# A program that has two functions: one which adds items and their count to an existing inventory, and one which # prints out the items and their count from the inventory def display_inventory(inventory): print("Inventory:") item_total = 0 for key, value in inventory.items(): item_total += value ...
2675bf5411bac4ff5bc653b088fcde6dac9dd470
H-Jan/Bank_Account
/BankAccount.py
2,478
4.125
4
import re #First is initializing class class BankAccount: def __init__(self, full_name, account_number, routing_number, balance): self.balance = balance self.account_number = account_number self.routing_number = routing_number self.full_name = full_name #balance is zero, wil...