blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
6c9f5e150500683c0565ea217d4bbb5f65db2df1
tridgley/Rosalind
/problem18.py
6,412
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Trevor Ridgley # BME-205: HMM Problems 16-19 """ Created on Tue Nov 12 20:31:18 2019 @author: tridgley Usage: python3 problem18.py < rosalind_ba10c.txt > result18.txt Decoding Problem Given: A string x, followed by the alphabet Σ from which x was constructed, ...
097e55901ce276a6095a0016a1f07b35dc8f40d2
Patricia888/data-structures-and-algorithms
/sorting_algos/merge_sort/test_merge_sort.py
1,041
3.5
4
import pytest from .merge_sort import merge_sort_the_list def test_merge_sort_the_list_example_sort(): ''' Test that the merge sort function sorts the unsorted example list. ''' example_list = [34, 19, 42, -9, 2018, 0, 2005, 77, 2099] assert merge_sort_the_list(example_list) == [-9, 0, 19, 34, 42, 77, 200...
439eadcc75e1b533b9535a3d4013277318801217
Patricia888/data-structures-and-algorithms
/sorting_algos/insertion_sort/insertion.py
446
3.96875
4
# insertion sort # time: O^2 # for loop goes 'forward' # while loop goes 'backward' def insertion_sort(lst): if len(lst) < 2: return lst for i in range(1, len(lst)): while lst[i] < lst[i - 1]: # this is an inplace swap # give them each a new value (swap) ...
aeb5e4b72d128ac04131053125ed663ad059d5f5
Patricia888/data-structures-and-algorithms
/sorting_algos/merge_sort/merge_sort.py
927
4.5
4
def merge_sort_the_list(lst): ''' Performs a merge sort on a list. Checks the length and doesn't bother sorting if the length is 0 or 1. If more, it finds the middle, breaks the list in to sublists, sorts, puts in to a single list, and then returns the sorted list ''' # don't bother sorting if list is less than...
a56350042eb37db6b829f6a1e39aafaf25f8bca8
Roderich25/mac
/python_cookbook/chapter_02/cookbook_11.py
391
4.25
4
# 2.11 Stripping unwanted characters from strings # whitespace stripping import re s = ' hello world \n' print(s) print(s.strip()) print(s.lstrip()) print(s.rstrip()) # character stripping t = '-----hello=====' print(t.lstrip('-')) print(t.strip('-=')) # another example s = ' hello world \n' print(s.s...
ba59fcb24f1a5eec0832f0f9b33fb2bfeaba82d5
Roderich25/mac
/python-scripts/squares.py
264
3.84375
4
def squares(n): print(n) for i in range(n): # print(i,end='') if i % n == 0 or (i + 1) % n == 0: print("*" * n) else: print("*", " " * (n - 2), "*", sep="") print() for i in range(2, 8): squares(i)
846c1869daf71a4207a0815aba395974d359a583
Roderich25/mac
/python_cookbook/chapter_01/cookbook_19.py
1,006
3.5
4
# 1.19 Transforming and reducing data at the same time import os nums = [1, 2, 3, 4, 5] s = sum(x*x for x in nums) print(s) # another examples files = os.listdir() if any(name.endswith('.py') for name in files): print('There be python!') else: print('Sorry, no python!') s = ('ACME', 50, 123.45) print(',...
0f35e21805d4f092f1f7e056e9e82d0d7e56b3fa
Roderich25/mac
/python_cookbook/chapter_02/cookbook_02.py
1,268
4.09375
4
# 2.2 Matching text at the start or end of a string import os import re from urllib.request import urlopen filename = 'spam.txt' print(filename.endswith('.txt')) print(filename.startswith('file:')) url = 'http://www.python.org' print(url.startswith('http:')) # filenames = os.walk('.') # for root, dirs, files in f...
f83fcd905c084cce98fc955ccf1e309f691d2eec
Roderich25/mac
/python-scripts/points.py
2,073
3.640625
4
#!/usr/bin/env python3 from random import randint import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation from matplotlib import cm def set_direction(): while True: x = randint(-1, 1) y = randint(-1, 1) if x != 0 or y != 0: break return x...
4e2dcb79a87788232e4ea09ff6e3688a6a6f4b8c
Roderich25/mac
/python-scripts/square_root.py
233
4.21875
4
#!/usr/bin/env python3 def square_root(a): x = a//2 while True: print(int(x)*"*", x) y = (x + a/x)/2 print if abs(y-x) < 0.00001: return y x = y print(square_root(125))
206827a35d19594ec8e726982f808e3642f87bef
Roderich25/mac
/python-scripts/decorators_example.py
1,542
3.59375
4
#!/usr/bin/env python3 from functools import wraps def decorator_function(original_function): def wrapper_function(*args, **kwargs): print(f"executed before {original_function.__name__}") return original_function(*args, **kwargs) return wrapper_function class decorator_class(object): def...
4e860d670043bfe8a9913f7b1695aafaa252970c
Roderich25/mac
/python_cookbook/chapter_02/cookbook_13.py
528
4.03125
4
# 2.13 Aligning text strings def printt(s): print("'"+s+"'") text = 'Hello World' printt(text.ljust(20)) printt(text.rjust(20)) printt(text.center(20)) printt(text.rjust(20, '=')) printt(text.center(20, '*')) printt(format(text, '>20')) printt(format(text, '<20')) printt(format(text, '^20')) printt(format(t...
c7eeb1a05df683cfc54342b4e004770e09f3366c
Roderich25/mac
/python_cookbook/chapter_01/cookbook_13.py
853
3.78125
4
# 1.13 Sorting a list of dictionaries by a common key from operator import itemgetter rows = [ {'fname': 'Brian', 'lname': 'Jones', 'uid': 1003}, {'fname': 'David', 'lname': 'Beazley', 'uid': 1002}, {'fname': 'John', 'lname': 'Cleese', 'uid': 1001}, {'fname': 'Big', 'lname': 'Jones', 'uid': 1004} ] ...
e10e5f413c7f9e4b84f8fe20a314a4be4d36a9a9
TheWronskians/capture_the_flag
/turtlebot_ws/src/turtle_pkg/scripts/primeCalc.py
912
4.125
4
from math import * import time def checkingPrime(number): #Recieves number, true if prime. Algorithem reference mentioned in readme file. checkValue = int(sqrt(number))+1 printBool = True #print checkValue for i in range(2, checkValue): if (number%i) == 0: printBool = False break return printBool def c...
1bafff0fd06d63ba88c6535d6163a9d67b47c241
sauravdosi/Ur-AI
/ur/game_board.py
866
3.828125
4
def render_board(state): """ Renders the given state to the console. :param state: The current game state :return: None """ no_tile = "⬚" first_line = [ state.tiles[4].token()[0], state.tiles[3].token()[0], state.tiles[2].token()[0], state.tiles[1].token()[0...
ee6056a89b8429cb7121fdbad13fb8d03da833e8
sharadamurali/speech-proc-misc
/LMS Speech Predictor/LMS.py
1,107
3.890625
4
""" LMS.py - adaptive LMS algorithm for an N-step predictor """ import numpy as np def LMS_train(train_X, train_Y, N_step, mu, epochs): """ in: train_X, train_Y : input and output of the training set N_step : Number of samples considered for prediction mu : Step size for weigh...
480d5b381f8b17cd5a09059d7ddbe0762a3bfc02
kushagragupta209/30-DaysOfCode-March-2021
/answers/kushagra/Day5/question1.py
193
4.03125
4
n=int(input("Enter the no. of terms for FIBONACCI : ")) first=0 second=1 sum=0 count=0 while count<n: print(first,end=",") sum=first+second first=second second=sum count+=1
a34d9ff2db8d9a5b575043ae94b5098e22ad4f05
drliebe/python_crash_course
/ch16/rainfall.py
1,021
3.515625
4
import csv from matplotlib import pyplot as plt from datetime import datetime # Get dates and rainfall from file. filename = 'sitka_weather_2014.csv' with open(filename) as f: reader = csv.reader(f) header_row = next(reader) dates = [] rainfall = [] #for index, column_header in enumerate(heade...
273b92997f588d6aeee2ae42928258d04f0a4187
drliebe/python_crash_course
/ch7/restaurant_seating.py
214
4.28125
4
dinner_party_size = input("How many people are in your dinner group? ") if int(dinner_party_size) > 8: print("I'm sorry, but you will have to wait to be seated.") else: print('Great, we can seat you now.')
20b3792997a403dda5086e24d5914c0157d91ea3
drliebe/python_crash_course
/ch9/restaurant.py
628
4.125
4
class Restaurant(): """A class modeling a simple restaurant.""" def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print('Restaurant name: ' + self.restaurant_name + ...
1a747fc8d6fefd929318c717954420f3e36ce54a
drliebe/python_crash_course
/ch9/ice_cream_stand.py
888
4.28125
4
class Restaurant(): """A class modeling a simple restaurant.""" def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print('Restaurant name: ' + self.restaurant_name + ...
85ec7783a8eddc8eaa560628ac00c472b04d6cf3
drliebe/python_crash_course
/ch3/greetings.py
313
3.921875
4
names = ['Josh', 'Frank', 'Brad', 'Jonathan'] print("Hello " + names[0] + "! I hope you are having a good day.") print("Hello " + names[1] + "! I hope you are having a good day.") print("Hello " + names[2] + "! I hope you are having a good day.") print("Hello " + names[3] + "! I hope you are having a good day.")
42ac8b60872642760c139be678932b2c11f5dffe
drliebe/python_crash_course
/ch9/admin.py
591
3.9375
4
"""A Module that defines a simple User class and Admin child class""" from user import User class Admin(User): """A simple Admin class""" def __init__(self, first_name, last_name, username, employee, privileges=''): super().__init__(first_name, last_name, username, employee) ...
7535164da5a4d12d8b72049fb7cdc2bdc6c58975
lolphish/codingqs
/graph.py
3,745
4
4
from collections import defaultdict,deque from edge import edge def addEdge(graph, from_node:int, to_node:int, cost:int): graph[from_node].append(edge( from_node, to_node, cost)) # Topological Sorting #Use a stack. For each vertices, recursively call function to visit all neighbors and add to stack when we r...
c3dee5df2e445a332a6806684f0e296e93124a34
genjix/random
/euler/pandigprimer.py
344
3.53125
4
import primality, itertools def ispand(n): nums = list(range(1,int(max(str(n)))+1)) while len(nums) > 0: try: [nums.remove(int(x)) for x in str(n)] except ValueError: return False print(n) return True primes = primality.primes(10000000) [ispand(primes[n]) for n...
8e48c9ec760049fde428322702f7a7cc8c9562e2
genjix/random
/euler/leapyear.py
1,303
3.921875
4
def monthdays(month, year): if month in (4, 6, 9, 11): return 30 elif month == 2: if year%4 == 0 and year%100 != 0 or year%400 == 0: #if year%4 == 0 and year != 1900: return 29 return 28 return 31 def incdate(date): wd, day, month, year = date wd += 1 ...
b7eca687ac48916e62ad4ae6b931832dc8dfdcc3
genjix/random
/euler/trianglewords.py
497
3.578125
4
import itertools f = open("words.txt") words = f.read().replace("\"", "").lower().split(",") # the longest word in the list is 14 chars # 364 is the word value of "z"*14 letval = lambda c: ord(c) - ord("a") + 1 wordval = lambda w: letval(w[0]) + (len(w) > 1 and wordval(w[1:]) or 0) trin = lambda n: n*(n+1)//2 firtris =...
d4050455b9cdf12656732b1645c506d7cf94e5d6
ISPM-Benguela/test
/Decorators.py
337
3.9375
4
#!bin/usr/python class Uppercase(object): def __init__(self, f): print("Ola mundo, eu sou programador __init__") self.f = f def __call__(self, *args): self.f(args[0].upper()) @Uppercase def nome(nome): print("Nome: %s" % nome) nome("Fred") nome = input("Digite o seu nome aqui: ...
42b2a2848527d4f024d2bdc5ff385b2ce9753dc4
aurafrost/Python
/DivisorCheck.py
518
4.21875
4
""" This program takes an int from the user then returns all divisors of that int from lowest to highest. """ num = int(input("Enter an integer: ")) divisorList = [] for x in range(1,num+1): if num%x==0: divisorList.append(x) #adds x to divisorList if it has no remainder when divided into num print("The div...
805061005e800ce0562e6ea8002d518ad421c163
aurafrost/Python
/BankAccount.py
807
3.875
4
class BankAccount(object): balance=0 def __init__(self,name): self.name=name def __repr__(self): return "Account owner: %s Balance: %.2f"%(self.name,self.balance) def show_balance(self): return "Balance: %.2f"%(self.balance) def deposit(self,amount): if(amount<=0): print("Invalid amount"...
48c9121eb096ac13947ca20444af9ece202582aa
hohaidang/Python_Basic2Advance
/MatplitlibLearn/src/main.py
485
3.546875
4
import cv2 from matplotlib import pyplot as plt image = cv2.imread("frame536.jpg") gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.imshow("Image", image) cv2.imshow("Gray", gray) cv2.waitKey(0) # construct a grayscale histogram hist = cv2.calcHist([gray], [0], None, [256], [0, 256]) # plot the histogram plt.figur...
b12b81aa4cc4b703a4e19bdc882aa03e47de89b0
hohaidang/Python_Basic2Advance
/CheckboxTkInter/src/main.py
1,438
3.65625
4
from tkinter import * # root = Tk() # frame = Frame(root) # frame.pack() # # buttonframe = Frame(root) # buttonframe.pack(side = BOTTOM) # # redbutton = Button(frame, text="red", fg="red") # redbutton.pack(side = LEFT) # # blackbutton = Button(buttonframe, text="Black", fg='black') # blackbutton.pack(side = BOTTOM...
19de2b7cbf63ce1d13fc2de2e375e60a724f20d3
hohaidang/Python_Basic2Advance
/GasStation/main.py
440
3.609375
4
def gasStation(gas, cost): cur_gas = 0 total_gas = 0 start_idx = 0 for i in range(0, len(gas)): cur_gas += gas[i] - cost[i] total_gas += gas[i] - cost[i] if cur_gas < 0: # cannot start from that gas start_idx += 1; cur_gas = 0; return start...
b41d7852e02effc78876df9a9279348d3c93afe0
dario-99/python
/pong/Ball_pong.py
1,994
3.5
4
import random import math import pygame class Ball: def __init__ (self, color, x, y, radius, vel): self.color = color self.x = x self.y = y if random.random() <= 0.5: self.angle = random.uniform(math.pi - math.pi/4, math.pi + math.pi/4) else: ...
3f40d1b6766ac8f57628a68e3cb84645536303d0
jenkinsc11/Partial-Seq-Search
/locate_sequence.py
1,641
3.796875
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 29 11:02:01 2018 @author: jenkinscc """ ###Opens the fasta file you want to explore entry by entry def read_FASTA_strings(fasta): with open(fasta) as file: return file.read().split('>')[1:] ###Matches the accession number to fasta and entry and sep...
edaaa9d51915039e033c950b030fbc08a9ef4084
fharookshaik/Mobius_GUI
/mobius.py
2,932
4.28125
4
''' Möbius function: For any positive integer n,n, define μ(n)μ(n) as the sum of the primitive n^\text{th}nth roots of unity. It has values in \{-1, 0, 1\}{−1,0,1} depending on the factorization of nn into prime factors: a) \mu(n) = 1μ(n)=1 if nn is a square-free positive integer with an even number of prime facto...
951cdb19222b2fe99ca6f1816c4650e3285abca5
whatnowbrowncow/projects
/python.py
7,114
4.125
4
def play(): print "Hello", name print "Would you like to play a game? Yes or No?" answer = raw_input().lower() if answer == "yes": print "ok then, let's get started" game_1() elif answer == "no": are_you_sure() else: print "You didn't type yes or no!" play() def are_you_sure(): print...
4c9bbafc28acf83cd0463b5e11e2b77ece808ad5
notantony/ITMO_FS
/wrappers/RandowWrapper.py
1,511
3.6875
4
import random as rnd import numpy as np from filters import RandomFilter class RandomWrapper: """ Creates random feature wrapper Parameters ---------- estimator: object A supervised learning estimator with a fit method that provides information about feature importan...
8ae534286aaa4453008d416e0e642028fbf11852
ahiguti/pxc
/pxc/tests/skip_137_python_timing/misc/tt.py
204
3.6875
4
#!/usr/bin/env python def fib(x): if x < 2: return x else: return fib(x - 2) + fib(x - 1) def test1(v, num): sum = 0 for i in range(num): sum += fib(v) return sum test1(30, 100)
86ae948be11bd8decc10050c7cea5fb41397e9d6
ms0695861/age
/age.py
657
4.1875
4
#age judement driving = input('Have you ever driven a car? (Y/N): ') if driving != 'Y' and driving != 'N': print('Please enter Y or N! Thanks!') raise SystemExit age = input('How old are you?: ') age = int(age) if driving == 'Y': if age >= 18: print('PASS!!') else: print('It is illegal') elif driving == 'N': ...
96c9cbeed37c53004910ac38ad5e41a393b55835
NyokoKei/Coursera_Python_week1
/18.py
128
3.53125
4
n = int(input()) i = 2 t = True while t: if not n % i: print(i) t = False else: i += 1
30decb2dc01b1f0772ac9c2847fc65f29439a62f
NyokoKei/Coursera_Python_week1
/6.py
83
3.59375
4
x = int(input()) y = int(input()) print('YES' if not y % (y - x + 1) else 'NO')
cfbe93931caa6d5e688ffb1f7d713cd2b15d5a8f
Nishchhal15unaffected/PythonPractice
/lacture3.py
189
3.953125
4
h=int(input()) # if(h>10): # print("the number is greater than 10") # elif(h<10): # print("the number is less than 10") # else: # print("equal") while(h>10): print("hello nish") h=h-1
7d0d3288235042da14844e375c9b5b438cfebbe7
490089604/python_learn
/基本输入输出及基本数据类型.py
1,236
3.78125
4
#!/usr/bin/env python3 #上面是为了在linux和MAC环境下以exe形式运行 #coding=utf-8 #输出中文,不写会报错 print('hello, world,我教吴长发') print('The quick brown fox', 'jumps over', 'the lazy dog') """ 输入输出 name = input() print('hello,', name) """ print('I\'m learning\nPython.') print(r'\\\t\\')#默认不转义r'' print('''line1 line2 line3''')#多行显示 print( 5 > 3...
05ac35b5adf284b21205fbac7552cbb114d94204
490089604/python_learn
/面向对象高级编程.py
5,081
3.765625
4
#!/usr/bin/env python3 # 上面是为了在linux和MAC环境下以exe形式运行 # coding=utf-8 # 输出中文,不写会报错 class student(object): #为了达到限制的目的,Python允许在定义class的时候,定义一个特殊的__slots__变量,来限制该class实例能添加的属性: #使用__slots__要注意,__slots__定义的属性仅对当前类实例起作用,对继承的子类是不起作用的: #除非在子类中也定义__slots__,这样,子类实例允许定义的属性就是自身的__slots__加上父类的__slots__。 __slots__ = ('name', 'ag...
b4322d300efcec782b2f862f988488803b1bdd65
jpozin/Math-Projects
/EvolutionOfText.py
1,609
4.0625
4
from random import choice from string import printable from sys import argv characters = list(printable) def UnboundedBogoGenerateText(desiredstr, showstrings=False): """Unbounded bogo text generation procedure Randomly generate a string of characters until it matches the input characters At each iteration, char...
cb98c118df80bbe3ef89900bc63d6e38d01514c8
jpozin/Math-Projects
/TriangleStuff.py
652
4.375
4
import sys from math import sqrt class TriangleException(Exception): pass def isValidTriangle(a, b, c): return (a + b > c) and (a + c > b) and (b + c > a) def Perimeter(a, b, c): return a + b + c def Area(a, b, c): s = Perimeter(a, b, c) / 2 return sqrt(s*(s-a)*(s-b)*(s-c)) if __name__ == '__m...
f22ad4dcc882dd0b2fe4d302c91ef292924c0dd4
esther-j/Doodle-Jump
/doodleJump.py
16,601
3.65625
4
import random from tkinter import * # Platform class class Platforms(object): speedY = 0 # Initialize values of class def __init__(self, cx, cy): self.width = 100 self.height = 10 self.cx = cx self.cy = cy self.color = "orange" # Draw individual platfo...
8ede766e58946782f1d751b995c816a48b2b5f5b
ysc3839/vcmp-python-plugin
/converters/name_convert.py
161
3.6875
4
import re def convert_name(string): return re.sub(r'([a-z])([A-Z])', r'\1_\2', string).lower() if __name__ == '__main__': print(convert_name(input()))
bcd81db03b5dc25bd76f7969f471ffba7fdbfbf9
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 3/Task3.py
620
3.515625
4
# Created by Moontasir Abtahee at 6/4/2021 class Wadiya(): def __init__(self): self.name = 'Aladeen' self.designation = 'President Prime Minister Admiral General' self.num_of_wife = 100 self.dictator = True def detail(self): print(f"Name of President: {self.name}\nDesigna...
907bc6613731a110a451fc19caae9ac35a8b7a86
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 2/Task7.py
413
4.34375
4
def Palindrome(String): word = "" for i in String: if i != " ": word += i oppositeWord = "" for i in range(len(String)-1,-1,-1): if String[i] != " ": oppositeWord += String[i] # # print(word) # print(oppositeWord) # if word == oppositeWord: ...
0b319bc4da6669340302f5d2f2ede1105f48369e
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 2/Task8.py
214
3.671875
4
def YearConverter(time): year= time//365 month= (time % 365)//30 day = (time % 365)%12 return str(year) + " year, " + str(month) + " month and " + str(day) + " day." print(YearConverter(4000))
01af7c4f05225a1b1d7e9552bbd511b03bb8843b
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 7/Task1.py
678
3.734375
4
# Created by Moontasir Abtahee at 6/9/2021 class Student: def __init__(self, name='Just a student', dept='nothing'): self.__name = name self.__department = dept def set_department(self, dept): self.__department = dept def get_name(self): return self.__name def set_name...
88fa321fa55d58ad43b8f58b560c120d0b63c9e2
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 1/String/Task2.py
134
3.9375
4
#Task2 String = input() if String.isalpha(): print("WORD") elif String.isnumeric(): print("NUMBER") else: print("MIXED")
7612a855b07308ae583ec7f5e7bad6748a4e1979
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 1/Dictionary _ Tuple/Task3.py
343
3.59375
4
inputDict=dict() outputDict = dict() stringList = input().split(",") for i in stringList: temp = i.split(":") inputDict[temp[0]] = temp[1] for key , value in inputDict.items(): if value not in outputDict.keys(): outputDict[value] = [key] else: outputDict[value] = outputDict[value] + [...
15d8ac7ab1048fe3121c401ffd852f1db35358cf
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 7/Task3.py
1,065
3.953125
4
# Created by Moontasir Abtahee at 6/9/2021 class Tournament: def __init__(self, name='Default'): self.__name = name def set_name(self, name): self.__name = name def get_name(self): return self.__name # write your code here class Cricket_Tournament(Tournament): def __init__(...
736ea42157a873d9f5ec7486fb30c33ee8623482
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 6/Task7.py
1,047
3.796875
4
# Created by Moontasir Abtahee at 6/8/2021 class Cat(): Number_of_cats = 0 def __init__(self,color = "White" ,do = "sitting" ): self.color = color self.do = do Cat.Number_of_cats+=1 @classmethod def no_parameter(cls): return cls() @classmethod def first_parameter(...
d39498399452d5ba74004a26c83f48b02aebfe93
Divine11/Project-Euler
/Largest_palindrome_number.py
503
3.984375
4
#A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. #Find the largest palindrome made from the product of two 3-digit numbers. def isPalindrome(lis): n = len(lis) for i in range(0,n//2): if lis[i]!=lis[n-i-1]: ...
2055665bc50fa81f50a5b5c5cac8930ad49c283e
arverma/100DaysOfCode
/Day_58/tictac.py
3,508
3.90625
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 1 17:50:13 2019 @author: amanranjan TicTac: Dumb System vs You 3x3 board is initialised with -1. User: 0/O System: 1/X """ import numpy as np import random as r class tictac_board(): def __init__(self): self._board = [[-1,-1,-1],[-1,-1,-...
e5c308b6e5eff3d310ab846de7aaac519979c02c
arverma/100DaysOfCode
/Day_40/queue_array_implementation.py
1,069
3.890625
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 29 12:44:00 2018 @author: amanranjan """ class queue(): def __init__(self, a): self.a = a self.size = 0 def isEmpty(self): if(self.size == 0): return True else: return False def isFull(...
326209738626d06845ea0eb6acd202bf99f86030
arverma/100DaysOfCode
/Day_64/rotate_90.py
871
3.625
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 6 16:00:12 2019 @author: amanranjan """ import numpy as np def rotate(a): if(len(a) != 1): l = 0 r = len(a[0]) -1 t = 0 b = len(a) -1 print(l, r, t, b) while(r > l and b > t): for i in range...
2f93f6ae9a9331e2ca5f5e18a4b42e5d1c54bb60
arverma/100DaysOfCode
/Day_60/Maximum Consecutive Gap.py
372
3.984375
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 2 23:30:52 2019 @author: amanranjan """ def maxgap(a): a.sort() max_diff = 0 diff = 0 if(len(a) < 2): return 0 for i in range(len(a)-1): diff = a[i+1] - a[i] if(diff > max_diff): max_diff = diff ...
6f67ff91362b55da56133306785babc73aa20f90
arverma/100DaysOfCode
/Day_44/String_permutation.py
570
3.78125
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 2 11:59:51 2019 @author: amanranjan """ def toString(a): return ["".join(a)] def permute(a, l, j): if(l==j): # count += 1 print(toString(a), end = " ") # print(x, count) else: for i in range(l, j+1): ...
8916b1a9252b9b5f493b61b21eaf60713539ce18
d2Anubis/donkeybot
/lib/bot/fetcher/interface.py
1,076
3.5625
4
# general python from abc import ABCMeta, abstractmethod class IFetcher(metaclass=ABCMeta): """ The Fetcher Interface <!> Note: Once we use the Fetcher to .fetch() the data the Fetcher returns corresponding DataFrame(s) and knows how to .save() and .load() accordingly. """ @abstractmetho...
3678302f6ea5a60eee7a94cbda6c2fe5eef24a39
emilyhuangml/Lab4-APCS
/Largest Prime Factor.py
1,023
3.6875
4
#Largest Prime Factor # factorList = [] # list = [] # for i in range (1, 320): # if 320 % i == 0: # factorList.append(i) # for factor in factorList: # for e in range (1, factor): # if factor % e != 0: # list.append(e) # print(len(list)) # for factor ...
399bc88889f0e822d8054c1fee9b6312857c65c2
itbc-bin/1920-owe1a-afvinkopdracht2-S-K-Tiger
/Afvinkopdracht 2#2.py
242
3.65625
4
# 2 sales prediction sales = float(input(str("What is the projected amount of total sales?\n"))) if isinstance(sales, (int, float)) != True: print("Invalid input") exit() profit = 0.23 * sales print("expected profit = " + str(profit))
2f5fad7590b33778b2b9403aa7559dd3dff5cf26
axellarsstenson/CSCI-1133
/bSearch.py
740
3.703125
4
def bsearch(searchTerm, searchList, low = 0, high = None): if high == None and low == 0: low = 0 high = len(searchList) - 1 while high >= low: position = (high + low) // 2 if searchTerm > searchList[position]: low = position + 1 bsearch(searchTer...
d405539afdad7aad5ba77e47f80b573cd2784dc1
FKistic/Python-Personal
/EXT File Copier/New folder/dir.py
366
3.640625
4
import os basepath=input("Enter the path from where files to be copied: ") basepath=basepath.replace('\\',"/") no="" def full_dir(name): a=os.path.join(name) a=str(a) print(a) for entry in a: if os.path.isdir(os.path.join(a, entry)): str(entry) print(entry) ...
ac328d6b8469108bc58fb7e308a1bb5898e1a0c8
FKistic/Python-Personal
/Exersize py program/test.py
491
3.734375
4
fruit_name1 = input("Please Enter a fruit 1 name: ") fruit_name2 = input("Please Enter a fruit 2 name: ") fruit_name3 = input("Please Enter a fruit 3 name: ") furit_name4 = input("Please Enter a fruit 4 name: ") fruit_name5 = input("Please Enter a fruit 5 name: ") fruit_name6 = input("Please Enter a fruit 6 name: ...
d6218b40c283b8ec5eda0c7f77e63e650a4eac75
FKistic/Python-Personal
/calci project/calci v5.py
2,422
4.21875
4
#simple calcultor using python import time time.sleep(1) print('''|||||||| //\\\ || |||||||| || || || //\\\ |||||||||| |||||||| ||||||\\''') time.sleep(1) print('''|| // \\\ || || || || || // \\\ || || || || ||''') time.sleep(1) print('''|| //==...
69236d50be6e8fdb718a02942f37e8755ff10100
HomelikeBrick42/Chess
/chess.py
8,812
3.578125
4
import terminal_util def get_piece_color(piece: chr) -> str: if piece.upper() == piece: return terminal_util.Colors.BRIGHT_RED + terminal_util.Colors.BOLD else: return terminal_util.Colors.BRIGHT_MAGENTA + terminal_util.Colors.BOLD def draw_board(board: list[list[chr]], flip: bool) -> None: ...
4744d355b2da7a90965de11a691ec736a8c0296f
lucas-silvs/AC-04-basica
/ex 1259.py
374
3.828125
4
# URI Online Judge | 1259 lista_impar = [] lista_par = [] # repete quantas vezes entrar em quantidade qtde = int(input()) for i in range(qtde): n = int(input()) if n % 2 == 0 and n>0: lista_par.append(n) elif n % 2 != 0 and n>0: lista_impar.append(n) lista_impar.sort(reverse=True) l...
d4eea3d68b1f9857652fb0dda77989ecb026297d
ashokballolli/pythonparadigm
/leetcode/longest_substring.py
1,135
3.703125
4
# https://leetcode.com/problems/longest-substring-without-repeating-characters/solution/188022 # Longest Substring Without Repeating Characters # Input: s = "abcabcbb" # Output: 3 class Solution: def lengthOfLongestSubstring01(self, s): dicts = {} maxlength = start = 0 for i,value in enumer...
e2a76f31abb28a6711e40d3273fd9f8c838b5c2b
ashokballolli/pythonparadigm
/basics/ClassesNObjects.py
4,276
4.59375
5
class Car: pass print("-------------------- Car ----------------------") ford = Car() # () is necessary to create the object and ford is the instance/object of the class Car honda = Car() ford.speed = 200 # we can assign to attributes on the fly honda.speed = 220 ford.color = 'red' honda.color = 'blue' print...
3a6b2349aa66ec88f7d0dec91b05677db3f9cc90
ashokballolli/pythonparadigm
/dataclasses_ex/DataClass01.py
937
3.671875
4
class DataClass01ProbSt: def __init__(self, name, age, salary): self.name = name self.age = age self.salary = salary # def __repr__(self): # return "name: {}, age: {}, salary: {}".format(self.name, self.age, self.salary) d11 = DataClass01ProbSt('Samrat', 30, 3243) d12 = DataC...
52756187aec18fc94ecc77d26594ab3d50a502a5
kellylougheed/raspberry-pi
/bubble_sort.py
956
4.375
4
#!/usr/bin/env python # This program sorts a list of comma-separated integers using bubble sort # Swaps two numbers in a list given their indices def swap(l, index1, index2): temp = l[index2] l[index2] = l[index1] l[index1] = temp numbers = input("Enter a list of comma-separated integers: ") lst = numbers.split...
9283e3cd58d64d26b2503358d2e4cd53dbb1f0df
akstorg/stepik
/1_12_3.py
215
3.9375
4
a = int(input()) b = int(input()) op = str(input()) if op == '+': print(a+b) elif op == '-': print(a-b) elif op == '/': if b == 0: print('Деление на 0!') else: print(a/b)
473d78088b698ab07eca912a5ef5bf23a76d32dc
dibaggioj/bioinformatics-rosalind
/textbook/src/ba1d.py
2,138
4.3125
4
#!/usr/bin/env # encoding: utf-8 """ Created by John DiBaggio on 2018-07-28 Find All Occurrences of a Pattern in a String In this problem, we ask a simple question: how many times can one string occur as a substring of another? Recall from “Find the Most Frequent Words in a String” that different occurrences of a sub...
1d371867f303776575ad8c495eef9c428c1b032d
dibaggioj/bioinformatics-rosalind
/textbook/src/ba1f.py
3,124
4.0625
4
#!/usr/bin/env # encoding: utf-8 """ Created by John DiBaggio on 2018-08-07 Find a Position in a Genome Minimizing the Skew Define the skew of a DNA string Genome, denoted Skew(Genome), as the difference between the total number of occurrences of 'G' and 'C' in Genome. Let Prefixi (Genome) denote the prefix (i.e., in...
47f6f9ad980659dc5b1408cb50f588adda37c9cf
FierySama/vspython
/Module7ComplexDecisions/m7cont.py
1,121
4.21875
4
team = input('Enter your favorite hockey team: ').upper() sport = input('Enter your favorite sport: ').upper() sportIsHockey = False if sport == 'HOCKEY': sportIsHockey = True teamIsCorrect = False if team == 'SENATORS' or team == 'LEAFS': teamIsCorrect = True if sportIsHockey and teamIsCorrect: print('g...
b2b59660795297211f00f7b98497fb289583e46a
FierySama/vspython
/Module3StringVariables/Module3StringVariables/Module3StringVariables.py
1,330
4.5625
5
#String variables, and asking users to input a value print("What is your name? ") # This allows for the next line to be user input name = input("") country = input("What country do you live in? ") country = country.upper() print(country) # input is command to ask user to enter info!! # name is actually the name of...
525574f48d9e6a18c57c3ed79fcf7465d12a7fb7
badshasha/learn-about-the-machine-
/eps_greedy.py
1,089
3.515625
4
import numpy as np class machine: def __init__(self, true_mean): self.true_mean = true_mean self.experiment_mean = 0 self.representate = 0 def work(self): return np.random.randn() + self.true_mean def update(self, reward): self.representate += 1 ...
826d4a041f9febb62518f4a60ddd69bd3da3858c
fbamopoulos/txt_consolidation
/consolidate_files.py
920
3.8125
4
import glob from os import path def consolidate_files(file_extension, directory_path): """ :param file_extension: File extension of file to be consolidated :param directory_path: Directory to look for files to consolidate :return: 0 if no errors, -1 if error """ my_file_paths = glob.glob(path...
fde27fc6f4f64d6d5170931b0d79dee13cb3eca9
AkiraMisawa/sicp_in_python
/chap2/c2_03_width_height.py
507
3.625
4
import utility def make_rectangle(width, height): return utility.cons(width, height) def width_rectangle(r): return utility.car(r) def length_rectangle(r): return utility.cdr(r) def perimeter_rectangle(r): return 2 * (width_rectangle(r) + length_rectangle(r)) def area_rectangle(r): return ...
99690b46a36542a1542e1337e4eca1a2e01f39f4
AkiraMisawa/sicp_in_python
/chap1/1-23.py
345
3.9375
4
def next(n): if n==2: return 3 else: return n+2 def smallest_divisor_impl(n): return find_divisor_impl(n,2) def find_divisor_impl(n,test_divisor): if test_divisor**2>n: return n elif n % test_divisor == 0: return test_divisor else: return find_divisor_im...
0018fdd142682eb1602a817f52c9e86bde4d0d10
AkiraMisawa/sicp_in_python
/chap1/1-27.py
221
3.5
4
def test_congruent(n): for a in range(1,n): print_congruent(a,n) def print_congruent(a,n): print(a,"^",n,"-",a,"=",congruent(a,n),"mod",n) def congruent(a,n): return (a**n-a)%n test_congruent(561)
be5020cf5ac6ce70571e3824e7af97c5a495171f
AkiraMisawa/sicp_in_python
/chap2/c2_18.py
842
3.5625
4
import utility import unittest def reverse(lst): if utility.is_null(lst): return None elif utility.length(lst) == 1: return lst else: x = utility.car(lst) xs = utility.cdr(lst) return utility.append(reverse(xs), utility.list(x)) class UnitTestOfAboveFunctions(unit...
f183d74d68e3d648d41d2b0bb77393c666ab126b
AkiraMisawa/sicp_in_python
/chap1/c1_30.py
614
3.765625
4
import unittest def sumiter(term, a, next, b): def iter(a, result): if a > b: return result else: return iter(next(a), result + term(a)) return iter(a, 0) def next(x): return x + 1 def square(x): return x * x class UnitTest(unittest.TestCase): def test...
578a0575e54c67d4be6780cf37867900166d4537
AkiraMisawa/sicp_in_python
/chap1/c1_3_3.py
1,907
3.59375
4
# coding=utf-8 """1.3.3""" def average(x, y): """ :type x: float :type y: float :rtype: float """ return (x + y) / 2 def is_close_enough(x, y, epsilon=1e-3): """ :type x: float :type y: float :type epsilon: float :rtype: bool """ return abs(x - y) < epsilon def ...
2b55880e8a21e1123cf44f32cdb64dbfe63a2d27
TommasoBendinelli/ObjectDatasetTools
/utils/ply.py
1,974
3.71875
4
import numpy as np class Ply: """ The Ply class provides the ability to write a point cloud represented by two arrays: an array of points (num points, 3), and an array of colors (num points, 3) to a PLY file. """ def __init__(self, points, colors): """ points -- The matrix...
a0997477f78ee975ec600e17b8c860e2d9ebec53
livexia/algorithm
/algorithms-princeton/UnionFind/quickunion.py
503
3.5625
4
# encoding = utf-8 # Quick Union class QU: id = [] count = 0 def __init__(self, n): self.id = list(range(n)) self.count = n def root(self, p): while p != self.id[p]: p = self.id[p] return p def union(self, p, q): if self.connected(p,q): ...
e05a2b45f898cf31df4c443b7807c16d2df20774
livexia/algorithm
/blind_75_leetcode/python/s0003_longest_substring_without_repeating_characters.py
993
3.59375
4
import unittest class Solution: def lengthOfLongestSubstring(self, s: str) -> int: left = result = 0 n = len(s) for (right, c) in enumerate(s): if left + result >= n: return result if c in s[left:right]: result = max(result, right - l...
9eb123f350704bb28d40d73930c650d073cbc1f8
livexia/algorithm
/blind_75_leetcode/python/s0235_lowest_common_ancestor_of_a_binary_search_tree.py
1,948
3.859375
4
import unittest from .s0104_maximum_depth_of_binary_tree import ( TreeNode, create_tree_from_list, search_val, ) class Solution: def lowestCommonAncestor( self, root: "TreeNode", p: "TreeNode", q: "TreeNode" ) -> "TreeNode": if root.val < p.val and root.val < q.val: re...
5c72799677153e8a6c367245eb57c2271cd5867e
edmontdants/cipher_solver
/cipher_solver/cli.py
528
3.578125
4
#!/usr/bin/env python # encoding: utf-8 import os import sys from cipher_solver.simple import SimpleSolver def main(): script_name = os.path.basename(sys.argv[0]) if len(sys.argv) != 2: sys.exit(f"Incorrect arguments. Usage: {script_name} <path_to_ciphertext_file>") input_file = sys.argv[1] ...
a290b0f8fceb02aeaf0704160bb27319c00b1771
omrikiei/mina-payout-script
/Currency.py
4,620
3.71875
4
# Credit: https://github.com/MinaProtocol/coda-python-client from enum import Enum class CurrencyFormat(Enum): """An Enum representing different formats of Currency in coda. Constants: WHOLE - represents whole coda (1 whole coda == 10^9 nanocodas) NANO - represents the atomic unit of coda """ ...
8ad939a380fc86dc6a129384390f212b7788fb61
Placius/fit_progress
/account_create.py
9,218
3.765625
4
# fuction for creating new account for user # import modules import datetime, os, time, sys class NewUser: def __init__(self): self.user_id = 1 self.name = "name" self.year_of_birth = "year" self.month_of_birth = "month" self.day_of_birth = "day" self.age = "age" ...
28753f210e50a5e1c51df4f399241998ec8ec7d8
sudhirpundir1/pyhon-training
/IfCondition-Copy1.py
408
4.03125
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: # In[1]: #if Condition -- test the conditions defined cars=['audi','bmw','honda','toyota'] #If cars= bmw then it should be in UPCASE letters, else other values turned to title case. for i in cars: if i == 'bmw': print(i.upper()) else: pri...
6c586ce71b22610d0ddbd92f3065c0c2ccd91fcc
JillT-521/IntroToProg-Python
/Employee.py
331
3.6875
4
class Employee(object): def __init__(self, ID, firstName, lastName): self.ID = ID self.firstName = firstName self.lastName = lastName def __str__(self): string = "Employee ID: " + self.ID + "\nFirst Name: " + self.firstName + "\nLast Name: " + self.lastName re...
4172ae64c4f60144abb25a08f47b204c6aebdb1e
Shourov1/small_games
/Python small projects/Roll_the_dice.py
381
3.921875
4
import random def roll (sides = 6): num_rolled = random.randint(1, sides) return num_rolled def main(): sides = 6 rolling = True while rolling: roll_again = input("Ready to roll? Enter=roll. Q=quit. ") if roll_again.lower() != "q": num_rolled = roll (sides) print("You roller a ", num_rolled) else: ...
7bcb3048baaf06d6138ff6426d02df9f3412d772
gabibguedes/MetodosNumericos
/nota.py
397
3.578125
4
def media_prova(p1, p2): return (p1 + p2)/2 def media_lista(done): return (done*10)/7 def media(p1, p2, lists_done): return 0.7 * media_prova(p1,p2) + 0.3 * media_lista(lists_done) if __name__ == "__main__": p1 = float(input("Nota P1: ")) p2 = float(input("Nota P2: ")) lists = float(input("...