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
a954e8cb66d437a263a338887fd7a37ab035d1ab
NgangaMaryanne/Bootcamp-14
/Day3/findMaxAndMin.py
264
3.96875
4
def find_max_min(numbers): my_max_and_min=[] max_num= max(numbers) min_num = min(numbers) if max_num==min_num: my_max_and_min.append(len(numbers)) else: my_max_and_min.append(min_num) my_max_and_min.append(max_num) return my_max_and_min
43b8107a49178ce617fa90e55b0b3d612be117bb
cornielleandres/Intro-Python
/src/day-1-toy/fileio.py
403
4.1875
4
# Use open to open file "foo.txt" for reading foo = open('foo.txt') # Print all the lines in the file for line in foo: print(line) # Close the file foo.close() # Use open to open file "bar.txt" for writing bar = open('bar.txt', 'w') # Use the write() method to write three lines to the file lines = ['first line\n', ...
d85abf5597c1e69d1336a9c0f04f0b9b98113616
Rogan003/Python-vezbe
/koronastats3.py
722
3.53125
4
import matplotlib.pyplot as plt import numpy as np from random import randint as rand plt.ion() rez = [0] pom = 0 lista = [pom] zbir = 0 for i in range(300): plt.xlabel("Vreme") plt.ylabel("Zarazeni") plt.title("Odnos zarazenih vremenom") plt.plot(lista,rez, color = 'red') plt.fill_between(lista,...
41a247d697163fb780bc40457eb1ab4c159ef8a2
tahniyat-nisar/while_loop-imp
/print even if you enter even or odd if you enter odd.py
98
4
4
n=int(input("enter a number:")) while n>=2: print(n) n=n-2 if n>=1: print(n) n=n-2
cf10d61f987d0a2c444a3539ed2c28aa13e310b9
tahniyat-nisar/while_loop-imp
/factors of a number.py
95
3.78125
4
n=int(input("enter a number:")) i=1 while i<=n: if (n%i)==0: print(i) i=i+1
d52f4b8f2ac825caab58afa7844a76a5ac6d8c9d
tahniyat-nisar/while_loop-imp
/sum of squares of 1 to n.py
96
3.890625
4
n=int(input("enter a number:")) i=1 sum=0 while i<=n: sum=sum+(i*i) print(sum) i=i+1
9a0dfe2910fd4fcfb765f61177b32e88c8d074dc
tahniyat-nisar/while_loop-imp
/print even numbers from 1 to n.py
81
3.890625
4
n=int(input("enter a number")) i=2 while n>=i: print(i) i=i+2
e49a3ef25dc5b838ba124a5451ed7a67343189a0
zafar26/practise
/vowels.py
145
3.859375
4
count = 0 string = "zafar" for i in string: if i == 'a' or i == "e" or i == "i" or i == "o" or i =="u": count += 1 return count
001831e92678bd58e380e59a1ca0d7f3e511f677
zafar26/practise
/pattern.py
2,819
3.609375
4
mat=[[0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,'Q',0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0]] moves=[]#//array for successfull moves #//update xQPos & yQPos if you change 'Q' in mat[][] xQPos=5-1#...
a6f179811f713250cfcc75866b55a05b0e1c0408
tdatu/meeting-noter
/speech_recog.py
710
3.5
4
import time import speech_recognition as sr from datetime import datetime r = sr.Recognizer() fs = open("converted_audio.txt","w+") with sr.Microphone() as source: print("Audio conversion now:") while True: audio = r.listen(source) try: text = r.recognize_google(audio) n = datetime.now() fs.write('{...
4d959f1ffd4888146f77df728ddff94022ecc853
theq629/tcod-ansi-terminal
/example/_sampling.py
568
3.640625
4
""" Tracking min/max/mean of a sampled sequence. """ class Sampler: def __init__(self) -> None: self.num = 0.0 self.mean = 0.0 self.maximum = 0.0 self.minimum = 0.0 def sample(self, value: float) -> None: if self.num == 0: self.maximum = value se...
b9a174d5d1a8c570d56daf94cebf0b1c43abf05d
SeanRan/Git2021
/note.py
578
3.859375
4
'''#[expression for target in interable] foo = [1, 2, 3, 4, 5] #将列表foo的每一项都乘以2,再返回由其结果组成的新列表 #用for循环来做 for i in range(len(foo)): foo[i] *= 2 print(foo) #用列表推导式来做 foo = [i * 2 for i in foo] print(foo) [expression for target in interable if condition] ''' foo = [i + 1 for i in range(10) if i % 2 == 0] print(foo) "...
5d3bd1501a4cc4215e8f1151d3f517aee4cdf389
tautomer/mcmc
/mcmc/mcmc.py
4,243
3.609375
4
# -*- coding: utf-8 -*- # The main program for Markov chain Monte Carlo simulation # This program requires four initial parameters, k, r, T and nsteps. # where k is the number of nodes, r is the weight coefficient. # T is temperature, nsteps is total number of steps, i.e., graphs. # They are specified at the beginning ...
ab66737c164a1aebcdc34baec315c491fc211e20
chemin233/pythonPractice
/day5/Fanction.py
651
3.796875
4
# -*- coding: utf-8 -*- import math def my_abs(x): if x>=0: return x else: return -x def move(x, y, step, angle=0): nx=x+step*math.cos(angle) ny=y-step*math.sin(angle) return nx, ny def quadratic(a, b, c): if not (isinstance(a, (int, float)) and isinstance(b,(int, float)) a...
b5dcefcf459bcb0e30c9dc5b5f27fd73e326ce9a
chemin233/pythonPractice
/day4/CountDemo.py
194
3.65625
4
# -*- coding: utf-8 -*- line=0 while line<10: column = 0 while column<line: column+=1 print(column,"*",line,"=",column*line,end=" ") print("",end="\n") line += 1
42f7b151bdb38564891b182705376fe1e3ee340e
chemin233/pythonPractice
/day4/RopeDemo.py
150
3.96875
4
# -*- coding: utf-8 -*- lenth=3000 day=0 while lenth>5: lenth/=2 day+=1 print("第%d 天" % day,"lenth----",lenth) print("第%d 天" %day)
c16ccd08191a04518eb0fed7858a250daba90e08
nikunjbadjatya/gedcom_parser
/app/gedcom_parser.py
3,030
3.6875
4
'''gedcom_parser.py Contains class GedcomParser ''' import sys from app_exceptions import ValidationError from validation import Validation class GedcomParser(): """GedcomParser class """ def __init__(self, input_file): """Initialization of GedcomParser object. """ Validation(i...
67f4dbf973947e11331d9c4f513de25210c3ea76
rollinde/are-gravite-2017-exoplanetes-lcm
/Début du code.py
1,498
3.515625
4
# -*- coding: utf-8 -*- """ Created on Lundi 06 Mars 2017 - ARE - @author: BOUKHALFI MOURAD 3679709 """ import numpy as np import matplotlib.pyplot as plt from matplotlib import animation circle1 = plt.Circle((0, 0), 0.3, color="yellow") fig= plt.figure() fig.set_dpi(100) fig.set_size_inches(10, 10) ...
ffd564aa5ca1d5666adfe026c8c518ae9b6c207e
pcornier/gumvox
/lib/interpolator.py
1,255
3.59375
4
from enum import IntEnum class Mask(IntEnum): """Mask values for interpolator""" NOTE = 1 VEL = 2 CTL = 4 class NoteInterpolator(object): """Used to interpolate notes, velocity and controller values""" flags = 0 vel1 = vel2 = 0 val1 = val2 = 0 ctl = 0 duration = 0 def __...
ce31cfc548e5e1fc89f36ddd8d270ebe01857b0c
AhernEYeldarB/Python-ADTs
/graph ADT/APQ.py
5,753
3.828125
4
class Node: ''' Node object in an Adaptable Priority Queue Attributes: Key = Quantative data type, used to determine position in list( Works with numerical data types ) Value = The value the node is storing in the list Index = the position of the item in the array ''' ...
5cb698b64f9f44a5bd89700c212ee887aea3f8c0
jeprinz/MuffinProblem
/general.py
8,643
4.0625
4
from fractions import Fraction import math import itertools import numbers import interval import operator #an interval is represented by (a,b) a tuple of Fractions class Value(tuple): """Represents 1st degree polynomial AQ + B""" def __new__ (self, a, b): return super(Value, self).__new__(self, tuple([a, b])) ...
9cba6a42db10fb1b601762379e6fedc252f984c4
jeprinz/MuffinProblem
/scottsimple.py
4,384
4.1875
4
#implementation of Scott Huddleston's algorithm for the muffin problem from fractions import Fraction import math import interval def scott(muffins, majors, minors): """Computes the "scott muffin problem", which says, given Nm muffins and two groups of students, group 1 is the "majors" and group 2 is the "mi...
25987b9fbee5783ddeb9b34ba300c71f76c6ce1d
zupremememes/perceptrons
/code/perceptron.py
715
3.578125
4
import numpy as np def sgn(x): if x > 0.: return 1. else: return 0. class Network: def __init__(self, wsize, x, yhat): self.input = x self.expectation = yhat self.weights = np.zeros((wsize,1)).flatten() def train(self): while True: error = 0...
c7294cbf1962e85d37e1e3d937e851957f5394a4
antiface/Schizobot
/INTERNALS/ArtificialConscience/CritiqueModule/Formalization/FirstConceptOfHistory.py
1,096
3.53125
4
# First Concept of History. A.G. (c) 2017. All Rights Reserved. # struct FirstConcept { # char title[50]; # int concept_id; # }; concept; # PROBLEM: WHAT IS THE TYPE OF TYPE "FIRST CONCEPT"? ######################### >>> class Concept: def __init__(self, name, id): self.name = name self.id = id >>> x =...
5d2bffe66c5d38d03ce7b07c33ef14f032c09775
CrislyGonzalez/Taller-de-Python-impartido-en-FAREM-Chontales-Nicaragua
/Interfaz.py
3,109
3.609375
4
# importando archivo o librerías from logica import * def imprimirLibro(libro): print("\n Imprimiendo libro...\n" "\nNombre del Libro: " , libro["tituloObra"],"\n" "\nAutor: ", libro["nombreAutor"],"\n" "\nAño de publicación: ", libro["anno"],"\n") def verLibros(): for i in bib...
5457d5886cc4d3fa471668960ababccef9ac9332
thatHumanJason/PythonTurtleClock
/PythonTurtleClock.py
14,944
4.34375
4
# Import the required modules. import turtle # The turtle module used to draw the clock. import datetime # The datetime module used to get the current time. import time # The time module used to wait one second. class PythonTurtleClock(): # __init__ initializes the PythonTurtleClock class def __init__(self): # Def...
c46d37c2a6cf41d971ecfdce7b55bb1d8cfeae3a
Zihad07/uva
/3077_No Brainer.py
210
3.625
4
number_of_data_set = int(input()) while(number_of_data_set): x,y = map(int, input().split()) if x<y: print("NO BRAINS") else: print("MMM BRAINS") number_of_data_set -= 1
710af7dde1eec7060f27405481a7f05ca8cd388d
JeeShao/nlp
/delPunctuation.py
627
3.5
4
# coding:UTF-8 ''' 对经CLAWS附码后的文本进行清理,删除多余内容并统计词数 ''' f=open('demo.txt','r') lines=f.readlines() f.close() str1 = "<s>\n</s>\n" count = 0 ff=open('demo1.txt','w') for line in lines: # print(line) strs = '' words = line.split(' ') for word in words: # print(word) if word in str1: continue elif len(word)==3 ...
ed3d7406b82b2d5818df012aec22704b19192601
ABGJancio/AlternativeCode
/Modification.py
765
3.578125
4
shopping = { 'piekarnia': ['chleb', 'pączek', 'bułki', 'ciastko'], 'warzywniak': ['marchew', 'seler', 'rukola'], 'drogeria': ['szampon', 'krem do rąk'], 'monopolowy': ['whisky', 'cognac', 'champagne'] } for shopname in shopping.keys(): new_shopname = shopname.capitalize() shopping[new_shopname]...
dc6c18763a5cdbb0e8ec0ddee339010e5ede0d7d
shuxianghuafu/IntroductionToAlgorithms
/chapter02/MERGE-SORT/mergeSort.py
1,443
4.1875
4
#!/usr/bin/env python3 # _*_ coding: utf-8 _*_ """ author : xiaohai email : xiaohaijin@outlook.com """ def merge(left, right): """ 归并排序的辅助函数 """ array = [] left_cursor, right_cursor = 0, 0 """ 开始收集两个子‘数组’中的元素 """ while left_cursor < len(left) and right_cursor < len(right): ...
08138bc7d63a9cc15ec13c8cf33e60cce825d6da
VinidiktovEvgenijj/PY111-april
/Tasks/a0_my_stack.py
980
4.3125
4
""" My little Stack """ my_stack = [] def push(elem) -> None: """ Operation that add element to stack :param elem: element to be pushed :return: Nothing """ global my_stack my_stack.append(elem) return None def pop(): """ Pop element from the top of the s...
5593379659cc3cff96ba105d81551c2feeca8f7c
VinidiktovEvgenijj/PY111-april
/Tasks/f0_binary_search_tree.py
816
3.875
4
from typing import Any # import networkx as nx def insert(key: Any, value: Any) -> None: """ Insert (key, value) pair to binary search tree :param key: key from pair (key is used for positioning node in the tree) :param value: value associated with key :return: None """ print(key, value) return ...
92f88ba857a833487e5fcfd83e1ebead52eb2e56
0x10F8/chessbot
/pieces/rook.py
3,016
3.515625
4
from pieces.location import Location from pieces.colour import Colour from pieces.piece import Piece class Rook(Piece): def __init__(self, colour): super().__init__(colour, "Rook", 5, self.__rook_move_worker__) def __str__(self): return "{}R".format(str(self.colour)[0]) def...
00a30883bfa530d04521ea1856cf5f693ccdd222
Kushal997-das/Hackerrank
/30-DaysCode/day6_lets_review.py
466
3.578125
4
def lets_review(t): #Constraints t and s if 1 <= t <= 10: s = input() if 2 <= len(s) <= 10000: even_s, odd_s = '', '' for j, letter in enumerate(s): if j % 2 == 0: even_s += letter else: odd_s += lett...
7aab79328cdc033ef2ef0588593662daa9374623
Kushal997-das/Hackerrank
/Hackerrank_python/7.collections/55.collections.Counter().py
482
3.578125
4
# Enter your code here. Read input from STDIN. Print output to STDOUT from collections import* no_of_shoes=int(input()) size_of_shoes_in_the_shop=Counter(map(int,input().split())) Number_of_customer=int(input()) amount_of_money_earned=0 for _ in range (Number_of_customer): size,price=map(int,input().split()) ...
7a6e09e95826b509959525612f8b1d11fc04e0dd
Kushal997-das/Hackerrank
/Hackerrank_python/13.Regex and Parsing/80.Detect Floating Point Number.py
241
3.625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import re for i in range(int(input())): x=input() #print(bool(re.match([r'^[-+]?[0-9]*.[0-9]+$'],input()))) print(bool(re.match(r'^[-+]?[0-9]*[.][0-9]*$',x)))
032857e8c8238530b5b26c0046d7db8c6647d30b
Kushal997-das/Hackerrank
/Hackerrank_python/13.Regex and Parsing/94.Validating Credit Card Numbers.py
562
3.671875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import re for _ in range(int(input())): x=input() if re.search(r"^[456]([\d]{15}|[\d]{3}(-[\d]{4}){3})$", x) and not re.search(r"([\d])\1\1\1", x.replace("-", "")): print("Valid") else: print("Invalid") ''' import re TEST...
bef3b5a84ac61c05851c81ec7784de9650ffd30f
Kushal997-das/Hackerrank
/Hackerrank_python/14.Closures and Decorators/991.Decorators 2 - Name Directory.py
429
3.640625
4
import operator def person_lister(f): def inner(people): return map(f, sorted(people, key=lambda x: int(x[2]))) # complete the function return inner @person_lister def name_format(person): return ("Mr. " if person[3] == "M" else "Ms. ") + person[0] + " " + person[1] if __name__ == '__ma...
06bca54756ca2317826e62ea2e7b0a08b9969777
Kushal997-das/Hackerrank
/Hackerrank_python/12.Python Functionals/79.Reduce Function.py
406
3.859375
4
from fractions import Fraction from functools import reduce def product(fracs): t =reduce(lambda numerator,denominator:numerator*denominator,fracs) # complete this line with a reduce statement return t.numerator, t.denominator if __name__ == '__main__': fracs = [] for _ in range(int(input())): ...
40b0eab57ae17cdb77045d0156e53e0ba073abd2
Viiic98/holbertonschool-higher_level_programming
/0x0A-python-inheritance/4-inherits_from.py
352
4.15625
4
#!/usr/bin/python3 def inherits_from(obj, a_class): """ inherits_from Check if obj is a sub class of a_class Return: True if it is a subclass False if it is not a subclass """ if type(obj) is not a_class and issubclass(type(obj), a_class): return True...
ea20965aa2780496907dd482e95732495dd29299
Viiic98/holbertonschool-higher_level_programming
/0x0A-python-inheritance/3-is_kind_of_class.py
324
4.0625
4
#!/usr/bin/python3 def is_kind_of_class(obj, a_class): """ is_kind_of_class Check if obj is an instance of a_class Return: True if it is an instance False if it is not an instance """ if isinstance(obj, a_class): return True else: return Fa...
d6703e24dc9bb6ce8f38718aaa6b2d88634d78ed
Kouba261/Hello_World
/Kdo první hodí ŠESTKU.py
1,221
3.6875
4
from random import randrange hra = input ("Chceš si zahrát kostky? ") if hra == "ano" : print ("Paráda, jdem na to!") hod = input ('Napiš "y" a začni házet kostkou:') if hod == "y": #HRAJE HRÁČ# pocet_hodu = 0 while True: # hazi do nekonecna cislo = (randrange (1,7)) po...
e7d49ed091be1a44a5cc39294fe759a3bd1c16b9
ybkong98/kong
/Graph2.py
898
3.5
4
N,M=map(int,input().split()) parent=list(range(N+1)) edges=[] result=0 for _ in range(M): a,b,c=map(int,input().split()) edges.append((c,(a,b))) edges.sort(key=lambda data: data[0]) #입력+edge를 cost 기준으로 정렬 def matching(parent,x): if parent[x]!=x: parent[x]=matching(parent,parent[x]) r...
a4018797a2cffe5fc6e73d9a3d68a063569e578c
kartikeyagup/CourseWorkSem6
/COL726/Tutorials/Tut1/Solution/Codes/q11.py
499
3.8125
4
import math def Integrate(f, start,stop, step): ans = 0.0 elem = start while (elem<stop): ans += 0.5*step*(f(elem)+f(elem+step)) elem += step # for elem in xrange(start,stop,step): # ans += 0.5*(f(elem)+f(elem+step)) return ans print "test" def fact(n): return n*2.0 pr...
8377d3c6b623ba6e45db7d6aca5de60f3a57b98d
PrashantMittal54/Two-Pointers-1
/Problem 35 3Sum.py
1,124
3.515625
4
# Did this code successfully run on Leetcode: Yes # Time Complexity: O(n^2) # Space Complexity: O(n) bcz if sorting # Logic: Extend the approach to calculate 2 sum, sort the array keep i to the left most & for every i calculate sum for # every j & k. if sum is 0 add in output else keep on checking. To avoid duplica...
04ff6c318550265da0dbe93b954283fb39956d41
Nikhil622/Black_Jack-using-Python-OOPs-
/BLACK_Jack.py
3,779
3.765625
4
suits=('DIAMOND','SPADE','CLUBS','HEARTS') ranks=('TWO','THREE','FOUR','FIVE','SIX','SEVEN','EIGHT','NINE','TEN','JACK','QUEEN','KING','ACE') values={'TWO':2,'THREE':3,'FOUR':4,'FIVE':5,'SIX':6,'SEVEN':7,'EIGHT':8,'NINE':9,'TEN':10,'JACK':10,'QUEEN':10,'KING':10,'ACE':(1,11)} class card(): def __init__(self,sui...
b74681f18b4a7ef53dc0f21ffce1329007b83b7c
zeelgandhi/Python-training
/Asignment2_Zeel/ques1.py
118
3.828125
4
# things = ["table", "chair", "sofa"] res = [things.capitalize() for things in ["table", "chair", "sofa"]] print(res)
31ff958139acc4c0fd10be6c8b7c2be9886af0d7
zeelgandhi/Python-training
/Assignments_Zeel/Ques1Assignment.py
320
3.671875
4
x= 2; y= 4 result = x/y print(result) print(type(result)) result1 = 6/4*2 print(result1) print(type(result1)) x = 15; y =4.0 result2 = x+y*2 print(result2) print(type(result2)) result3 = x/y print(result3) print(type(result3)) result4 = y/x print(result4) print(type(result4)) res= y/2 print(res) print(type(res))
681608743c7f31a8d66ec59219b1874f70d083df
zeelgandhi/Python-training
/Asignment2_Zeel/ques4.py
187
4.0625
4
def odd_value(n): for x in n: if x%2 != 0: yield x result = odd_value(range(10)) for y in result: if result.__next__() == 3: print(result.__next__())
917eb326e329cb0eb946da36882b414493a608db
reklu/aap_variables
/main.py
269
3.796875
4
''' saludo = "Hola " nombre = input("Ingresa nombre la concha de tu hermana: ") print(saludo + nombre) ''' ''' num1 = input("Ingrese el primer numero: ") num2 = input("Ingrese segundo numero: ") print(num1 + num2) ''' nombre = input("ingrese nombre:") print(nombre)
ce6aa645e756644348de25c3321e907c4894a139
cosanlab/nltools
/examples/02_Analysis/plot_multivariate_classification.py
4,047
3.796875
4
""" Multivariate Classification =========================== This tutorial provides an example of how to run classification analyses. """ ######################################################################### # Load & Prepare Data # ------------------- # # First, let's load the pain data for this example. We ne...
19fc714f10602fd1760aed8455566fb2777e2e05
oniani/profile-generation
/util/bio/get_bio.py
1,249
3.8125
4
""" @author: David Oniani @date: 2019 """ from random import choice from typing import List def generate_bio(name: str, hobbies: List[str], path: str) -> str: """Generate a user biography.""" intro_word = choice(["Greetings", "Hello", "Hey", "Hi", "Hiya", "Howdy", "Howdy-doody"]) if choice([True, False]...
fd62e0b851ff1285e6a6264b9aa4b669b016d862
llittleTomato/OpenCV-tutorials
/image/1c-Resize.py
340
3.6875
4
import cv2.cv as cv im = cv.LoadImage("../img/alkaline.jpg") #get the image thumb = cv.CreateImage((im.width / 2, im.height / 2), 8, 3) #Create an image thatis twice smaller than the original cv.Resize(im, thumb) #resize the original image into thumb #cv.PyrDown(im, thumb) cv.SaveImage("thumb.png", thumb) # sa...
3d44585b68348d17e1f0f2eee59f57416ca01de2
llittleTomato/OpenCV-tutorials
/image/2a-Filters.py
1,300
3.59375
4
import cv2.cv as cv image=cv.LoadImage('../img/lena.jpg', cv.CV_LOAD_IMAGE_COLOR) #Load the image cv.ShowImage("Original", image) grey = cv.CreateImage((image.width ,image.height),8,1) #8depth, 1 channel so grayscale cv.CvtColor(image, grey, cv.CV_RGBA2GRAY) #Convert to gray so act as a filter cv.ShowImage('Gr...
ce308929c4917ff7611d25c1e14c382f8a0895db
RockJohnson503/MyDemo
/PyDemo/CollectionsOverView/chapter3/namedtuple_test.py
286
3.5625
4
# encoding: utf-8 """ File: namedtuple_test.py Author: Rock Johnson """ from collections import namedtuple name_tuple = (["rock", 17, 177], ["johnson", 18, 188]) User = namedtuple("User", ["name", "age", "height"]) user = [] for name in name_tuple: user.append(User(*name)) print(user)
40205027a2105fe072edd5f84419fa647080e82c
RockJohnson503/MyDemo
/PyDemo/algorithm/searchFunc.py
687
3.546875
4
# encoding: utf-8 """ File: searchFunc.py Author: Rock Johnson """ class Search: def __init__(self): self.__index = -1 self.__isFind = False def searchDepth(self, arr, target): self.searchHelper(arr, target, 0, len(arr) - 1) return self.__index def searchHelper(self, arr,...
854e81ad6cc9e5a9a0df03fe8d168906444daf06
AlirezaTeimoori/Unit_3-01
/Guess_the_number.py
556
3.953125
4
#Created by: Alireza Teimoori #Created on: 3 Oct 2017 #Created for: ICS3UR-1 #Lesson: Unit 3-01 #This program is to learn if statments #The code shows "you won!"if the user's entry is 5 import ui WINNING_NUMBER = 5 def check_button_touch_up_inside(sender): #Checks if the number user entres is the winning numbe...
27225d6ae5aa4d38041e5e8e2d3a967853fc20be
shrutiturner/Tic-Tac-Toe
/Problems/Grade/task.py
508
4.09375
4
student_score = int(input()) max_score = int(input()) def calculate_percentage(student_score, max_score): percentage = student_score / max_score * 100 return percentage def assign_grade(percentage): if percentage >= 90: return "A" elif percentage >= 80: return "B" elif percentage...
0be0c5e8d9197d53cdb573483a249a18bfea608f
gabrielnavas/data_structure_and_algorithm_in_python
/basic/condition_structure.py
241
3.875
4
name = 'Gabriel' if name == 'Gabriel': print('Olá') elif name == 'gabriel': print('bye') if name in ['gabriel', 'gab', 'Gabriel']: print('i am...') if False: print('ola') elif True: print('hellooww gabb') else: print('olaa')
40a3b9043a91eaa1d83af80221639e16ff12eb4f
gabrielnavas/data_structure_and_algorithm_in_python
/tree/binary-search-tree.py
947
3.875
4
class Node: def __init__(self, data): self.left = None self.right = None self.data = data class BinarySearchTree: def __init__(self): self._root = None def add(self, data): if(self._root == None): self._root = Node(data) else: node = self._root end = False while...
68ea33c87477fbd71a21dccf7c9549b015a00319
DSoliz/448-Project-1
/feed_HMS.py
2,152
4.09375
4
""" @file: feed_HMS.py @author: Diego Soliz, Shane Chu, Michael Bechtel, Connor Welsh, Dustin Wendt @date: 2016.02.14 @brief: Feed_HMS class. Used get input from the user and handle exceptions. """ hour_range = [x+1 for x in range(13)] #[1,2,....,12] minute_range = [x for x in range(60)] #[0,1,2,....,59] second_range ...
37a81875a98a3b61ac42098493f2916f5464afbc
adityawisnugraha/GUI-Python-Example-
/Kalkulator.py
1,025
4.03125
4
#definisikan cond = 'error' cond = 'error' #jika cond = 'error', lakukan: while cond == 'error': # input angka1 tipe decimal angka1 = float(input('masukkan bilangan ke-1: ')) # input angka2 tipe decimal angka2 = float(input('masukkan bilangan ke-2: ')) # input operator oprtr = input('masukkan o...
6e4f90c3dd486241de794f0d071a0601fcc1ea44
ysjwdaypm/study
/python/pyfiles/deco.py
510
4.4375
4
""" 问题: Python的函数定义中有两种特殊的情况,即出现*,**的形式。 如:def myfun1(username, *keys)或def myfun2(username, **keys)等。 解释: * 用来传递任意个无名字参数,这些参数会一个Tuple的形式访问。 **用来处理传递任意个有名字的参数,这些参数用dict来访问。* """ def deco(fun): def inner(*args,**kwargs): return fun(*args,**kwargs) return inner @deco def my_func(*args): print(arg...
04cfaeb9aa0e84867269480d88b6aad850964b29
dscottboggs/practice
/HackerRank/panagram/panagram.py
337
4.0625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import string s = str(raw_input()).lower() print(''.join(set(sorted(s))).strip()) print(string.ascii_lowercase) #if (''.join(set(sorted(s.strip()))).find(string.ascii_lowercase) == -1): # print("pangram") #else: # print("not pangram") def getM...
d15a5aa268e7d312cef56fdd19be4efe2a0b9fdc
dscottboggs/practice
/HackerRank/diagonalDifference/difference.py
1,391
4.5
4
from typing import List """The absolute value of the difference between the diagonals of a 2D array. input should be: Width/Height of the array on the first input line any subsequent line should contain the space-separated values. """ def right_diagonal_sum(arrays: List[List[int]]) -> int: """Sum the right diago...
156a01330763344eb7a0a87c03a47a289595a465
raguileoam/sockets-with-encryption
/servidorSinSSL.py
1,085
3.5625
4
# -*- coding: utf-8 -*- import threading import socket class Server(): def __init__(self): self.host = 'localhost' self.port = 8886 self.maxcon = 1 def start(self): self.s = socket.socket() self.s.bind((self.host, self.port)) self.s.listen(self.maxcon) ...
96ce22ed7f7ae056ac73f20ef5da47ca203e1a16
weberna/fmri-clustering
/ModCluster.py
10,067
3.578125
4
import numpy as np np.set_printoptions(threshold=np.nan) def modularity(D, split, clustList=None, degrees=None): """ Calculate the modularity increase value obtained when the clustering described in split is applied on the graph of data matrix/group matrix Dg @INPUTS: (2d numpy array) D - data matr...
d07c366a58048aad954bac1d804894cb3dece5fa
katzaw89/Sum-of-array-singles
/main.py
329
3.671875
4
list = [4,5,7,5,4,8] list1 = [9, 10, 19, 13, 19, 13] list2 = [16, 0, 11, 4, 8, 16, 0, 11] def repeats(arr): newArr = [] for i in range(len(arr)): if arr.count(arr[i]) == 1: newArr.append(arr[i]) return sum(newArr) print(repeats(list)) print(repeats(list1)) print(repeat...
8d777e48c4394b845642810a97bc68080df3c2b8
JConwayAWT/pgss15cb
/stochSim.py
295
3.703125
4
#!/usr/bin/env python """Main function""" from Parser import Parser import sys if len(sys.argv)!=3: raise ValueError("This program needs 2 arguments: input file (.react) and output file (.csv)") p = Parser() model = p.get_model(open(sys.argv[1], "r"), open(sys.argv[2], "w")) model.iterate()
d0d2053a9bf48cf17f97a45a3bfc5201e3f1788c
fkocak/PL_Hmw_FK
/4. Hafta Odev/PL-HW3_odev_3.py
4,099
3.71875
4
# -*- coding: utf-8 -*- # HW-3 answers for Alfa Programming Language Course Lecture-5 # Program name: PL-HW3_odev_3.py # Written by: Fatih Koçak (fkocak@aysuelektrik.com.tr) # Date: 31-03-2016 # Version : 1.0 # Soru #1 print ''' Problem 1-) Kullanıcıdan gelen karekter dizinini ortadan iki'ye bölün ilk yarısını terst...
9f648cf17a10008db6530e26c941642ae9bddbfb
abigail-powell/Tic-Tac-Toe
/player.py
6,682
3.671875
4
''' Abby Powell apowell9@binghamton.edu A52, Elizabeth Voroshylo Simrohn Iftekhar siftekh1@binghamton.edu A53, Jonathan Cen Final Project Collaborated equally in designing and building the Player class ''' import piece import random class Player: # --- Constants --- START = 0 MAGIC_NUM ...
3aead5274a1d18e8f0d25c0833472a99f0e11caa
LiXin-Ren/Algorithms
/并查集(union-find)/QuickFind.py
703
3.734375
4
""" 实现UnionFind算法。s使用最简单的quick-find方法 union(p, q) find(p) connected(p, q) """ class QuickFind(): def __init__(self, N): self.id = [i for i in range(N)] # 触点的类别 self.count = N # 连通域个数 def findID(self, p): return self.id[p] def connected(self, p, q): ...
b4729ac8cb9c4d7ba23b8fb98149a734ef517a93
yawitzd/dsp
/python/q8_parsing.py
1,343
4.375
4
#The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program to...
b12125bfd87a14b9fba134333f933e0adf308bb6
talhahome/codewars
/Oldi2/Write_Number_in_Expanded_Form.py
612
4.3125
4
# You will be given a number and you will need to return it as a string in Expanded Form. For example: # # expanded_form(12) # Should return '10 + 2' # expanded_form(42) # Should return '40 + 2' # expanded_form(70304) # Should return '70000 + 300 + 4' # NOTE: All numbers will be whole numbers greater than 0. def expan...
04765aa603e860cc13f9b7541f00fe608ccb35c5
talhahome/codewars
/Oldi3/RGB_To_Hex_Conversion.py
1,097
3.921875
4
# The rgb() method is incomplete. Complete the method # so that passing in RGB decimal values will result in a hexadecimal representation being returned. # The valid decimal values for RGB are 0 - 255. # Any (r,g,b) argument values that fall out of that range should be rounded to the closest valid value. # # The follow...
85b6e1437a59c1841f504218723b9535ae9b740a
talhahome/codewars
/Oldi2/Gap_in_Primes.py
1,928
3.734375
4
# Description: # The prime numbers are not regularly spaced. For example from 2 to 3 the gap is 1. From 3 to 5 the gap is 2. # From 7 to 11 it is 4. # Between 2 and 50 we have the following pairs of 2-gaps primes: 3-5, 5-7, 11-13, 17-19, 29-31, 41-43 # # A prime gap of length n is a run of n-1 consecutive composite num...
cb5c164435c1ea3c6f4e1b3a30641365fc30f4a3
talhahome/codewars
/Oldi/extract_file_name.py
651
3.65625
4
# You have to extract a portion of the file name as follows: # Assume it will start with date represented as long number # Followed by an underscore # You'll have then a filename with an extension # It will always have an extra extension at the end class FileNameExtractor: def __init__(self, dirty_file_name): ...
ea28dc883c613ace6f42e05c4bcd733df3482635
talhahome/codewars
/Number of trailing zeros of N!.py
580
4.3125
4
# Write a program that will calculate the number of trailing zeros in a factorial of a given number. # N! = 1 * 2 * 3 * ... * N # # Examples # zeros(6) = 1 # 6! = 1 * 2 * 3 * 4 * 5 * 6 = 720 --> 1 trailing zero # # zeros(12) = 2 # # 12! = 479001600 --> 2 trailing zeros # Hint: You're not meant to calculate the factoria...
859004d58610becfeedade2dc0e0a1a5a28c3cd2
talhahome/codewars
/Oldi2/Vowel_Count.py
609
4
4
# Return the number (count) of vowels in the given string. # # We will consider a, e, i, o, and u as vowels for this Kata. # # The input string will only consist of lower case letters and/or spaces. def getCount(inputStr): num_vowels = 0 vowels = ['a', 'e', 'i', 'o', 'u'] for i in inputStr: if i in...
eb58da5a627e3f0802d33c127b1340e770d89a41
talhahome/codewars
/Oldi2/Find_the_divisors!.py
700
3.96875
4
# Create a function named divisors/Divisors that takes an integer n > 1 and returns an array # with all of the integer's divisors(except for 1 and the number itself), from smallest to largest. # If the number is prime return the string '(integer) is prime' (null in C#) # (use Either String a in Haskell and Result<Vec<u...
fd2100872e564e2952336bcdd2192606a8dfa4f0
Lohithayenugu/Python-DL
/Lab1/Task3.py
9,681
3.578125
4
class Person: __per_count=0 def _init_(self,name,age,family): self.__name=name self.__age=age self.__family=family Person._per_count=Person._per_count+1 @classmethod def get_persons_count(self): return Person.__per_count def get_name(self): return s...
d1d96df019112222b53a12e9ce81a30ba8934a72
Paeans/CodeAnywhere
/PYTHON/6.00.1X/Chapter00/Python_Test.py
692
3.65625
4
# Paste your code into this box balance = 99999999999 annualInterestRate = 0.18 monthRate = annualInterestRate / 12.0 lowPay = round(balance / 12.0 * 100.0) / 100.0 highPay = round(balance * (1 + monthRate) ** 12 / 12.0 * 100.0) / 100.0 while round((highPay - lowPay) * 100) > 1: remaining = balance midPay = r...
22cf3ddee55d8c12125b4863eb9875274a487aa2
MotherNature/Glassdoor-Interview-Scraper
/interview_parser.py
4,062
3.53125
4
import shutil import os import time import datetime import math import urllib import urllib.request from array import array #Picks which page to start iterating on rss_begin = 23016 #Set number of feeds that you want to scrape #FUTURE: have user enter number of feeds that they want to capture, potentially including t...
029d387dfc3a52b1bc13a5875bcc2b1dd288ed1f
Mustafaryad1/Graph
/graph and dijkstar's algorithm/dijkstar's.py
2,038
3.8125
4
from graph import AdjacencyMatrixGraph from priority_dict import priority_dict # Dijkstra's algorithm def build_distance_table(graph,source): distance_table = {} for i in range(graph.numVertices): distance_table[i] = (None,None) distance_table[source] = (0,source) # Holding mapping of...
f296fa1387440866aa8c4da238371ad8be559a62
kawain/pymaze
/main.py
2,189
3.765625
4
import random import math import ana import bou def find_dead_end(maze, i, j): """行き止まり地点を探す""" count = 0 if maze[i-1][j] == 1: # 上 count += 1 if maze[i+1][j] == 1: # 下 count += 1 if maze[i][j-1] == 1: # 左 count += 1 if maze...
52186ccc01a6f49cd21fcfd72760c9f54ada20c3
akotek/CDN
/utils/utils.py
203
3.640625
4
import os def read_file_to_text(path): with open(relpath(path), "r") as file: data = file.read() return data def relpath(path): return os.path.join(os.path.dirname(__file__), path)
5eac3388736b6995ae3fc0a86adbfce5fd3c471e
akotek/CDN
/preprocessing/tokenize/keyword.py
381
3.625
4
from preprocessing.tokenize.tokenizer import Tokenizer class KeywordTokenizer(Tokenizer): def tokenize(self, s: str, stops: set = None) -> list: # The keyword tokenizer is a “noop” tokenizer that accepts whatever text it # is given and outputs the exact same text as a single term # "New...
3e27494fa5776ac2a3f8190bd688e6aacb5539c3
imayush15/python-practice-projects
/Learn/ListEnd.py
260
4.15625
4
print("Program to Print First and last Element of a list in a Seperate List :=\n") list1=['i',] x = int(input("Enter the Range of list : ")) for i in range(x): y = int(input("Enter the Value : ")) list1.append(y) print(list1[1], list1[-1])
60bd72d60b4c4a59af5d5a61f63f0fd05d1affbe
imayush15/python-practice-projects
/Learn/Reverse_Sentence.py
226
4.0625
4
def myfunc(mystring): wordlist = mystring.split() reversed_list = wordlist[::-1] return " ".join(reversed_list) x = input("Enter a Sentence : ") result = myfunc(x) print("The Reversed Sentence is : ", result)
3c28effd55d6948bfcd606a1e3466a2cbbc25218
imayush15/python-practice-projects
/Learn/Pythagorean_Triplet.py
311
4.1875
4
print("This is the program for thr Pythagoran triplet : ") h = int(input("Enter the Height : ")) b = int(input("Enter the Base : ")) p = int(input("Enter the Hypotaneus : ")) if (p*p)==(h*h)+(b*b): print("This is a Pythagorean Triplet :)") else: print("Sorry ! This is not a Pythagorean Triplet :(")
8d7814de5c811cf37dff3c7c8fcb8575d5a7a633
imayush15/python-practice-projects
/Learn/Divisor.py
171
4.21875
4
print("This is the program to find out the divisor of the given number : ") x = int(input("Enter the Number : ")) for i in range(1, x+1): if x%i==0: print(i)
80861ffacc9dbcda50bb8b14daee0fbe3ea33771
nirkhl2/Word-Of-Games
/Live.py
3,321
3.859375
4
import GuessGame import MemoryGame import CurrencyRouletteGame import Scores global user_name, game_name, game_difficulty games_names_list = ['Memory Game', 'Guess Game', 'Currency Roulette'] user_input_type_list = ['game', 'difficulty'] def set_user_name(name): global user_name user_name = name def welcom...
d36f04026a397bc778cdd541227ff2d0699cd9b0
rajeshb/SelfDrivingCar-Term3
/search/search-solution.py
3,183
3.6875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 20 15:59:13 2017 @author: rajesh """ # ---------- # User Instructions: # # Define a function, search() that returns a list # in the form of [optimal path length, row, col]. For # the grid shown below, your function should output # [11, 4, 5]. # # I...
5d1e39aea6d33db17bd2357d3fc6924c07fbe70c
tripathiaakash/AI-Utilities
/Detect_Language.py
996
3.609375
4
import string def is_English(x): cnt = 0 for ch in x: if ch in string.ascii_uppercase or ch in string.ascii_lowercase: cnt+=1 if cnt/len(x)>0.5: return True return False def is_Hindi_and_marathi(x): cnt = 0 for char in x: if ord(u'\u0900') <= ord(char) <= o...
781ffc3126a844072c27e74c4ae4a1b1dd40ae3f
shad-con/week1
/task_1_2.py
344
4
4
from math import sqrt for x0 in range(1, 9): for y0 in range(1, 9): for x1 in range(1,9): for y1 in range(1,9): distance = sqrt((x1-x0)**2+(y1-y0)**2) if x1 == x0 and y1 == y0: continue print("{},{} to {},{} distance {}".format...
9149d0d3807fbb9e654654fe7bb95692083f01f5
coba-luis-enrique/PROYECTO-INTEGRADOR-UNIDAD-1
/main.py
672
3.625
4
from opereacion import * archivo = open('lista.txt', 'r') leer_fila = archivo.readlines() archivo.close() print("nombres desosdernados") for lista in leer_fila: # revisamos si tiene un salto de linea al final para quitarlselo. if lista[-1]=="\n": dato=lista[:-1].split(",") else: dato=list...
cf9ab3237227842f23664d4853f2db32a75d4f54
sanderbroos/jas-rush-hour
/code/algorithms/breadth_first.py
5,001
4.03125
4
from code.util import all_moves from queue import Queue from copy import deepcopy from time import time class BreadthFirst(): """ A Breadth First algorithm that builds a queue of games each with cars in an unique position. """ def __init__(self, game): self.game = deepcopy(game) se...
17866448c21623d28b8abd4ca3b51b0d5a9f5eb5
sanderbroos/jas-rush-hour
/code/algorithms/hill_climber.py
4,162
3.984375
4
from .randomise import Random from copy import deepcopy class HillClimber: """ A Hill Climber algorithm that uses a randomly generated solution and iteratively tries to combine moves together for improvement. """ def __init__(self, game): self.game = deepcopy(game) self.moves = [] ...
22e20e0933f10c88e9e43969fe71999802590dc5
banginji/algorithms_sot
/chapter3/my_queue.py
1,044
3.875
4
from datastructures import stack class MyQueue(): def __init__(self): self.stack_one = stack.Stack() self.stack_two = stack.Stack() def enqueue(self, data): self.stack_one.push(data) def dequeue(self): for item in self.stack_one.stack_data: self.stack_two.push...
9c1066c1cb46e59eedf024bf7f3f99f8ce722e0c
banginji/algorithms_sot
/datastructures/min_heap_kai.py
1,150
3.875
4
def build_min_heap(arr): for idx in range(len(arr) // 2, -1, -1): min_heapify(arr, idx) def min_heapify(arr, idx): left_idx = left(idx) right_idx = right(idx) if left_idx < len(arr) and arr[left_idx] < arr[idx]: smallest_idx = left_idx else: smallest_idx = idx if right_...