blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e5514cce596e76f5120a07921d85973b08c88d33
quocodile/auto_correct
/auto_correct.py
4,474
3.875
4
import csv def calc_edit_dist(word1, word2): ''' First, create a 2D array to enable dynamic programming. Then, use dynamic programming to alculate edit distance between two words. ''' #this method needs fixing comparison_matrix = create_comparision_matrix(word1, word2) num_rows = len(comparison_matrix...
33287805565dd6925d6876140ab2c81ebae9123b
yusureabc/LearningPython
/bmi.py
404
4.25
4
#!/usr/bin/env python3 height = input( 'Please enter your height (m):' ) weight = input( 'Please enter your weight (kg):' ) height = float( height ) weight = float( weight ) bmi = weight / pow( height, 2 ) if bmi <= 18.5: print( '过轻' ) elif bmi <= 25: print( '正常' ) elif bmi <= 28: print( '过重' ) elif bmi...
4a737c50155c9dd5ea06def246ee1af320c7e929
ash-github20/Python_programs
/Ceaser_cipher.py
1,429
4.15625
4
def encryption(plain_text,key): print("Plain text is: ",end="") plain_text = plain_text.replace(" ","") plain_text = plain_text.upper() print(plain_text.upper()) cipher_text="" for i in range(len(plain_text)): char = plain_text[i] cipher_text+=chr(((ord(char)+key-65)%26)+...
b5a018f96926215938d9e53c9d8a1034afc7b282
lisonzou/stockana
/test/globalvar.py
384
3.578125
4
a = 1 b = [2, 3] c = 1 def func(): a = 2 print("in func a:", a) b[0] = 1 print("in func b:", b) global c c = 3 print("in func c:", c) if __name__ == '__main__': print("before func a:", a) print("before func b:", b) print("before func c:", c) func() print("after func a...
5162cf244f8a10651a447be28ade403a566f040f
JuanScaFranTru/Randoms
/continuous/generics.py
883
3.875
4
from random import random def inverse_transform(G): """Generate a random number using the inverse CDF G.""" return G(random()) def rejection(Y_random, c, f, g): """Get a random number using the acceptance-rejection method. Y_random -- a random number generator with the same distribution as Y. c...
ec62f57c1743f669aada91fab3a15d4fb80756ff
JuanScaFranTru/Randoms
/continuous/distributions.py
3,444
3.96875
4
from math import log, sqrt, cos, sin, pi, exp from random import random from discretes.distributions import poisson def uniform(a, b): """Get a random number in [a, b].""" return (b - a) * random() + a def nroot(n): """Generate a random number with CDF F(x) = x ** n. This function uses the fact tha...
90d044d296cd0f1b5f6543f82ccb13386cabe1fd
EduardoEspinosaLahoz/Primera-Evaluaci-n
/tabla_de_multiplicar_while.py
264
3.984375
4
def tabla_de_multiplicar_while(): numero=input("Que tabla quieres que escriba?") #for i in range(numero,0,-1): i=numero while(i>0): print str(numero)+ " x "+ str(i)+ " = " + str (numero*i) i=i-1 tabla_de_multiplicar_while()
4a63ac2078354d60abbbd389d2c0aa75cacc01b6
oesukam/we-connect-flask
/app/tests/test_user_model.py
1,175
3.59375
4
import unittest import os from app.models.user_model import UserModel # import app.models.user_model.UserModel print(os.path) class TestUserModel(unittest.TestCase): """User model unit test""" def setUp(self): self.user_data = { "username": "username", "email": "username@emai...
0b1ef57b2669e25aed33557c7cc61d6373abb41b
youngerwei/nnlearning
/Perceptron.py
6,482
3.515625
4
import math import random import numpy as np from numpy import random import pylab # A function to generate the halfmoon data # where Input: # rad - central radius of the half moon # width - width of the half moon # d - distance between two half moon # n_samp - total number of the sam...
f048fa45d4f4836e7635557b0081c39a6d590453
thioaana/DataStructuresAndAlgorithms
/AlgorithmicToolbox/Week4DevideAndConquer/majority_element.py
1,624
3.875
4
# Uses python3 import sys import random def get_majority_element(a) : seq = MergeSort(a) l = len(seq) for i in range(int(l / 2) + l%2) : if seq[i] == seq[i + int(l / 2)] : return 1 return 0 def MergeSort(seq) : l = len(seq) if l == 1 : return seq mid = int(l / 2) se...
50bbf02ab74550cd7be6aa20519106ef8d1d8229
thioaana/DataStructuresAndAlgorithms
/AlgorithmsOnGraphs/Week3PathsInGraphs/bfs.py
3,823
3.734375
4
#Uses python3 import sys class Graph : def __init__(self, n) : self.numOfVertices = n self.graph = [[] for _ in range(self.numOfVertices)] # Return the number of Vertices def getNumOfVertices(self) : return self.numOfVertices # Return the number of Edges def getNumOfEdges...
15021adaeb5d0a86483c71e886eeae6ecd9e4524
Sinoh/CalPoly-CPE-202
/Lab 6/Lab6-merge_sort.py
2,301
3.953125
4
# Name: Jeffery Ho # Section: 201 - 11 import random # list of ints -> int # takes in a list, sorts it, and returns the # of comparisions needed to sort the list def insert_sort(alist): counter = 0 for idx in range(1, len(alist)): cur = alist[idx] pos = idx counter += 1 while (pos >...
1c1f1f43edf93986dc9654b359f091f3ca97d451
imraghava/close_pep
/test_isclose_c.py
7,350
3.515625
4
#!/usr/bin/env python3 """ Unit tests for isclose function -- this one tests the c version in is_close_module.py """ import unittest from is_close_module import isclose from decimal import Decimal from fractions import Fraction class ErrorTestCase(unittest.TestCase): """ ValueError should be raised if eithe...
21da205d55e834e154bc7679af19c4f01c2ca4aa
pauldedward/100-Days-of-Code
/Day 3/love_calculator.py
428
3.78125
4
name1 = input("Enter your name : ") name2 = input("Enter your partner's name : ") name = name1 + name2 name.lower() firstDigit = name.count("t") firstDigit += name.count("r") firstDigit += name.count("u") firstDigit += name.count("e") secondDigit = name.count("l") secondDigit += name.count("o") secondDigit += name....
1f4f105397457c8ece706af71bcbde2a0bbc158d
pauldedward/100-Days-of-Code
/Day-12/guessingGame.py
2,134
3.640625
4
import random import os clear = lambda: os.system('cls') logo = ''' _________ ______ ___ _____ __ ______ __ ____/___ _____________________ ___ |/ /____ __ ___ | / /___ ________ ______ /______________ _ / __ _ / / / _ \_ ___/_ ...
36bf68faf460c13605c23cb2d206b695a7bc6a6a
pauldedward/100-Days-of-Code
/Day-22/Pong/ball.py
1,008
3.78125
4
from turtle import Turtle, xcor import random class Ball(Turtle): def __init__(self): super().__init__() self.shape("circle") self.color("white") self.penup() self.goto(0,0) self.initial_velocity = (random.randint(0, 1), random.randint(0, 1)) self.x_ste...
ae7fbc009ea138158373f31ca337f5104a032add
pauldedward/100-Days-of-Code
/Day-14/higer or lower/main.py
2,114
3.65625
4
from gameData import data from art import logo, vs import random import os clear = lambda: os.system('cls') def resetScreen(): clear() print(logo) def displayGameplay(personA, personB, score, isRight): if isRight: print(f"You are right Yourscore is {score}") print(f'Compare A: {personA["n...
90ad171e6244268be436b57d3a9cc6e432c4eba9
pauldedward/100-Days-of-Code
/Day 8/caesar/caesarCipher.py
1,844
3.90625
4
import os def clear(): return os.system('cls') should_continue = True def cipherUnrestricted(message, direction, caesarNumber): cipheredMessage = "" if direction == 'e': for letter in message: if letter.isalpha(): cipheredMessage += chr((ord(letter) - ...
535667685bbf4a20af133f530ab3e2297d486c73
chapman-cpsc-230/hw3-matte31
/repeated_sqrt.py
391
3.84375
4
from math import sqrt for n in range (1,60): r = 2.0 for i in range (n): r = sqrt(r) for i in range (n): r = r**2 print '%d times sqrt and **2: %.16f' %(n,r) #takes the number r and taking the square root of the number then squaring that for n in range (1,60): r = 2.0 for i in r...
8717d83ea1d058f48f7514c2e8fc21751ca9bdbb
tomreitsma/rabotest
/test.py
1,135
3.640625
4
import unittest from word_frequency import WordFrequency from word_frequency_analyzer import WordFrequencyAnalyzer class TestWordFrequencyAnalyzer(unittest.TestCase): TEXT = '- A favorite copy set by writing teachers for their pupils is the following, ' \ 'because it contains every letter of the alpha...
073a15b9480f062a09b6905974a6ca4ff124b814
yoannawei/monkies
/parseCSV.py
748
3.8125
4
# convert a CSV file to a Dictionary import os import csv import string DATADIR = "" datafile = "beatles-diskography.csv" def parse_file(datafile): data = {} records = [] with open(datafile) as file: # reads the first line of the csv datafile # forms a keys list composed of the column na...
ac94d778bc93cd8e8262895399542d8544c92c42
15110500442/pa-
/机器学习/code/Coursera-Machine-Learning-master/ml-ex4/ex4.py
9,273
4.21875
4
## Machine Learning Online Class - Exercise 4 Neural Network Learning # Instructions # ------------ # # This file contains code that helps you get started on the # linear exercise. You will need to complete the following functions # in this exericse: # # sigmoidGradient.m # randInitializeWeights.m # ...
734628d51846c64b3040c3b73e8a394f2d08aa08
15110500442/pa-
/机器学习/code/Coursera-Machine-Learning-master/ml-ex3/ex3.py
2,438
4.125
4
## Machine Learning Online Class - Exercise 3 | Part 1: One-vs-all # Instructions # ------------ # # This file contains code that helps you get started on the # linear exercise. You will need to complete the following functions # in this exericse: # # lrCostFunction.py (logistic regression cost function) # ...
bfec72f67af66f00ba33302b63e9a123d045cc6c
15110500442/pa-
/深度学习/code/Coursera-Machine-Learning-master/ml-ex1/computeCost.py
402
3.734375
4
import numpy as np #COMPUTECOST Compute cost for linear regression # J = COMPUTECOST(X, y, theta) computes the cost of using theta as the # parameter for linear regression to fit the data points in X and y def computeCost(X, y, theta): # Initialize some useful values m = len(y) # number of training example...
28458621b08e967c02b9d9a3eab73ccad9ce8c3c
15110500442/pa-
/机器学习/code/Coursera-Machine-Learning-master/ml-ex7/drawLine.py
350
3.96875
4
import numpy as np import matplotlib.pyplot as plt from plotDataPoints import plotDataPoints #DRAWLINE Draws a line from point p1 to point p2 # DRAWLINE(p1, p2) Draws a line from point p1 to point p2 and holds the # current figure def drawLine(p1, p2, *varargin): # Plot the examples plt.plot([p1[0], p2[0]...
798c8e9a90aeaf59448c500b530f194919fc2c1d
15110500442/pa-
/复习/pachong/教学代码/第四天/global.py
517
3.734375
4
# 1、在函数外边定义的变量叫做全局变量 # 2、全局变量能够在所有的函数中进行访问 # 4、如果在函数中修改全局变量,那么就需要使用global进行声明,否则出错 # 5、如果全局变量的名字和局部变量的名字相同,那么使用的是局部变量的,强龙不压地头蛇 _name = '苍老师' def get_name(): global _name _name = '泽马老师' print(_name) def get_name1(): global _name print(_name) get_name() get_name1()
bbcbfd890fba95ab02298b37fcdc2789153aff57
Voluter/algorithm
/3.4.3DLNode.py
1,937
3.875
4
class LNode: def __init__(self,elem,next_=None): self.elem=elem self.next=next_ class DLNode(LNode): def __init__(self,elem,next_=None,pre=None): LNode.__init__(self,elem,next_) self.pre=pre class DLList: def __init__(self): self._rear=None self._hea...
eec05a113f8cf49db1d03d62a7d0ad8747b79623
shivam-arora742/python_hackerRank
/Python-hackerRank/leap_year.py
243
4.09375
4
def is_leap(year): leap = False # if it is century year (00) if(year%100==0 and year%400==0): leap=True if(year%100!=0 and year%4==0): leap=True return leap year=input() year=int(year) print(is_leap(year))
bd89cd59ec1f82558164b560091ac08707dd17bb
VeraMendes/Graphs
/projects/ancestor/ancestor.py
1,778
3.703125
4
# directed acyclic graph class Queue(): def __init__(self): self.queue = [] def enqueue(self, value): self.queue.append(value) def dequeue(self): if self.size() > 0: return self.queue.pop(0) else: return None def size(self): r...
03138f8c357900174497cd39d17da72533c4feb4
muralieee0898/Python
/fact.py
69
3.859375
4
n=int(input()) num=1 for i in range(1,n+1): num=num*i print(num)
1f18a986f61437644079407ee7c2914e93407685
ColinGreybosh/ProjectEuler-Python
/p019.py
2,504
3.84375
4
""" Project Euler Problem 19 ======================== You are given the following information, but you may prefer to do some research for yourself. * 1 Jan 1900 was a Monday. * Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Whi...
7e907fcb72eb4610f056b64f944b0653173bdb86
ColinGreybosh/ProjectEuler-Python
/p015.py
477
3.8125
4
""" Project Euler Problem 15 ======================== Starting in the top left corner of a 2 * 2 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 20 * 20 grid? """ import math def routes_through_grid_of_size_n(n): return int(math.fact...
06a9c7b964f2910cb502b40e75f9ac63ecaf0558
Raghibshams456/Python_building_blocks
/Numpy_worked_examples/015_numpy_checkerboard_pattern.py
463
3.859375
4
""" Create a 8x8 matrix and fill it with a checkerboard pattern """ import numpy as np Z = np.zeros((8,8),dtype=int) Z[1::2,::2] = 1 Z[::2,1::2] = 1 print(Z) """ PS C:\Users\SP\Desktop\DiveintoData\Numpy> python .\015_numpy_checkerboard_pattern.py [[0 1 0 1 0 1 0 1] [1 0 1 0 1 0 1 0] [0 1 0 1 0 1 0 1] [...
a077489d9dac846d19b7a06349925615f4aae1ce
Raghibshams456/Python_building_blocks
/Numpy_worked_examples/033_numpy_max_and_min.py
692
3.546875
4
""" Print the minimum and maximum representable value for each numpy scalar type """ import numpy as np for dtype in [np.int8, np.int32, np.int64]: print(np.iinfo(dtype).min) print(np.iinfo(dtype).max) for dtype in [np.float32, np.float64]: print(np.finfo(dtype).min) print(np.finfo(dtype).max) prin...
72a9b1982aed67e90b543451ae5bc79ae57b89a7
Raghibshams456/Python_building_blocks
/Numpy_worked_examples/016_numpy_100thindex.py
397
3.734375
4
""" Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? """ import numpy as np print(np.unravel_index(99,(6,7,8))) """ PS C:\Users\SP\Desktop\DiveintoData\Numpy> python .\016_numpy_100thindex.py (1, 5, 3) PS C:\Users\SP\Desktop\DiveintoData\Numpy> ...
f3fe4d0d00ce7afe31de0bdf69c7fdcf7151bf9b
JnnyRdng/flask_app_rock_paper_scissors__hw
/app/modules/game_test.py
1,974
3.6875
4
import unittest from app.modules.game import Game from app.modules.player import Player class TestGame(unittest.TestCase): def setUp(self): self.game = Game() self.player_r = Player("Jim", "rock") self.player_p = Player("Jim", "paper") self.player_s = Player("Jim", "scissors") ...
80f9bece4903405a1fb0fed1159d847751f8feeb
martin-marinov/PythonHomeworks
/challenge01.py
196
3.6875
4
COINS = (100, 50, 20, 10, 5, 2, 1) def calculate_coins(coins): result = {} coins *= 100 for coin in COINS: result[coin] = coins//coin coins %= coin return result
21490f70a87680cf7e08df6ed919cebfec219f29
Divyashreesaravanan/shalini
/reverse.py
48
3.734375
4
s=str(input()) print('Reverse string:'+s[::-1])
1f72c59c2fa3980595b3614e33bddafe81eeda4b
vug/coding-moding
/programming_pearls/column_01/generate_numbers.py
1,161
3.71875
4
""" Script that generates N M-bit Integers and writes them into a file. # problem input: took 10+ seconds, generated 85MB file python generate_numbers.py --number-count 10 --upper-range 10 --output-file "numbers_small.txt" # small input python generate_numbers.py --output-file "numbers_big.txt" """ import argparse ...
c0737c478669aff2a445c3713c583f72e35c6769
vug/coding-moding
/problems/decompress_string.py
1,736
3.703125
4
""" Question seen here https://leetcode.com/discuss/interview-experience/124626/Google-onsite-interview-questions """ def decompress(s: str) -> str: r = [] i = 0 while i < len(s): # loop over characters, add them to result while i < len(s) and s[i].isalpha(): r.append(s[i]) ...
0d7cd68d6d3468d360dd89701c208cc94becf8b8
mikeghen/dss-615-spring-2018
/module1/main.py
1,853
3.9375
4
# Lab 1: Body Mass Index height_meters = 2.1 weight_kilograms = 89.5 body_mass_index = weight_kilograms / (height_meters * height_meters) print(body_mass_index) # Lab 2: Slope of a line m = 0.5 b = 3 x = 2 y = m * x + b print(y) m = 1//2 b = 3 x = 2 y = m * x + b print(y) # Lab 3: Word Math hello = "Hello" wo...
4b30258fddc717168d9b5ebc35e4e493699d7c1e
huihui571/DL-homework
/hw3/assignment2/PyTorch.py
21,889
3.6875
4
#!/usr/bin/env python # coding: utf-8 # # Training a ConvNet PyTorch # # In this notebook, you'll learn how to use the powerful PyTorch framework to specify a conv net architecture and train it on the CIFAR-10 dataset. # In[ ]: import torch import torch.nn as nn import torch.optim as optim from torch.autograd impo...
42487bf267f29efcc2dd05e3478cf52c4dfe073e
DIGITALFRANK/dsc-object-oriented-attributes-with-functions-lab-nyc-ds-career-042219
/school.py
809
3.890625
4
class School: def __init__(self, name=None, roster={}): self.name = name self.roster = roster def add_student(self, student, grade_level): self.name = student self.grade_level = grade_level if grade_level in self.roster: self.roster[grade_level].append(studen...
66892bba8ce961d8ab4d77661ffc89333483f895
bivanalhar/math-clustering
/eng_clustering.py
5,054
3.9375
4
""" This program is intended to cluster the Math problem into several categories (still unknown) based on their similarity in the Math expression contained within the problem itself The program itself consists of several sub-parts, considering the type of the problem we're handling on right now (which con- sists of ko...
6ff2f0e77a32abd4bb27249f40f7268a3b440c48
LingChenBill/python400
/python_programming/ch15/001_mpl_squares.py
637
3.828125
4
#! /usr/bin/python3 # -*- coding:utf-8 -*- # @Time: 2021/2/6 # @Author: Lingchen # @Prescription: 绘制一个简单的拆线图. # page_306. import matplotlib.pyplot as plt int_values = [1, 2, 3, 4, 5] squares = [1, 4, 9, 16, 25] # plt.plot(squares) # plt.plot(squares, linewidth=5) # 同时提供输入值和输出值. plt.plot(int_values, sq...
5a4f00cece96dcc32d4a0c6668ea4739e3aca4ba
LingChenBill/python400
/python_programming/ch09/001_favorite_languages.py
802
3.734375
4
#! /usr/bin/python3 # -*- coding:utf-8 -*- # @Time: 2021/2/1 # @Author: Lingchen # @Prescription: Python标准库. # 记录被调查者参与调查的顺序. # 类名应采用驼峰命名法,即将类名中的每个单词的首字母都大写.而不使用下划线. # 实例名和模块名都采用小写格式.并在单词之间加上下划线. # page_178. from collections import OrderedDict # 创建一个空的有序字典. f...
24dd95434b81e06334d1790057da05157ba58128
JoyLubega/TheShoppingList
/app/classes/auth.py
1,081
3.5625
4
class App: def __init__(self): super().__init__() self.all_users = [] def sign_up(self, user): """ this function registers a user :param user: """ if [existing_user for existing_user in self.all_users if existing_user.email == user.email]: ...
323d705f64528385fad9fd7a232c852efec01deb
Aprilya/bioinformatics
/RNA.py
435
3.75
4
# rosaling.info RNA task from bioinformatics stronghold # transcribing coding DNA into RNA from sequence given in a sequence.txt sequence = open('sequence.txt').read() sequence_length = len(sequence) RNA = "" for i in range(sequence_length): if sequence[i] == "T": RNA += "U" else: RNA += seque...
9ecad8665f6528dba094c52e8da5de4d93901d2b
Dhananjay0701/Algorithm-Question
/reverse_list.py
494
4.125
4
# Question: Write function that reverses a list, preferably in place. def sol(arr): i = len(arr)-1 while i > (len(arr)//2)-1: # swapping ith element from start with ith element from last arr[i], arr[len(arr)-1-i] = arr[len(arr)-1-i], arr[i] i -= 1 return arr print(sol...
a3198277e9a8fc79d484fe600d093af5e0bddad6
deanc474/myrepo
/FFTShift.py
682
3.546875
4
import numpy as np import matplotlib.pyplot as plt #x - x data #y - y data #s - Shift (fraction of a data point) #note: (+s) shifts left, (-s) shifts right def FFTShift(x,y,s): #Compute Fourier Transform of y data fty = np.fft.fft(y) m = np.fft.fftfreq(len(y)) #Compute Appropr...
8bc46657bae02e76b70633a4d4655488a94fd854
waltercueva/CLRS
/C02-Getting-Started/exercise_code/Insertion_sort_with_binary_search.py
1,780
3.953125
4
# Exercise 2.3-6 in book # Standalone Python version 2.7 code import os import re import math import time from random import randint def insertion_sort(array): for j, v in enumerate(array): key = v i = j - 1 while i > -1 and array[i] > key: array[i+1] = array[i] i = i - 1 array[i+1] = key def inserti...
2ad9181a437e762f954c7909971d8da7fdb411ae
waltercueva/CLRS
/C31-Number-Theoretic-Algorithms/exercise_code/binary2decimal.py
281
3.53125
4
#!/usr/bin/env python # coding=utf-8 def b2d(binary, base): l = len(binary) if l == 1: return int(binary)*base; mid = l/2 high = binary[:mid] low = binary[mid:] return b2d(high, base*(2**(l-mid)))+b2d(low, base) binary = "1111" print b2d(binary,1)
365fe85952629b28f2cae8077384a4bc468894da
gayecolakoglu/PythonExercises
/TelephoneDirectory.py
2,187
4.15625
4
direc_dict={} x=1 while x==1: special_information_dict={} phone=[] mail = [] city = [] person=input("Please write the name and surname of the person you want to add to the directory:") if person not in direc_dict.keys(): x=3 while x==3: phone_num=input("Please enter ...
eaa965054846d0b658f81c57bbff0776e45988c5
yashvirsinghgrewal-crypto/energyexperiments
/thermalmodels_first_price.py
6,266
3.546875
4
import math from gym.utils import seeding import numpy as np """ First-order thermal model, approximating the temperature of a system, such as a house, a thermal zone, or a refrigerator by a single state variable (the indoor temperature). Model due Mortensen and Haggerty, "A stochastic computer model for hea...
402d817a98996d7c28b54aad5a65be729eb60aa2
MahabubArafat/TicTacToe
/toss.py
1,110
4.25
4
import random def toss(): print("----------->Welcome to Tic Tac Toe<---------------\n\n\n Figthing over WHO is gonna GO first? Let the computer decide then (@-@)\n\n\n") print(">>>>>>>>Enter Y to Let computer decide (If You have already Decided who is gonna go first then Enter N to start the game immediately...
2320a95963e4152b935d32c6d738f70e917124a3
tame0001/purdue
/ECE60146/hw1/hw1.py
3,390
4.1875
4
class Sequence(object): ''' The base class. The array is defined in this class. This class is iterable so all children inherit this. ''' def __init__(self, array) -> None: self.array:list = array # store array at base class self.index = -1 # index for iteration def __len__(s...
efe25ae5566e88c98a898fe17f2e64cab25a2a29
gitneeraj/ctfs
/cryptohack/mathematics/gcd.py
306
3.84375
4
#!/usr/bin/env python3 # Python code to demonstrate naive # method to compute gcd ( recursion ) def hcfnaive(a,b): if(b==0): return a else: return hcfnaive(b,a%b) a = 26513 b= 32321 # prints 12 print (f"The gcd of {a} and {b} is : ",end="") print (hcfnaive(a,b))
281c252300c5211771498712ed57d1355385348e
mradityagoyal/arduino
/Python/MagicFlyControl.py
2,253
3.578125
4
''' This code contains starting python code example for arduino pymata testing. ''' import time import sys import signal from PyMata.pymata import PyMata from binascii import unhexlify # Digital pin 13 is connected to an LED. If you are running this script with # an Arduino UNO no LED is needed (Pin 13 is connected...
62b2ba917a7293e2a443491be9b930ffa18e5c8d
t0ri-make-school-coursework/cracking-the-coding-interview
/stacks-and-queues/animal_shelter.py
2,393
4.0625
4
# 3.6 # Animal Shelter # An animal shelter holds only dogs and cats, and operates on a # strictly "first in, first out" basis. People must adopt either # the "oldest" (based on arrival time) of all animals at the # shelter, or they can select whether they would prefer a dog or # a cat (and will receive the oldest anima...
771ba494ba1336984c03cd8c1a5ea1ab663b5cdc
t0ri-make-school-coursework/cracking-the-coding-interview
/trees-and-graphs/first_common_ancestor.py
1,146
4.03125
4
from minimal_tree import min_tree from Node import TreeNode # 4.8 # First Common Ancestor # Design an algorithm to find the first common ancestor of two nodes in a binary tree. # traverse tree to find node1 # traverse tree to find node2 # 2 pointer traverse both traversal_node1 is not traversal_node2 def first_ances...
2fd1e687f5a7bc082be9f5285ed52db96156213b
t0ri-make-school-coursework/cracking-the-coding-interview
/linked-lists/partition.py
1,170
4.0625
4
from LinkedList import LinkedList from Node import Node # 2.4 # Partition # Write code to partition a linked list around a # value target,such that all nodes less than target # come before all nodes greater than or equal to target. def partition_llist(ll, target): high_nodes = [Node('partition')] node = ll.hea...
1116e994834c3305f702f922e7f5e9e22b8022ba
t0ri-make-school-coursework/cracking-the-coding-interview
/recursion-and-dynamic-programming/triple_step.py
574
4.46875
4
# 8.1 # Triple Step # A child is running up a staircase with n steps and can either hop # 1 step, 2 steps, or 3 steps at a time. Implement a method to count # how many possible ways the child can run up the stairs. def step_up(steps): if steps < 0: return 0 if steps is 0: return 1 else: ...
c9f3e7d9c4cf44213bff9ea0ad19cbbd8e648cb7
swm82/ProgrammingPearls
/Column2/bin_search.py
1,078
3.765625
4
def find_one_duplicate_element(arr, lo, hi): if lo + 1 >= hi: return arr[lo] + 1 mid = lo + ((hi - lo) // 2) # if the range of nums in left half, is less than number of el in left, search left if arr[mid] - arr[lo] != mid - lo: return find_one_duplicate_element(arr, lo, mid) if arr[h...
b34159d0258e6802251f6d6cd64f8607ac1b33c4
HugoVazquez-x/Neurofit
/tools.py
319
3.828125
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 16 13:59:48 2020 @author: hugov """ def x_in_y(x, y): # check if x is a nested list if any(isinstance(i, list) for i in x): return all((any((set(x_).issubset(y_) for y_ in y)) for x_ in x)) else: return any((set(x).issubset(y_) for y_ in y))
2b07522576f412ef2ec7917fd41374e5627da82d
feco93/TouristGuide
/app/weather/weather.py
1,815
3.78125
4
class Weather(object): def __init__(self, d): self.morn_temp = int(d["temp"]["morn"]) self.day_temp = int(d["temp"]["day"]) self.eve_temp = int(d["temp"]["eve"]) self.night_temp = int(d["temp"]["night"]) self.min_temp = int(d["temp"]["min"]) self.max_temp = int(d["te...
b12ad002347f8df43624043f643d72eba60edfa5
Mimi-D/Data-Structures
/Binary vs Interpolation.py
2,468
4.375
4
# DUKE MIRIAM # DATA STRUCTURES ASSIGNMENT 2 import random import time # Binary search function def binary_Search(array, target, low, high): if low > high: return False middle = (low + high) // 2 if array[middle] == target: return True elif array[middle] > target: ...
c94556df29ed843286f51a227beeebfd00f8c315
bashiralam185/PythonPracticeQuestions
/ChallengingQuestions1/Website_questions.py
40,130
3.53125
4
# Game wich generates auto numbers ,. each numbers has its own points and the player having more points will be winner # ############################33THis KATA is intended as a small challenge for my students (CODE WAR) ################################# # from random import randint # import time # def main(): ...
abe012b5574b0c2686ca5cfad648c3386ef4b844
nickrinaldi88/NBAblog
/news/bball_refparser.py
3,986
3.640625
4
# To be used as a tool on django site import requests from bs4 import BeautifulSoup import pandas as pd ''' TODO: 1. Write a web scraper and parse this page: https://www.basketball-reference.com/players/ and save a list of players names in text doc 2. Create function that takes in player name and creates suffix ...
b757cb8d884b20764b4801a30ae8ef7b1ecd27df
K2-cyber/Monash_Patient_Management_System
/Patient.py
1,157
3.78125
4
from Account import Account # patient class inherits from Account class class Patient(Account): __patient_first_name = "" # declare user_first_name attribute as private string __patient_last_name = "" # declare user_last_name attribute as private string # Constructor of Patient class def __init__(sel...
0fbf759a53fd4644a66e80ba3e563b49f8cecb4e
Jillllll/day4
/object/object_test.py
1,333
3.515625
4
#!/bin /env python # _*_coding=utf-8_*_ class Province(object): # static field:belong to class;can't access to dynamic field memo = 'one out of 23 provinces' # constructor def __init__(self, name, capital, flag): # dynamic field:belong to object;can access to static field self.Name = n...
d577b421178408760b67991142b6dbb16ec045ef
Dsbaule/INE5452
/Simulado 04/EscalonamentoDeIntervalosComPesos/src/__main__.py
5,509
3.890625
4
""" Autor: Daniel de Souza Baulé (16200639) Disciplina: INE5452 - Topicos Especiais em Algoritmos II Atividade: Quarto simulado - Questoes extra-URI Escalonamento de Intervalos com Pesos """ # Classe para representação de uma requisição class Requisicao(): def __init__(self, values: list): self.s, se...
620b4b111ffe5bcaec65a35d92e9927fb1d3b46d
Dsbaule/INE5452
/Simulado 10/07 - A Problem With A Happy Ending.py
2,968
3.9375
4
import math class Point(): def __init__(self, x, y): self.x = x self.y = y self.used = False def __repr__(self): return "(%d, %d)" % (self.x, self.y) def dist(p1: Point, p2: Point): return math.sqrt(((p1.x - p2.x) ** 2) + ((p1.y - p2.y) ** 2)) def angle(p1: Point, p2:...
578ecb32037037549449d565e772e1a8ad7486da
Dsbaule/INE5452
/Simulado 09/03 - The Law Goes on Horseback!.py
4,022
3.5625
4
from pprint import pprint class Vertice: def __init__(self): self.edges = set() self.searched = False def get_max(policemen_horses, horse_capacity, n = 0): if n >= len(policemen_horses): return 0 max_num = 0 for horse in policemen_horses[n]: if hor...
e878ed5b3aa20f70e129e3642216684188eba96f
Dsbaule/INE5452
/Lista 2 - Ad-Hoc e ordenação e Estrutura de Dados/04 - Medal Table.py
503
3.671875
4
n = int(input()) countries = list() for _ in range(n): country, gold, silver, bronze = tuple(input().split()) countries.append((int(gold), int(silver), int(bronze), country)) countries.sort(key=lambda x: x[3], reverse=False) countries.sort(key=lambda x: x[2], reverse=True) countries.sort(key=lambda x: x[1], ...
43d9c69b10e05f9eaab5c05cfc394b9ca89b4213
Dsbaule/INE5452
/Simulado 02/URI/06 - Level Order Tree Traversal.py
1,326
3.734375
4
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def insert(self, value): if self.value >= value: self.insert_left(value) else: self.insert_right(value) def insert_left(self, value): if ...
3c91cfab1ac0bcf584d0ba7611d2897fbe9d8af5
Dsbaule/INE5452
/Simulado 03/Karatsuba/src/__main__.py
4,368
4.1875
4
""" Autor: Daniel de Souza Baulé (16200639) Disciplina: INE5452 - Topicos Especiais em Algoritmos II Atividade: Terceiro simulado - Questoes extra-URI Algorítmo de Karatsuba De wikipedia: procedure karatsuba(num1, num2) if (num1 < 10) or (num2 < 10) return num1 × num2 /* Ca...
dc3faf74a5ef6ab49a205491f4399f54c36a3975
Dsbaule/INE5452
/Simulado 01 (Novo)/BucketSort/src/BucketSort.py
1,871
4
4
""" Autor: Daniel de Souza Baulé (16200639) Disciplina: INE5452 - Topicos Especiais em Algoritmos II Atividade: Primeiro simulado - Questoes extra-URI Pontos resolvidos: 1. 1 simbolo; 2. k símbolos; e 3. qualquer quantidade de símbolos Não realizei a checagem dos baldes não vazios devido a facilidade d...
d7e0a20c5e98743dd3ad6e20fa0318ef0d98ea5d
Dsbaule/INE5452
/Simulado 03/OrdemDasPermutações/src/__main__.py
3,304
4.03125
4
""" Autor: Daniel de Souza Baulé (16200639) Disciplina: INE5452 - Topicos Especiais em Algoritmos II Atividade: Terceiro simulado - Questoes extra-URI Ordem das Permutações """ # Outro algorítmo por backtracking para gerar todas as permutações de uma lista # (A lista ja deve estar preenchida com numeros de 1-n) de...
cd796ab406e69b773665f842d0d6ec006124b5da
Botany-Downs-Secondary-College/mathsquiz-NehaDesu
/Maths Quiz V1.py
1,548
3.890625
4
from tkinter import* class MathQuiz: def __init__(self,parent): self.Welcome = Frame(parent) self.Welcome.grid(row=0, column=0) self.TitleLabel = Label(self.Welcome, text = "Welcome to Maths Quiz", bg = "black", fg = "white", width ...
dc183d9c0dc43d38d7084943f90c7ce71efdfda7
ftgod/lab_14_all_parts
/fortune.py
1,233
4.5
4
""" fortune.py ===== Write a program that generates a random fortune. You'll be using the random module. 1. Ask the user if they want to see the future. 2. If the answer yes, y, or yeah, then use the rand int function to generate a random number between 1 and 5. 3. Create 5 fortunes. 4. Based on the number that is g...
d37617c8ab524575322effc19cf51600a7e4daa6
RadiObad/1MAC-Workshop
/16 - Stores/Forums/stores.py
505
3.546875
4
class MemberStore(): """This class provides a way to Manage Members Information""" members = [] last_id = 1 def get_all(self): return MemberStore.members def add(self, member): member.id = self.last_id self.members.append(member) self.last_id += 1 class PostStore(): """This class provides a way to Man...
ec4bb5a16e20efada23760dc5a3892296782b9d7
smishraaa/smishraaa
/python-projects/scrabble_functions.py
1,486
3.609375
4
def length_n(file_name,n): f = open(file_name, "r") len_n = [] for k in f.readlines(): k = k.strip().lower() #remove trailing or leading white spaces and lower case the word if (len(k) == n): len_n.append(k) f.close() return len_n def starts_with(file_name, n, first_letter): f = open(file_name, "r") l...
fefa1c2d37699e0808efd4759e4c6550d0610a1e
atharva07/python-files
/uncommon.py
485
4
4
# function to return all uncommon words def UncommonWords(A,B): # count will contain all word counts count = {} # insert word of string A into hash for word in A.split(): count[word] = count.get(word, 0) + 1 # insert word of string B into hash for word in B.split(): count[word...
e63dbc4ddbbd6d5be901f14a3067b81be519f9cd
atharva07/python-files
/count_str.py
771
4.5
4
# python code to count the frequency of string using naive method test_str = "geeksforgeeks" # intializing count to zero count = 0 for i in test_str: if i == 'e': count = count + 1 print("the frequency is as follows = " + str(count)) # there is another method to count the freqency of the occurence of stri...
d2df99942056a8e0f0e668af211d703e7376c31c
atharva07/python-files
/Madlibs2.py
495
3.765625
4
def fullname(first_name,last_name): compl_name = first_name + last_name return compl_name f_name = input("Enter the first name = ") l_name = input("Enter the last name = ") name_output = fullname(f_name,l_name) print(name_output) pl_list = [] maxLength = 4 while len(pl_list) >= maxLength: player = input("...
fae8069dafcee293ac265795773081b1c864fb5b
atharva07/python-files
/STACK.PY
568
4.21875
4
# creating a stack def create_stack(): stack = [] return stack # creating an empty stack def is_empty(stack): return len(stack) == 0 # adding an item into stack def push(stack, item): stack.append(item) print("Pushed item = " + item) # removing an item from stack def pop(stack): if (is_empty(...
e84849f3474fb63ead28cc142c54e55519e54630
atharva07/python-files
/pattern1.py
4,276
4.03125
4
# 1 rows = 6 for num in range(rows): for i in range(num): print(num, end = " ") print(" ") # 2 rows = 5 for row in range(1, rows + 1): for column in range(1, row + 1): print(column, end = " ") print(" ") def greet(first_name, last_name): print(f'hello {first_name} {last_name}') ...
3080b66653c55378cbdbd4052905717d7fbf00c8
atharva07/python-files
/functions3.py
637
3.78125
4
def change_name(mylist): mylist.append(5) print('values inside a function',mylist) return def make_name(mylist1): mylist1.append(4) print('values inside a function',mylist1) return mylist1 = [56,67,34] make_name(mylist1) print('values outside a function', mylist1) mylist = [34,45,667] change_...
c72ba328dd971ee15d12a6339e90073bc5dc5687
atharva07/python-files
/oop6.py
523
3.65625
4
class Carmodel: def __init__(self,brand,model,price,color,speed): self.brand = brand self.model = model self.price = price self.color = color self.speed = speed Carmodel.num_of_cars = 1 def car_name(self): return '{} {}'.format(self.brand,self.model) ...
fa54762f4cc62a289763484c9aad47130607959e
wimarbueno/python3-course
/course/types/string/strings.py
985
4.375
4
'mensaje entre comillas simples' "mensaje entre comillas dobles" ''' a multi line message ''' # concatenation "hello " + "world" # print("hello " + 1)# eror "hello " * 10 # Scaped Characters print('Line1\nLine2\nLine3') # raw print print(r'C:\\somepath\n') #'he's my friend' 'he\'s my friend' # to see all string...
9e9dfeca670f29dad6a3233c0650fd47a0a38f63
sebschneid/adventofcode2020
/01/01.py
955
3.75
4
import itertools import pathlib import sys from typing import List import numpy as np from rich import print def solve(puzzle_input: List[int]): combinations = itertools.combinations(puzzle_input, 2) combination_solution = [ combination for combination in combinations if sum(combination) == 2020 ...
ba43d46c092487072609d948bfd6a7cd404fa2aa
MrComputingHound/python_algorithms
/bubble_sort.py
461
3.78125
4
import datetime array = [6, 5, 3, 1, 8, 7, 2, 4] a = datetime.datetime.now() def bubble_sort(arr): changeling = len(arr)-1 while changeling > 0: for i in range(0, changeling): while arr[i] > arr[i+1]: temp = arr[i] arr[i] = arr[i+1] arr[i+1...
34869bdd6732f3ef246a9807a288eaddeb0850fb
Morpheus158/desktopDatabaseApplication
/frontend.py
3,294
3.5625
4
from tkinter import Listbox, Entry, Button, Label, Tk, Scrollbar, StringVar, END import backend def view_all_command(): entries_field.delete(0, END) for row in backend.view_all(): entries_field.insert(END, row) def search_entry_command(): entries_field.delete(0, END) for row in backend.search_...
36792edeeabddd6686eddd8efdcb444a496604a6
grillzwitu/alx-higher_level_programming
/0x01-python-if_else_loops_functions/8-uppercase.py
227
4.0625
4
#!/usr/bin/python3 def uppercase(str): for c in range(len(str)): char = ord(str[c]) if char >= ord('a') and char <= ord('z'): char -= 32 print("{}".format(chr(char)), end='') print()
df26eb8a8649337367ff0372b27258aff8ef97f2
jpsbur/adventofcode
/2019/06/06.py
1,659
3.546875
4
import unittest class Orbit: def __init__(self, o): self.to = {} self.p = {} self.v = {} for x in o: [a, b] = x.split(')') self.v[a] = True self.v[b] = True if a not in self.to: self.to[a] = [] self.to[a].a...
1a036c00489810b5210e7061b3785e11fa377b2f
jpsbur/adventofcode
/2020/02/main.py
1,536
3.734375
4
import unittest class Password: def verify1(self, c, cmin, cmax, p): """Verify that p contains at least cmin and at most cmax occurrences of c.""" cnt = 0 for cur in p: if cur == c: cnt += 1 return cmin <= cnt <= cmax def verify2(self, c, p1, p2, p)...
ead9833658d9564fe324902d0d23912a2e0ded39
youyanggu/taxi_matcher
/Test.py
2,622
3.703125
4
d = {} #someList = [] class Person: def __init__(self, day, loc, time1, time2, name, course, livgroup, phone, email): self.day = day self.loc = loc self.time1 = time1 self.time2 = time2 self.name = name self.course = course self.livgroup = livgroup se...
74609071d315a5b168040d055e58e39c17c3479a
KingEdwardZhang/python_AI
/functions.py
238
3.65625
4
def fuction1(): print ("my python function") return def printname(s): print("the name is %s" %(s)) name="edward zhang" printname(name) def printname( score, s = 'no name'): print("the is %s and the score is %d" %(name, score))
f60af88f5fb594c691fc7fc949500a64cc96000e
Ybenson/Modulo-de-tratamento-de-dados-em-Python
/ValidateTelefone.py
357
4.125
4
def validate_phone(phone): number = [numbers for numbers in phone] if (len(phone) == 8 or len(phone) == 9) and (number[0] == '7' or number[0] == '8'): return ('9' + phone) elif (len(phone) == 8 or len(phone) == 9) and phone.isnumeric(): return phone else: return None ...
cae91c9dc65c8674e6eec5edfdddc4a7a8fd801d
Ybenson/Modulo-de-tratamento-de-dados-em-Python
/VerificarSeNumero.py
272
3.640625
4
def is_simple_number(value): if not value.strip().replace('-', '').replace('+', '').replace('.', '').isdigit(): return False try: float(value) except ValueError: return False return True print(is_simple_number("1234"))