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
4058a7a8f8e41bda17b55436f41f19807727dd41
kim-dong-yeob/dataStructure
/binarySearch.py
442
3.859375
4
def binarySearch(result, left, right, t): if left > right: return None mid = (left + right) // 2 if result[mid] == t: return mid if result[mid] > t: return binarySearch(result, left, mid-1, t) else: return binarySearch(result, mid+1, right, t) if __name__=="__ma...
e378f29d1bd2dbf43f88f0a0d2333f811150be2f
scvetojevic1402/CodeFights
/CommonCharCount.py
660
4.15625
4
#Given two strings, find the number of common characters between them. #Example #For s1 = "aabcc" and s2 = "adcaa", the output should be #commonCharacterCount(s1, s2) = 3. #Strings have 3 common characters - 2 "a"s and 1 "c". def commonCharacterCount(s1, s2): num=0 s1_matches=[] s2_matches=[] f...
5ca49ac94f920beae227f0c98638a5358a8749fe
cedric05/test
/challange/prices.py
1,347
3.609375
4
class ItemNotAvailable(Exception): message = "item is not available/listed" pass class Item(object): def __init__(self, name, price, helpful_name): self.name = name self.price = price self.helpfull_name = helpful_name def __eq__(self, other): return super.__eq__(self, ...
b541124ea5c89bf0713969fbf71de4a5d1f0728f
isaaclc98/Curso_De_Python
/programas14deAbril/for.py
175
3.890625
4
#repeticion cadena=input("Dame una cadena:") repeticion=int(input("Cuantas vecez se repetira?:")) for x in range (0,repeticion): print(x+1,cadena) input("\n....")
17567fbf331c167f16cb76d18cbb6e5d21adcd60
isaaclc98/Curso_De_Python
/programas14deAbril/cadenas.py
970
3.5625
4
#para cadenas simples son comillas dobles(""), pero para grandes son comilas triples(""") cadena_grande="""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex e...
17af5c325feed4b9cb6fc4514c2dc77623f47ada
isaaclc98/Curso_De_Python
/Programas21deAbril/AreaCuadradoTriangulo.py
666
4.03125
4
print("Seleccione una operacion: \na: Area cuadrado \nb: Area Triangulo") x=input("Opcion: ") if x == 'a' : print("Calculadora area cuadrado") baseC=int(input("Dame la base: ")) alturaC=int(input("Dame la altura: ")) area=baseC*alturaC print("El area es:",area) input("........"), elif x...
3d428a27a9978e95bb93197f99bfc3a3f5cf5359
bitlearns/Simple_Calculator
/Simple_calculator.py
3,447
3.984375
4
#Before this correction there was 100+ problem but all problems are solved now. #Here i am importing tk,Button etc individually from tkinter import Tk from tkinter import Button from tkinter import END from tkinter import Entry root=Tk() root.title("Simple Calculator") #Creating Entry box In Top e=Entry(root,...
c006e1519a8c2b1d4b30b0f6778c2cdaa92d623e
dayanandtekale/Python_Basic_Programs
/for_over_dict.py
451
3.859375
4
a = {'A':30, 'B':54, 'C':67, 'D':12, 'E':89, 'F':45} #print every numberon separate line using for loop #logic1 #for i in a: # print(i) # print(i,a[i]) #logic2: #for i in a: # print(a[i]) # print(a['c']) #nested for loop: #for i in range(6): #(0-5) # for j in range...
b1607962d1e6a3099333bc3274b87de2ba88c41b
dayanandtekale/Python_Basic_Programs
/for_loop3.py
892
3.6875
4
#list1 = [[[45, 67, 27], [92, 30, 71]], [[91, 54, 67], [28, 71, 45]], [[91, 54, 67], [92, 30, 71]]] #for item in list1: #1st method # print(item) # for inneritem in list1[6]: # print(inneritem) #for idx, item in enumerate(list1): #next met...
1281b78ad6c3928723cf36b887f5542a1f1ac246
dayanandtekale/Python_Basic_Programs
/list_removal.py
170
3.703125
4
a=[[2, 3, 4, 5],[10, 20, 30,40]] b=[[],[]] for i in range(len(a[0])): if not(i==1 or i==2): b[0].append(a[0][i]) b[1].append(a[1][i]) print(b)
c2d0e8489e7783edf1fc6a5548825a77da605e57
dayanandtekale/Python_Basic_Programs
/basics.py
1,303
4.125
4
#if-else statements: #score=int(input("Enter your score")) #if score >=50: # print("You have passed your exams") # print("Congratulations") #if score <50: # print("Sorry,You have failed Exam") #elif statements: #score=109 #if score >155 or score<0: # print("Your score is invalid") #elif s...
d5b14839ed3b77333d594a8cfdb619b8ee1fb203
johnnyem527/pyprac
/singleton/ex1.py
1,050
3.8125
4
# class Singleton(object): # def __new__(cls, *args, **kwargs): # if not hasattr(cls, '_instance'): # cls._instance = super().__new__(cls) # return cls._instance # # class Apple(Singleton): # def __init__(self, name): # self.name = name # # def __str__(self): # re...
4d1c33ba6db586534054682268da470dde438f81
johnnyem527/pyprac
/binary_search/impl_binary_search.py
829
3.875
4
def binary_search(arr, ele): first = 0 last = len(arr) - 1 found = False while first <= last and not found: mid = int((first + last)/2) if arr[mid] == ele: found = True else: if ele < arr[mid]: last = mid - 1 else: ...
9a6a75faed5188fcc609b8bc7ca5f53929e7c9a5
ChenWang91/qsbk
/get_qsbk.py
658
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from bs4 import BeautifulSoup import requests import os def get_information(): num = int(raw_input("Please Input Page Number:")) while num > 0: s = requests.get('http://www.qiushibaike.com/hot/page/'+str(num)) soup = BeautifulSoup(s.text, "lxml") ...
e172dfe3f6f46a0fbfd6e9524977eb6a0bdf1a0b
d3c0d3d-cmd/libro
/src/main/python/libro/ebookmeta/utils.py
512
3.546875
4
def xstr(string): if string is None: return '' else: return str(string) def person_sort_name(name, first_delimiter=' '): n = name.split() if len(n) > 0: n.insert(0, n.pop()) if len(n) == 1: return n[0] elif len(n) > 1: return n[0] + fir...
8f86412ffc398ad4da515de3b378d3fbca2c19e5
JadenTravnik/GazeVector
/GazeVectorUsingRegression/regressor.py
4,036
3.546875
4
import numpy as np from sklearn.linear_model import LinearRegression as LinReg # This function simply performs a simple linear regression http://scikit-learn.org/stable/modules/linear_model.html def regressTest(original, target, test, numTargetCols): numFrames = len(test) linReg = LinReg(fit_intercept=True) p...
bb4a1cdb6f008b08dbb6f8d494a66651b172ee3d
navneettiwari81/algo_visualiser
/path_finding_algo_a_star.py
7,472
3.59375
4
import pygame as pg from math import sqrt from queue import PriorityQueue WIDTH=765 root=pg.display.set_mode((WIDTH,WIDTH)) pg.display.set_caption("Path finding Algo -A*") #color for further use BLUE=(0,191,255) PARR_GREEN=(0, 255 ,127) BLACK_BLUE=(0, 0, 255) BLACK=(0, 0 ,0) RED=(255, 0, 0) LIME_GREEN=(50...
49063cf5cbae4fc79e96e59d6dfd07178f16b211
cxdy/CSCI111-Group4
/project2/final.py
597
4.40625
4
# Find the distance between two points # Class: CSCI 111 - Intro to Computer Science # Group: Project Group 4 import math # Ask for the 2 xy coordinates x1 = float(input("Point #1 x-coord: ")) y1 = float(input("Point #1 y-coord: ")) x2 = float(input("Point #2 x-coord: ")) y2 = float(input("Point #2 y-coord: ")) # S...
613a833ae062123c4f5a81af2e957fb28fea74cd
cxdy/CSCI111-Group4
/project1/GroupProect1 BH.py
1,054
4.40625
4
firstname1 = input("Enter a first name: ") college = input("Enter the name of a college: ") business = input("Enter the name of a business: ") job = input("Enter a job: ") city = input("Enter the name of a city: ") restaurant = input("Enter the name of a restaurant: ") activity1 = input("Enter an activity: ") activity2...
a365de7796d86fe009cfbe69e143e83d1c25f2ac
choandrew/Project-Euler-with-Python
/Project Euler 3 general.py
1,483
3.875
4
"""The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143""" #the number they gave is too big too simply brute force #b/c listing all numbers from 1 to 600851475143 causes overflow import math from datetime import datetime startTime = datetime.now() #to measure s...
84e9c523cfbd6a1b43f205fb7eb6f2a779567edb
kakabisht/practice_compi_coding
/Incubyte/python/Cal_test.py
1,404
3.59375
4
from Cal_main import addStrings # To import another file and fix directory issue import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) def test(): ''' This function is used to test our code for the following test cases. args: No arguments passed ''' #...
c7bac0820428939277cb0703ac804c0df6fc9e4b
Byankap/Python_basics
/Section_30:Building_App/App.py
1,580
3.8125
4
#creating an app that querie data from mysql database #downloading a library to allow pyton to interact w/ mysql # on the terminal type: pip3 intall mysql-connector-python import mysql.connector #a library that compares text from difflib import get_close_matches #create a connection using a variable con = mysql.co...
371e180fba6385090b5c9cfc5cb2011a02690373
Byankap/Python_basics
/Section_10:Modules/Modules.py
2,949
3.859375
4
#Buildin modules, importing modelules for excecuting things not found in python #for example time(which contains various attributes.) import time while true: with open('files/vegetables.txt') as file: print(file.read()) time.sleep(10) #the output it w...
f9c0bc07955ef9c0fda56610221ecd8e5a4df145
philsgu/Python6DayChallenge
/Day_4/thirteen.py
140
3.859375
4
l = [1, 3, 9, 8, 7] def slice(l,i,k): list1=[] for i in range(i,k): list1.append(l[i]) print(list1) slice(l,1,3)
629016a6e1cdd62b0d6860b9aa04d91e45c1bcce
philsgu/Python6DayChallenge
/Day_5/twenty.py
281
3.921875
4
# Euclid's theorem: the largest number that divides them both without a remainder def gcd(num1,num2): max_num= max(num1,num2) for i in range(1,max_num+1): if (num1 % i == 0) and (num2 % i == 0): gcd=i print(f'GCD is {gcd}') gcd(63,36)
02d6401189b9f9ca69fca58712c2dea180d44a58
vitorvilela/es-recruitment-test
/ES/1/main.py
1,158
3.921875
4
# ESSS1 import argparse import sys # Simple input validation function def inputValidation(X, Y): if (type(X)!=int or type(Y)!=int or X<=0 or Y<=0 or X>=2000 or Y>2000 or X>=Y): sys.exit("X and Y must be positive integers in the range [1, 2000] and Y must be greater than X.") def fizzBuzz(X, Y): ...
10df56e58389cf454d3b53a0f12a291c73bba513
rjegankumar/exploring_CRDC
/enrollment.py
1,474
3.65625
4
import pandas as pd def percent_enr(col_name): return (round(data[col_name].sum()/all_enrollment*100, 2)) if __name__=="__main__": data = pd.read_csv("data/CRDC2013_14.csv") data["total_enrollment"] = data["TOT_ENR_F"] + data["TOT_ENR_M"] all_enrollment = data["total_enrollment"].sum() print("Perc...
1f04065d6d115d8fda31e651b71ca9ed4e3bc9b7
destinyplan/ZenCloud2
/homework/d20180805_6.py
1,539
3.703125
4
#listOri.append(5)#c = a + b #1.将两个列表同时添加到同一个列表中 listOri=[2312,23121,31231] listInsert=[1232312323,3123] listC=[listOri+listInsert] print(listC,listC==listOri+listInsert) # listOri.clear()# listOri=[1,11,2,2,3,3,4,4] list1=[] Len=len(listOri) listOri=list1 print(listOri) # listOri.copy()# # listOri.count('a')# # listO...
7ca5da5615effc6579a9f1d7d77392e0eae6418a
destinyplan/ZenCloud2
/project/project_Apple/day0802.py
7,931
3.546875
4
#优化-五子棋 # while True: # mapSize=int(input("size=")) # fiveMap=[] # i=0 # k=[0]*mapSize # while i<mapSize: # fiveMap.append(k) # i+=1 # print(fiveMap) # for line in fiveMap: # for elem in line: # print(elem,end=' ') # print("") # 乘法表 #1: 1*1=1 #2: ...
6f2ad6d77c7883cacfd7b706000ce75cfe52acf5
Mohan-sutraye/Assignment-1
/Assignment 1 ( Day 2).py
161
3.640625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: # while loop n= 11 total_numbers = n sum = 0 while (n >=0): sum +=n n-=1 print("sum using while",sum)
7d39eec87d287a762658caac377a880d532143d3
buzzcola/adventofcode2019
/Day03/day03.1.py
734
3.796875
4
with open('Day03/input','r') as f: input = f.read() (wire1, wire2) = input.split('\n') def make_path(wire): directions = { 'R': (1, 0), 'L': (-1, 0), 'U': (0, 1), 'D': (0, -1) } visited = set() current = (0,0) moves = wire.split(',') for move in moves: di...
a037899ebf7328d10cc891ae9c1c1060161ac420
Akascape/CTkListbox
/example.py
558
3.71875
4
import customtkinter from CTkListbox import * def show_value(selected_option): print(selected_option) root = customtkinter.CTk() listbox = CTkListbox(root, command=show_value) listbox.pack(fill="both", expand=True, padx=10, pady=10) listbox.insert(0, "Option 0") listbox.insert(1, "Option 1") li...
10e396f5019fd198a588d543c6746a642867496c
DSR1505/Python-Programming-Basic
/04. If statements/4.05.py
309
4.15625
4
""" Generate a random number between 1 and 10. Ask the user to guess the number and print a message based on whether they get it right or not """ from random import randint x = randint(1,10) y = eval(input('Enter a number between 1 and 10: ')) if(x == y): print('You get it right') else: print('Try again')
4c590e8a0ff2058228a40e521d4dc31b1978ee9e
DSR1505/Python-Programming-Basic
/02. For loops/2.14.py
276
4.34375
4
""" Use for loops to print a diamond. Allow the user to specify how high the diamond should be. """ num = eval(input('Enter the height: ')) j = (num//2) for i in range(1,num+1,2): print(' '*j,'*'*i) j = j - 1 j = 1 for i in range(num-2,0,-2): print(' '*j,'*'*i) j = j + 1
de001e29922f66254d28e5b83a7104fcdb1de860
DSR1505/Python-Programming-Basic
/05. MISCELLANEOUS TOPICS I/5.06.py
302
3.546875
4
""" Write a program that finds all four of the perfect numbers that are less than 10000. """ n = 1 while n <= 10000: sum = 0 divisor = 1 while divisor < n: if not n % divisor: sum += divisor divisor = divisor + 1 if sum == n: print(n) n = n + 1
a524fadcebb0dd56c75a7499d2a085604aa2d015
DSR1505/Python-Programming-Basic
/05. MISCELLANEOUS TOPICS I/5.02.py
448
3.84375
4
""" Write a program that counts how many of the squares of the numbers from 1 to 100 end in a 4 and how many end in a 9. """ a = [] b = [] for x in range(1, 101): if x%10 == 2 or x%10 == 8: y = x**2 if y%10 == 4: a.append(y) if x%10 == 3 or x%10 == 7: z = x**2 if z%1...
9c3879bb2853ad0d312313440b2f01646725d55f
samane1404/project1
/project1/login.py
8,147
3.65625
4
import csv import pandas as pd import logging logging.basicConfig(level=logging.DEBUG, filename='loging.log', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S') class LoginStudent: def __init__(self, n, file='text.csv'): self.n = n self.file = f...
d05599f192bbe4240318ecf8e6907b0d4fdc93fd
BrunoTorresF/python-toy-problems
/commonCharacters.py
422
3.96875
4
# Write a function `f(a, b)` which takes two strings as arguments and returns a # string containing the characters found in both strings (without duplication), in the # order that they appeared in `a`. Remember to skip spaces and characters you # have already encountered! # Example: commonCharacters('acexivou', 'aegiho...
b89ef80230343f159ac94424120e67d62b78f9f7
athirarajan23/luminarpython
/data collections/list1/multiplication of list.py
49
3.609375
4
list=[1,6,5] a=1 for i in list: a*=i print(a)
4a3808a23ac3bdcbbcb65b36dce2e82cc46c359a
athirarajan23/luminarpython
/object oriented advanced python/addition using object oriented.py
192
3.75
4
class Addition: def add(self,num1,num2): self.num1=num1 self.num2=num2 def printval(self): print(self.num1+self.num2) obj=Addition() obj.add(1,1) obj.printval()
e86064ac31b884d38fc3b7d6b4f3c87b4e8322f8
athirarajan23/luminarpython
/advanced python exceptions/exception handling in division.py
330
4.03125
4
# a=int(input("enter a number")) # b=int(input("enter a number")) # print(a/b) #to solve unexpected errors exception handle is used a=int(input("enter a number")) b=int(input("enter a number")) try: print(a/b) except: print("exception occured") #try and exception wont work at once but at some cases it works ...
d1e88442b66d36a697090704f68f6267c0a0020e
athirarajan23/luminarpython
/data collections/print passed student name.py
184
3.5
4
total_student={"athira","aishu","kyat","athul","vishnu"} failed_students={"aishu","kyat"} for i in total_student: passed_student=total_student-failed_students print(passed_student)
2bccd665c794dc882a6ec631032c1d931d06248d
athirarajan23/luminarpython
/flowcontrols/for loop/febbinocci.py
216
3.625
4
# 0 adding previous of 2 numbers is febinocci series # 1 # 1 # 2 # 3 # 5 # 8 # 13 n=int(input("enter a limit")) a=0 b=1 count=0 for i in range(0,n+1): print(a) count=a+b a=b b=count count+=1
4fa88d573cbda292db775d6256508287a3081de2
athirarajan23/luminarpython
/flowcontrols/looping.py
56
3.71875
4
#looping i=1 while(i<=10): print("hello") i+=1
69844a23e566f2bdf526b96b8bc8cb115ced181b
athirarajan23/luminarpython
/operators/4 subject mark.py
579
3.9375
4
sub1=int(input("enter a number")) sub2=int(input("enter a number")) sub3=int(input("enter a number")) sub4=int(input("enter a number")) total=(sub1+sub2+sub3+sub4) print(total) if(total>=180)&(total<=200): print("grade is A+") elif(total>=160)&(total<=179): print("grade is A") elif(total>=140)&(total<=159): ...
dbfc05771d4b0822666f2a185874ce9efbe20d82
athirarajan23/luminarpython
/flowcontrols/calculator.py
609
4.09375
4
opr=input("enter the operation ") def add(): num1=int(input("enter a number")) num2=int(input("enter a number")) print(num1+num2) def sub(): num1 = int(input("enter a number")) num2 = int(input("enter a number")) print(num1-num2) def mul(): num1 = int(input("enter a number")) num2 = int(...
b682277bd147e0115a3acc43d9287658f3a84dbd
athirarajan23/luminarpython
/operators/continue flwcntrl.py
128
3.890625
4
#checking a number is pos or neg n=int(input("enter any number")) if(n<0): print("negetive") else: print("positive")
1ddc261cf174c109583fd0ead1f537673d29090a
athirarajan23/luminarpython
/regular expression/validation rules/rules with eg.py
2,250
4.15625
4
#rules used for pattern matching # #1. x='[abc]' either a,b or c #eg: # import re # x="[abc]" # matcher=re.finditer(x,"abt cq5kz") # for match in matcher: # print(match.start()) # print(match.group()) #2. x='[^abc]' except abc #eg: # import re # x="[^abc]" # matcher=re.finditer(x,"abt cq5kz") # for match in ...
9c1605a430772fe9bbbc6d92a87b8d46fd305589
athirarajan23/luminarpython
/inheritence in advanced python/emp class eg.py
411
3.59375
4
class Employee: company_name="LUMINAR" def __init__(self,name,dept,salary): self.name=name self.dept=dept self.salary=salary def printvalue(self): print(self.name) print(self.dept) print(self.salary) print(Employee.company_name) def __str__(self): ...
55f10fd365d51364b199e97c535c3c1cbc4c60c2
athirarajan23/luminarpython
/data collections/print prime numbers as a set.py
304
4.0625
4
numbers={1,2,4,5,7,6} prime=set() non_prime=set() for i in numbers: if i>1: for j in range(2,i): if(i%j)==0: non_prime.add(i) break else: prime.add(i) print("prime numbers are:",prime) print("non_prime numbers are:",non_prime)
24d461e1522aa67d14533599207602fd2a4c3573
athirarajan23/luminarpython
/polymorphism in advnced python/overriding.py
260
3.875
4
#child class method overrides parentclass method class Parent: def properties(self): print("10 lack rs,2 car") def marry(self): print("with ran") class Child(Parent): def marry(self): print("with arun") c=Child() c.marry()
af8f6a301de6b7bcf12dce96898944ec99928b6d
vickylee745/Learn-Python-3-the-hard-way
/ex30.py
925
4.46875
4
people = 30 cars = 40 trucks = 15 if cars > people: print("We should take the cars.") elif cars < people: print("We should not take the cars.") else: print("We can't decide.") if trucks > cars: print("That's too many trucks.") elif trucks < cars: print("Maybe we could take the trucks.") else: ...
3b6e455b81e53e6031c542a02cefa2ebcc650ac2
vickylee745/Learn-Python-3-the-hard-way
/ex6.py
759
4.09375
4
# define variable: types_of_people types_of_people = 10 # define variable x (is a string with variable) x = f"There are {types_of_people} types of people." # variable binary is a string "binary" binary = "binary" # variable do_not is a string "don't" do_not = "don't" # y is a string with 2 variables y = f"Those who kno...
b850944dda58cf4d1909cbb475cdc780106b52e2
ImagineZero0/Machine-Learning
/Preprocessing/Feature_Selection.py
2,622
3.6875
4
''' Varun Gupta This is an implementation of the Sequential Backward Selection Algorithm which is used to select best subset of features from a feature subspace when we are needed to select some best features and this is one of the algorithms used in feature selection. It works on the principle of removing that feature...
f7a8d02e6470be2805e834b1dea48a90fb228220
ImagineZero0/Machine-Learning
/Linear Models/Adaline Model/Adaline_Gradient_Descent_Model.py
2,678
4.0625
4
''' Varun Gupta An implementation of Adaline Gradient Descent Model using the Python OOP approach using a python class, which initializes a model with the predict and fit method in which the fit method is a improvement over the Rosenblatt's Perceptron as it uses the linear function during the weights update and thresho...
8684285a1e580d4249b60a838d4eec6bc85222db
kkashii/Python-NRS568
/Class 2/Challenge2.2.py
391
4.125
4
# List Overlap list_a = ['dog', 'cat', 'rabbit', 'hamster', 'gerbil'] list_b = ['dog', 'hamster', 'snake'] def overlap(list_a, list_b): list_c=[value for value in list_a if value in list_b] return list_c print(overlap(list_a, list_b)) for x in list_a: if x not in list_b: pri...
4aa9b5c515d4fe780af9c8e9ecfc3c167c290389
mnur9868/python
/latihan.py
6,008
3.640625
4
# import only system from os from os import system, name # clear screen def clear(): # for windows if name == 'nt': _ = system('cls') # for mac and linux(here, os.name is 'posix') else: _ = system('clear') nama = input("Siapa nama anda ? : ") # awal def awal(): #...
ed49c76e4fd354c741258c2f8cd9619f79a92117
DinoFromGoogle/PyDev_Lesson_2
/Task_3.py
323
3.953125
4
""" Задача 3 Найти сумму ряда чисел от 1 до 100. Полученный результат вывести на экран. """ sum = 0 for i in range(1, 101, 1): sum += i print("Step ", i, "___", sum) print("Сумма ряда чисел от 1 до 100 будет равна ", sum)
33dffd72dbc71e9bf6d0669e3570557c5102418d
Chyi341152/pyConPaper
/Concurrency/codeSample/Part4_Thread_Synchronuzation_Primitives/sema_signal.py
1,236
4.65625
5
#!/usr/bin/env python3 # -*- coding:utf-8 -*- # sema_signal.py # # An example of using a semaphore for signaling between threads import threading import time done = threading.Semaphore(0) # Resource control. item = None def producer(): global item print("I'm the producer and I produce data.") ...
04983070df34b993bd794165d93f2a79265782e0
Chyi341152/pyConPaper
/Concurrency/codeSample/Part10_The_Multiprocessing_Module/pipemp.py
914
3.84375
4
#!/usr/bin/env python3 #-*- coding:utf-8 -*- # pipemp.py # An example of a multiprocessing producer/consumer with a pipe import multiprocessing def consumer(p1, p2): p1.close() # Close producer's end while True: try: item = p2.recv() except EOFError: break...
2d7fa7bd8444d40ec6c551ce7365634f35ee4080
Chyi341152/pyConPaper
/Concurrency/functionProgramming/listSum.py
595
4
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- # map, reduce import functools # map() 函数接受两个参数,一个函数,一个时序列,map将传入的函数依次作用到序列的每一个元素,并将结果作为新的list返回 print("map function list[1,2,3,4,5,6] %s"%(list(map(str, [1,2,3,4,5,6])))) # reduce() 函数把一个函数作用在一个序列【x1,x2,x3】上,这个函数必须接受两个参数,reduce把结果继续和序列的下一个元素做累计计算 print("reduce function ...
07722691892280bb323c38a5469ba6613a4b226f
Chyi341152/pyConPaper
/Concurrency/codeSample/Part10_The_Multiprocessing_Module/countdownp.py
736
3.75
4
#!/usr/bin/env python3 #-*- coding:utf-8 -*- # countdownp.py # Example of launching a process with the multiprocessing module import time import multiprocessing class CountdownProcess(multiprocessing.Process): def __init__(self,count): multiprocessing.Process.__init__(self) self.count = count ...
05663ba4101af5e3b5d00d1fe161918de76545f1
1251024/Workspaces_Python
/Python01/com/test01/control04_break_continue.py
349
3.53125
4
i = 1 while i <= 10: if i > 5: break # break로 종료되는 것은 정상종료 아님 / 중간에 멈춘걸로 됨 print(i) i += 1 else: print('i', i, sep='=') for i in range(1, 10): if i % 2 == 0: continue #마지막까지 for문은 계속 돌고나서 끝남 print(i) else: print('i', i, sep='=')
3df062d10ddff464e32ed814ddd2012dc97d326d
DataKind-DUB/PII_Scanner
/namelist.py
1,231
4.25
4
#!/usr/bin/python3 -i """This file contain functions to transform a list of names text file to a set """ def txt_to_set(filename): """(str) -> set() Convert a text file containing a list of names into a set""" res = set() with open(filename,'r') as f: for line in f: l = line.strip().split() for item in l:...
4187ef5beeac26767fb058f5bf72139bc1b9080a
asadh1/Hangman-py
/hangman.py
2,681
3.8125
4
# -*- coding: utf-8 -*- import os import pwd import random import re # Functions def clear(): '''Clears the shell.''' os.system('cls' if os.name == 'nt' else 'clear') def get_word(file_path): '''Gets words from the file path that was passed in.''' if file_path != None: file = open(file_path) data = f...
8c5a08e09518174db99a2e11485d6b03234543a5
SanderHarbo/Project-1
/project 1 - 2
2,250
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 25 09:51:17 2021 @author: sanderharbo """ class Quiz: def __init__(self, question, correct_answer, answerlist): self.question = question self.answerlist = answerlist self.correct_answer = correct_answer def check_i...
75b38f77dd74d0e5728997510769def657ceca20
JonahTuckman/Bioinformatics-
/BioInformatics/Conditional_Assignment/complex_condition.py
393
4
4
import pandas as pd # Using pandas to read the data because it is great # reading the file data = pd.read_csv('data.csv', header = None) # iterating over the different rows so that I can check the conditions for index, row in data.iterrows(): # checking conditions if (row[2].startswith('k') or row[2].startsw...
f8d553695eb42917846cdfb9a7f8582e64db3fed
tzpBingo/github-trending
/codespace/python/tmp/rolldice.py
391
3.546875
4
""" 掷骰子决定做什么事情 Version: 0.1 Author: 骆昊 Date: 2018-02-28 """ from random import randint face = randint(1, 6) if face == 1: result = '唱首歌' elif face == 2: result = '跳个舞' elif face == 3: result = '学狗叫' elif face == 4: result = '做俯卧撑' elif face == 5: result = '念绕口令' else: result = '讲冷笑话' print(res...
2a5cc7ec62b7b44d49703747101881a56d840775
tzpBingo/github-trending
/codespace/python/tmp/for3.py
191
3.609375
4
""" 输入非负整数n计算n! Version: 0.1 Author: 骆昊 Date: 2018-03-01 """ n = int(input('n = ')) result = 1 for x in range(1, n + 1): result *= x print('%d! = %d' % (n, result))
49c87faa101d18ddc2447014721a91f64fd75007
tzpBingo/github-trending
/codespace/python/tmp/mycal.py
1,173
4
4
#!/usr/bin/python3 from datetime import datetime import sys def is_leap(year): return year % 4 == 0 and year % 100 != 0 or year % 400 == 0 def main(): if len(sys.argv) == 3: month = int(sys.argv[1]) year = int(sys.argv[2]) else: now = datetime.now() date = now.date ...
3cf74ebb8314f8e18775cd5981b4b3e07a87f6c1
tzpBingo/github-trending
/codespace/python/tmp/while2.py
175
3.546875
4
""" 用while循环实现1~100之间的偶数求和 Version: 0.1 Author: 骆昊 Date: 2018-03-01 """ sum, num = 0, 2 while num <= 100: sum += num num += 2 print(sum)
3a3b4e3c401baf6a1a658e0292713e2e65466766
tzpBingo/github-trending
/codespace/python/tmp/for5.py
420
3.5625
4
""" 输入两个正整数计算最大公约数和最小公倍数 Version: 0.1 Author: 骆昊 Date: 2018-03-01 """ x = int(input('x = ')) y = int(input('y = ')) if x > y: (x, y) = (y, x) for factor in range(x, 0, -1): if x % factor == 0 and y % factor == 0: print('%d和%d的最大公约数是%d' % (x, y, factor)) print('%d和%d的最小公倍数是%d' % (x, y, x * y //...
061f34d0ae2055ecaa8c26aaa5ef2d43dcb473cf
tzpBingo/github-trending
/codespace/python/tmp/strings.py
661
4.15625
4
""" 字符串常用操作 Version: 0.1 Author: 骆昊 Date: 2018-02-27 """ str1 = 'hello, world!' print('字符串的长度是:', len(str1)) print('单词首字母大写: ', str1.title()) print('字符串变大写: ', str1.upper()) # str1 = str1.upper() print('字符串是不是大写: ', str1.isupper()) print('字符串是不是以hello开头: ', str1.startswith('hello')) print('字符串是不是以hello结尾: ', str1.end...
ce83b4d1eb0af6275d4df4adf4299bdeee3cadfb
tzpBingo/github-trending
/codespace/python/tmp/verify.py
444
3.71875
4
""" 用户身份验证 Version: 0.1 Author: 骆昊 Date: 2018-02-28 """ # import getpass # from getpass import getpass # from getpass import * username = input('请输入用户名: ') password = input('请输入口令: ') # 输入口令的时候终端中没有回显 # password = getpass.getpass('请输入口令: ') if username == 'admin' and password == '123456': print('身份验证成功!') else: ...
307b9a3b8ac5d9d65ad3c9a834cabab1b51c6c62
tzpBingo/github-trending
/codespace/python/tmp/example16.py
1,731
4.25
4
""" 魔术方法 如果要把自定义对象放到set或者用作dict的键 那么必须要重写__hash__和__eq__两个魔术方法 前者用来计算对象的哈希码,后者用来判断两个对象是否相同 哈希码不同的对象一定是不同的对象,但哈希码相同未必是相同的对象(哈希码冲撞) 所以在哈希码相同的时候还要通过__eq__来判定对象是否相同 """ class Student(): __slots__ = ('stuid', 'name', 'gender') def __init__(self, stuid, name): self.stuid = stuid self.name = name ...
7f32753c7072c81965a441f7a52a3f903e128b61
FachrulCH/ngulik-pytest
/selenium/04_assertion/main.py
621
3.75
4
def is_leap_year(year: int): return year % 400 == 0 or year % 100 != 0 and year % 4 == 0 if __name__ == '__main__': def assert_equal(expected, actual, message): if expected == actual: print(f"{message} returned {actual} as expected") else: print(f"{message} did not retu...
7fc9aedf48a4944e0d4ee056a948fc6aa9f435f0
StarLight312/python-backup
/1.3.4/Jap_1.3.4.py
6,392
3.75
4
from __future__ import print_function # must be first in file import random '''Procedure''' '''Part 1: Nested if structures and testing''' #1 def food_id(food): ''' Returns categorization of food food is a string returns a string of categories ''' # The data fruits = ['apple', 'banana', 'ora...
25bd934b7b8e9ad4c68a8cfbbbc9b8cdfebbdb26
mertcanekiz/Euler
/euler026.py
568
3.515625
4
from euler import timer def decimal_period(n): while n%2 == 0: n //= 2 while n%5 == 0: n //= 5 if n == 1: return 0 result = 1 while True: current = 10**result % n if current == 1: return result result += 1 return result @timer def e...
8cc778ae0aa70ecc76d2d42585dfe6a7cb2e5beb
SimonGideon/Hands_on_python
/Data Structure.py
4,582
3.8125
4
fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana', 'orange'] x = fruits.count('orange') print(x) print(fruits.count('tangerines')) print(fruits.index('banana')) print(fruits.index('banana', 4)) # Find next banana starting at position 4 fruits.reverse() print(fruits) fruits.append('grapes') print...
ceb5babc4ed9b659718168ece85e7b11cba8bfdf
Taller-Python-SEGuach/Leccion7
/Fischer_compute.py
612
3.875
4
def compute_1(a,b): c=(a-40)*(1.5*b) return c def compute_2(b): c=40*b return c def compute_3(a,b): c=a*b return c print("Calculo de ganancia total por horas trabajadas") x=input("ingrese horas trabajadas:") y=input("ingrese ganancia por hora:") try: x=float(x) y=float(y) if x ...
502bd022ef5639f2852c60c9029bf22d8780848c
Taller-Python-SEGuach/Leccion7
/NicolasEspinoza_T1.py
457
3.640625
4
def computepay(horas,pagoprom): if horas <=40 : sueldo = horas*pagoprom if horas >40 : sueldo = pagoprom*40 + (horas-40)*1.5*pagoprom return print("El sueldo que recibes asciende a: " + str(sueldo)) try: x = float(input("Ingrese el número de horas trabajadas semanalmente: ")) y = float(input...
d6fc09eff320d85facc2e54fec2696075bff3af1
ANUSHAVAVILTHOTA/Fiftyfive-Technologies
/prime_between_numbers.py
443
3.59375
4
input_str=input() split_num=[] #splitting numbers word='' for char in input_str: if char ==' ' and word!='': split_num.append(word) word='' else: word+=char if word!='': split_num.append(word) #checking prime or not b/n interval for num in range(int(split_num[0]),int(split_num[1]),1)...
3f3603c193dc0b3e6854d2c4cb9088dc805cc6e5
C-CCM-TC1028-102-2113/tarea-1-programas-que-realizan-calculos-RamsesEscoto
/assignments/21LevaduraParaPizza/src/exercise.py
299
3.625
4
def main(): #escribe tu código abajo de esta línea harinagrm=float(input("Cantidad de harina en gramos: ")) levadura=(harinagrm*50)/1000 levadura=round(levadura,1) print("Necesitas estos gramos de levadura: "+str(levaduragrm)) pass if __name__ == '__main__': main()
ac992a95505637c169c2bb99b71f6f2c0ae12571
crazycracker/Assignment_9.1
/problem_statement_2_2.py
404
3.59375
4
import pandas as pd import numpy as np ''' step 1: creating a dateTimeIndices using date_range step 2: creating a series with date of random numbers using numpy and index as the dateTimeIndices ''' dateTimeIndices = pd.date_range('1/1/2015','31/12/2015') series_of_random_numbers = pd.Series(np.random.randint(0...
44c22aec37805f3931d7dfec3f4445f6f8c66e44
Codewithml/coding-problems-solutions
/arrays/missing-element/missingElement.py
917
3.53125
4
class MissingElement(object): def missingElement(self, arr1, arr2): count = {} for element in arr1: if element in count: count[element] += 1 else: count[element] = 1 for element in arr2: if element in count: ...
ed90f0fc62c11b46bd61c6123873f99ca26208a2
Codewithml/coding-problems-solutions
/sorting/radixSort/testRadixSort.py
640
3.546875
4
import unittest from radixSort import RadixSort class TestRadixSort(unittest.TestCase): def testRadixSort(self): radix_sort = RadixSort() self.assertRaises(TypeError, radix_sort.radixSort, None) self.assertEqual(radix_sort.radixSort([]), []) data = [128, 256, 164, 8, 2, 148, 212...
a17c8ef55b4f028b06275ddaeeb4bfe98a9e009d
Codewithml/coding-problems-solutions
/arrays/fizzbuzz/testFizzBuzz.py
795
3.515625
4
import unittest from fizzbuzz import FizzBuzz class TestFizzBuzz(unittest.TestCase): def fizz_buzz_solution(self): fizzbuzz = FizzBuzz() self.assertRaises(TypeError, fizzbuzz.fizzbuzz, None) self.assertRaises(ValueError, fizzbuzz.fizzbuzz, 0) expected = [ '1', ...
9695163537932ba133a44b1476882f9a6d1b1d3e
Codewithml/coding-problems-solutions
/codewars/7kyu/alphabet_addition.py
262
3.84375
4
def add_letters(*letters): if not letters: return 'z' sum = 0 for i in letters: sum += ord(i) - 96 if sum > 26: sum -= 26 return chr(sum + 96) if __name__ == "__main__": print(add_letters('y', 'c', 'b'))
b5f7593ae080feb1ab60960358925bbf6068b89c
Codewithml/coding-problems-solutions
/cassidoo-newsletter-coding-problems/pizza-slices/pizzaSlices.py
733
3.84375
4
''' Given an array of people objects (where each person has a name and a number of pizza slices they’re hungry for) and a number for the number of slices that the pizza can be sliced into, return the number of pizzas you need to buy. $ arr = [{ name: Joe, num: 9 }, { name: Cami, num: 3 }, { name: Cassidy, num: 4 }] $ ...
af0ebb605369b9bf6bb01a32e834eb05c20300d6
Codewithml/coding-problems-solutions
/codewars/6kyu/iq_test.py
226
3.578125
4
def iq_test(numbers): res = [int(i) % 2 for i in numbers.split()] if res.count(0) > 1: return res.index(1) + 1 else: return res.index(0) + 1 if __name__ == "__main__": print(iq_test("1 2 2"))
32ce06c5d1a10568a1fd41b49a982af5a03f1c8f
Codewithml/coding-problems-solutions
/codewars/7kyu/pattern_complete_1.py
197
3.734375
4
def pattern(n): if n < 1: return "" res = [] for i in range(1, n+1): res.append(f"{i}" * i) return "\n".join(res) if __name__ == "__main__": print(pattern(3))
a31bbb5eaea549cb821c97c3d29b024d79105276
Codewithml/coding-problems-solutions
/sorting/bubbleSort/bubbleSort.py
501
3.828125
4
class BubbleSort(object): def bubbleSort(self, data): if data is None: raise TypeError("can't be none") if len(data) < 2: return data for i in range(len(data)): swapped = False for j in range(len(data) - 1): if data[j] > data[j...
a04f566705183933f4db84e69a0c3eb9ac8ae3c1
jucaazevedo/estudo_python
/for_else.py
250
3.53125
4
def testa_for_elses(): a = [10, 20, 30] for i in a: if i==21: break print(i) else: print("saiu 1") a = [] for i in a: print(i) else: print("saiu 2") testa_for_elses()
83fe5da33ca4fcde575cb38e9dfb09d635f60ffa
jucaazevedo/estudo_python
/tela.py
158
3.78125
4
print("Escolha um jogo:") print("1 - taboada") print("2 - jogo da velha") g = int(input()) if (g == 1): print("jogo taboada") else: print("jogo da velha")
3d32a66b37341705c302d065f055f319f13782e2
mchen06/2021_Summer_Projects
/2021_cube_loop.py
135
4.15625
4
cube = input("pick a number: ") cube = int(cube) cube = cube + 1 x = 0 for i in range(1, cube): i = i**3 x = x + i print(x)
9a049b0cd58d5c48f564591f9edb5ff6b19e1ae9
Ishita46/PRO-C97-NUMBER-GUESSING-GAME
/gg.py
551
4.25
4
import random print("Number Guessing Game") Number = random.randint(1,9) chances = 0 print("Guess a number between 1-9") while chances < 5: guess = int(input("Enter your guess")) if guess == Number: print("Congratulations you won!") break elif guess < Number: print("Yo...
6a5978e6ed1829a5c24c4e70dad26ab980c83203
BramvdnHeuvel/AdventOfCode2018
/day_01/ex1_sum.py
164
3.703125
4
open_file = open('input.txt', 'r') sum = 0 for line in open_file: number = line.split('\n')[0] number = int(number) sum += number print(sum)
53efd6ab468025b2730a6e8efcef869d915516fd
RohanSahana/pythonprogram
/Demonstration of Basic Euclidean Algorithm.py
329
3.765625
4
# To demonstrate Basic Euclidean Algorithm def gcd(a, b): if a == 0 : return b return gcd(b%a, a) a = 55 b = 20 print("gcd(", a , "," , b, ") = ", gcd(a, b)) c = 94 d = 6 print("gcd(", c , "," , d, ") = ", gcd(a, b)) e = 34 f = 69 print("gcd(", e , "," , f, ") = ", gc...
460ff6fdd960c041d1c9b7744bd451dce1db90af
virgax7/ProjectEuler
/src/questions-41-60/q46.py
811
3.859375
4
# It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. # # 9 = 7 + 2×1^2 # 15 = 7 + 2×2^2 # 21 = 3 + 2×3^2 # 25 = 7 + 2×3^2 # 27 = 19 + 2×2^2 # 33 = 31 + 2×1^2 # # It turns out that the conjecture was false. # # What is the smallest odd composite...
6244a947d384462fd95f75b24eaba45735128991
virgax7/ProjectEuler
/src/questions-41-60/q45.py
658
3.625
4
# triangle, pentagonal, and hexagonal numbers are generated by the following formulae: # # triangle tn=n(n+1)/2 1, 3, 6, 10, 15, ... # pentagonal pn=n(3n−1)/2 1, 5, 12, 22, 35, ... # hexagonal hn=n(2n−1) 1, 6, 15, 28, 45, ... # it can be verified that t285 = p165 = h143 = 40755. # # find the next triangle n...