blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
35f60514ec8786b329995344a6bc3e838c3eb046
ChWeiking/PythonTutorial
/Python基础/day11(继承、多态、类属性、类方法、静态方法)/demo/01_继承/02_覆盖重写.py
2,862
4.34375
4
''' 子类和父类都有相同的属性、方法 子类对象在调用的时候,会覆盖父类的,调用子类的 与参数无关,只看名字 覆盖、重写: 扩展功能 ''' class Fu(object): def __init__(self): print('init1...') self.num = 20 def sayHello(self): print("halou-----1") class Zi(Fu): def __init__(self): print('init2...') self.num = 200 def sayHello(self): print("halou-----2") ...
false
28624d6b4fe400671cec84c3b57ff5948db2a323
ChWeiking/PythonTutorial
/Python高级/day38(算法)/demo/02_二叉树_广度优先.py
2,028
4.1875
4
class MyQueue(object): """队列""" def __init__(self): self.items = [] def is_empty(self): return self.items == [] def enqueue(self, item): self.items.insert(0,item) def dequeue(self): """出队列""" return self.items.pop() def size(self): """返回大小""" ...
false
46a4b5fac21253cff9e24012c4c6a5d1053f65f0
ChWeiking/PythonTutorial
/Python基础/day05(集合容器、for循环)/demo/02_tuple/01_tuple.py
555
4.28125
4
''' 元组:是用小括号的 ''' directions = ('东','西','南','北','中') print(directions) print(directions[1]) print('*'*20) t1 = (1,2,3) #t1[0]=2 t2 = ([1,2,3],110,'120',(1,2,3)) t2[0].append(110) print(t2) ''' 列表和元组相互转换 ls = list(元组) tu = tuple(列表) ''' ls = [1,2,3] print(type(ls)) print(ls) tu = tuple(ls) print(type(tu)) pr...
false
251b26428c895b27abb3e0db7ff0316e5bc8a7e1
Filjo0/PythonProjects
/Ch3.py
2,197
4.25
4
""" Chapter 3. 11. In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are lots of ways to win: (1, 6), (2, 5), and so on. A little mathematical analysis re...
true
3cd6ff12af16a6a3d672cad425a9df0d398cedb1
lslewis1/Python-Labs
/Week 5 Py Labs/Seconds converter.py
747
4.21875
4
#10/1/14 #This program will take a user input of a number of seconds. #The program will then display how many full minutes, hours, days, and leftover seconds there are #ts is the input of seconds #s1 is the leftover seconds for the minutes #s2 is the seconds for hours #s3 is the seconds for days #m is the numb...
true
c46d80d326ba0b65ca97c0679faa2e50aa384371
lslewis1/Python-Labs
/Week 5 Py Labs/BMI.py
530
4.34375
4
#10/1/14 #This program will determine a person's BMI #Then it will display wheter the person in optimal weight, over, or under #bmi is the body mass indicator #w is the weight #h is the height w=float(input("Enter your weight in pounds :")) h=float(input("Enter your height in inches :")) bmi=(w*703)/(h*h) ...
true
f22d1886a08da98b613d9ed89432a39d47679830
lslewis1/Python-Labs
/Week 6 Py Labs/calories burned.py
327
4.125
4
#10/6/14 #This program will use a loop to display the number of calories burned after time. #The times are: 10,15,20,25, and 30 minutes #i controls the while loop #cb is calories burned #m is minutes i=10 while i<=30: m=i cb=m*3.9 i=i+5 print(cb,"Calories burned for running for", m,"minut...
true
29260166c31c491e47c68e1674e384bc56c6a2d5
lslewis1/Python-Labs
/Week 8 Py Labs/Temperature converter.py
919
4.4375
4
#10/20/14 #This program will utilize a for loop to convert a given temperature. #The conversion will be between celsius and fahrenheit based on user input. ch=int(input("Enter a 1 for celsuis to fahrenheit, or a 2 for fahrenheit to celsius: ")) if ch==1: start=int(input("Please enter your start value: ")) ...
true
d31c472acb56ddda5e696e10c957d3d85cf88220
lslewis1/Python-Labs
/Week 4 Py Labs/Letter grade graded lab.py
536
4.375
4
#9/26/14 #This program will display a student's grade. #The prgram will print a letter grade after receiving the numerical grade #Grade is the numerical grade #Letter is the letter grade Grade=float(input("Please enter your numerical grade :")) if Grade>=90: print("Your letter grade is an A.") elif Grad...
true
7f0bcddba963482972f1c6b2e9d6d9688cf5cee6
samanta-antonio/python_basics
/fizz.py
283
4.21875
4
#Receba um número inteiro na entrada e imprima Fizz se o número for divisível por 3. Caso contrário, imprima o mesmo número que foi dado na entrada. numero = int(input("Digite um número: ")) resto = (numero % 3) if resto == 0: print("Fizz") else: print(numero)
false
6b6bee3144bce48f71c9eb02c574d7540f0f42da
aaqibgouher/python
/numpy_random/generate_rn.py
815
4.34375
4
from numpy import random # 1. for random integer till 100. also second parameter is size means how much you wanna generate # num_1 = random.randint(100) #should give the last value # print(num_1) # 2. for random int array : # num = random.randint(100,size=10) # print(num) # 3. for random float ; # num_2 = ra...
true
962557880d2b679913ac49c86658aa8e5bb1205d
aaqibgouher/python
/numpy_eg/vector/summation.py
995
4.21875
4
import numpy as np # 1. simple add element wise # arr_1 = np.array([1,2,3,4,5]) # arr_2 = np.array([1,2,3,4,5]) # print(np.add(arr_1,arr_2)) # 2. summation - first it will sum the arr_1,arr_2 and arr_3 individually and then sum it at once and will give the output. also axis means it will sum and give the output in on...
true
cc22a9186c232e9b318940858ad2f0757b6ae77a
GHubgenius/DevSevOps
/2.python/0.python基础/day13/代码/7 匿名函数.py
659
4.25
4
''' 匿名函数: 无名字的函数 # :左边是参数, 右边是返回值 lambda : PS: 原因,因为没有名字,函数的调用 函数名 + () 匿名函数需要一次性使用。 注意: 匿名函数单独使用毫无意义,它必须配合 “内置函数” 一起使用的才有意义。 有名函数: 有名字的函数 ''' # 有名函数 def func(): return 1 print(func()) # func函数对象 + () print(func()) # 匿名函数: # def (): # pass # # () # + () # 匿名(), return 已经...
false
45511470c4e3732cb408a609b81daf21b0567553
GHubgenius/DevSevOps
/2.python/0.python基础/day13/代码/8 内置函数.py
1,042
4.21875
4
''' 内置函数: range() print() len() # python内部提供的内置方法 max, min, sorted, map, filter sorted: 对可迭代对象进行排序 ''' # max求最大值 max(可迭代对象) # list1 = [1, 2, 3, 4, 5] # max内部会将list1中的通过for取出每一个值,并且进行判断 # print(max(list1)) # # dict1 = { # 'tank': 1000, # 'egon': 500, # 'sean': 200, # 'jason'...
false
a7f71f51a443042364a36a82503ab431e29394a8
GHubgenius/DevSevOps
/2.python/0.python基础/day10/代码/02 函数的嵌套.py
551
4.15625
4
# 函数的嵌套调用:在函数内调用函数 # def index(): # print('from index') # # # def func(): # index() # print('from func') # # # func() # def func1(x, y): # if x > y: # return x # else: # return y # print(func1(1,2)) # def func2(x, y, z, a): # result = func1(x, y) # result = func1(result...
false
07923c14b2d3cc7e14a49c0eaff1e20d8769b7cb
Jonaugustin/MyContactsAssignment
/main.py
2,408
4.34375
4
contacts = [["John", 311, "noemail@email.com"], ["Robert", 966, "uisemali@email.com"], ["Edward", 346, "nonumber@email.ca"]] menu = """ Main Menu 1. Display All Contacts Names 2. Search Contacts 3. Edit Contact 4. New Contact 5. Remove Contact 6. Exit """ def displayContact(): if contacts: pr...
true
7e46a856a34046e99f4353318d1cc9bf787973b2
lukejskim/sba19-seoulit
/Sect-A/source/sect07_class/s720_gen_object.py
255
4.125
4
# 클래스 정의 class MyClass: name = str() def sayHello(self): hello = "Hello, " + self.name + "\t It's Good day !" print(hello) # 객체 생성, 인스턴스화 myClass = MyClass() myClass.name = '준영' myClass.sayHello()
false
57d9d25fe134eff49886a76ba6d8ea91f9498073
nikhilpatil29/AlgoProgram
/algo/MenuDriven.py
2,442
4.125
4
''' Purpose: Program to perform all sorting operation like insertion,bubble etc @author Nikhil Patil ''' from utility import * class MenuDriven: x = utility() choice = 0 while 1: print "Menu : " print "1. binarySearch method for integer" print "2. binarySearch method for String...
true
953f3587f7cba8d48585a093ce5e0c8e2942d35f
noite-m/nlp2020
/chart1/practice09.py
1,876
4.125
4
''' スペースで区切られた単語列に対して,各単語の先頭と末尾の文字は残し, それ以外の文字の順序をランダムに並び替えるプログラムを作成せよ. ただし,長さが4以下の単語は並び替えないこととする. 適当な英語の文 (例えば”I couldn’t believe that I could actually understand what I was reading : the phenomenal power of the human mind .”) を与え,その実行結果を確認せよ. ''' import random ''' ランダムに複数の要素を選択(重複なし): random.sample() randomモジュールの関数s...
false
cbfa94e5ab45819bb1dd9ee3834ec98d1b826911
webfarer/python_by_example
/Chapter2/016.py
317
4.125
4
user_rainy = str.lower(input("Tell me pls - is a rainy: ")) if user_rainy == 'yes': user_umbrella = str.lower(input("It is too windy for an umbrella?: ")) if user_umbrella == 'yes': print("It is too windy for an umbrella") else: print("Take an umbrella") else: print("Enjoy your day")
true
fe3b3b55e4d537cab59c9c4943361b4714eabf64
afeldman/sternzeit
/year/year.py
2,904
4.78125
5
#!/usr/bin/env python3 def is_leap_year(year): """ if the given year is a leap year, then return true else return false :param year: The year to check if it is a leap year :returns: It is a Leap leap year (yes or no). """ return (year % 100 == 0) if (year % 400 == 0) else (year % 4 == 0) ...
false
126ba2113fe13cb7a8008b772793718001df3c94
KacperKubara/USAIS_Workshops
/Clustering/k-means.py
1,734
4.1875
4
# K-NN classification with k-fold cross validation import pandas as pd import numpy as np import matplotlib.pyplot as plt # Read Data dataset = pd.read_csv("Mall_Customers.csv") # Choose which features to use x = dataset.iloc[:, 3:5].values # Features - Age, annual income (k$) """ K-Means clustering is unsupervise...
true
f0749405938e25a640b1955262887d8e5924397a
betty29/code-1
/recipes/Python/52316_Dialect_for_sort_by_then_by/recipe-52316.py
1,587
4.15625
4
import string star_list = ['Elizabeth Taylor', 'Bette Davis', 'Hugh Grant', 'C. Grant'] star_list.sort(lambda x,y: ( cmp(string.split(x)[-1], string.split(y)[-1]) or # Sort by last name ... cmp(x, y))) # ... then by first name print...
true
da7d9b543243c19783719c409b67347ce4b126a3
betty29/code-1
/recipes/Python/304440_Sorting_dictionaries_value/recipe-304440.py
843
4.21875
4
# Example from PEP 265 - Sorting Dictionaries By Value # Counting occurences of letters d = {'a':2, 'b':23, 'c':5, 'd':17, 'e':1} # operator.itemgetter is new in Python 2.4 # `itemgetter(index)(container)` is equivalent to `container[index]` from operator import itemgetter # Items sorted by key # The new built...
true
809a2e466bf5784e776a0249cf43460147cb14e0
betty29/code-1
/recipes/Python/578935_Garden_Requirements_Calculator/recipe-578935.py
2,723
4.21875
4
''' 9-16-2014 Ethan D. Hann Garden Requirements Calculator ''' import math #This program will take input from the user to determine the amount of gardening materials needed print("Garden Requirements Calculator") print("ALL UNITS ENTERED ARE ASSUMED TO BE IN FEET") print("____________________________________________...
true
e2f6af7d70e34e1fd89e1239bcbac0709810dc25
betty29/code-1
/recipes/Python/577344_Maclaurinsseriescos2x/recipe-577344.py
1,458
4.15625
4
#On the name of ALLAH and may the blessing and peace of Allah #be upon the Messenger of Allah Mohamed Salla Allahu Aliahi Wassalam. #Author : Fouad Teniou #Date : 03/008/10 #version :2.6 """ maclaurin_cos_2x is a function to compute cos(x) using maclaurin series and the interval of convergence is -inf < x < +inf cos...
true
a752a877f7aa023a64622cb406d86f9655133808
betty29/code-1
/recipes/Python/577345_Maclaurinsseriescos_x/recipe-577345.py
1,429
4.21875
4
#On the name of ALLAH and may the blessing and peace of Allah #be upon the Messenger of Allah Mohamed Salla Allahu Aliahi Wassalam. #Author : Fouad Teniou #Date : 03/08/10 #version :2.6 """ maclaurin_cos_pow2 is a function to compute cos(x) using maclaurin series and the interval of convergence is -inf < x < +inf co...
true
a5431bb48049aa784132d0a08a866223d580d2d4
betty29/code-1
/recipes/Python/577574_PythInfinite_Rotations/recipe-577574.py
2,497
4.28125
4
from itertools import * from collections import deque # First a naive approach. At each generation we pop the first element and append # it to the back. This is highly memmory deficient. def rotations(it): """ rotations([0,1,2]) --> [[0, 1, 2], [1, 2, 0], [2, 0, 1]] """ l = list(it) for i in range(len(l)):...
true
d821b07149089dba24a238c3ad83d5c8b6642fd6
betty29/code-1
/recipes/Python/577965_Sieve_Eratosthenes_Prime/recipe-577965.py
986
4.34375
4
def primeSieve(x): ''' Generates a list of odd integers from 3 until input, and crosses out all multiples of each number in the list. Usage: primeSieve(number) -- Finds all prime numbers up until number. Returns: list of prime integers (obviously). Time: around 1.5 seco...
true
849e48eba0db9689f82e2c23ec9d9ae777c78a54
betty29/code-1
/recipes/Python/466321_recursive_sorting/recipe-466321.py
443
4.25
4
""" recursive sort """ def rec_sort(iterable): # if iterable is a mutable sequence type # sort it try: iterable.sort() # if it isn't return item except: return iterable # loop inside sequence items for pos,item in enumerate(iterable): iterable[pos] = rec_sort(item) ...
true
25fc1d2d9fe540cc5e2994ac04c875cb40df2f8c
betty29/code-1
/recipes/Python/334695_PivotCrosstabDenormalizatiNormalized/recipe-334695.py
2,599
4.40625
4
def pivot(table, left, top, value): """ Creates a cross-tab or pivot table from a normalised input table. Use this function to 'denormalize' a table of normalized records. * The table argument can be a list of dictionaries or a Table object. (http://aspn.activestate.com/ASPN/Cookbook/Python/Rec...
true
a2e8e4bc7ec3c702eca1668891cfe72ea1a70113
betty29/code-1
/recipes/Python/502260_Parseline_break_text_line_informatted/recipe-502260.py
1,089
4.1875
4
def parseline(line,format): """\ Given a line (a string actually) and a short string telling how to format it, return a list of python objects that result. The format string maps words (as split by line.split()) into python code: x -> Nothing; skip this word s -> Return this word ...
true
486e319264ee6470f902c3dd3240f614d06dff83
betty29/code-1
/recipes/Python/498090_Finding_value_passed_particular_parameter/recipe-498090.py
1,180
4.125
4
import inspect def get_arg_value(func, argname, args, kwargs): """ This function is meant to be used inside decorators, when you want to find what value will be available inside a wrapped function for a particular argument name. It handles positional and keyword arguments and takes into account d...
true
f15d9fdb5bd40bfa44342919598f3df07340b086
J-Cook-jr/python-dictionaries
/hotel.py
334
4.125
4
# This program creates a dictionary of hotel rooms and it's occupants. # Create a dictionary that lists the room number and it's occupants. earlton_hotel ={ "Room 101" : "Harley Cook", "Room 102" : "Mildred Tatum", "Room 103" : "Jewel Cook", "Room 104" : "Tiffany Waters", "Room 105" : "Dejon Waters...
true
bf44d7003cfce950a3002a4bb62d4a91e5d6f0a8
cczhouhaha/data_structure
/1016堆,优先队列/堆heap.py
2,352
4.1875
4
#堆是完全二叉树,又分为最大堆(根>左右孩子)和最小堆(根<左右孩子) class Heap: def __init__(self): self.data_list = [] #用数组实现 # 得到父节点的下标 def get_parent_index(self,index): if index < 0 or index >= len(self.data_list): raise IndexError("The index out of range") else: return (index-1) >> 1 ...
false
f74e3aaff1778023fc4d7180c9c3e7a96cd871ee
MatthewGerges/CS50-Programming-Projects
/MatthewGerges-cs50-problems-2021-x-sentimental-readability/readability.py
2,780
4.125
4
from cs50 import get_string # import the get_string function from cs50's library def main(): # prompt the user to enter a piece of text (a paragraph/ excerpt) paragraph1 = get_string("Text: ") letters = count_letters(paragraph1) # the return value of count_letters (how many letters there are in a...
true
602ea8ecddf9d0747115b17773236b33780a8507
TTUSDC/practical-python-sdc
/Week 1/notes/testing.py
1,407
4.1875
4
print("Hello World") pizza = 3 print(pizza) pizza = 3.3 print(pizza) pizza = "i like pizza" print(pizza) pizza = 333333333333 print(pizza) # + - / ** * // % x = 3 y = 5 print(x - y) print(x + y) print(x // y) print(x * y) print(x ** y) print(30 % 11) # True, False # and, or, is, not print(True is True) print(Tru...
false
fa4348c886de9e98fee1878c424aab1ebe8e448e
marina-h/lab-helpers
/primer_helper.py
813
4.15625
4
#!/usr/bin/env python # -*- coding: utf8 -*- import readline reverse_comp_dict = {'A':'T', 'T':'A','G':'C', 'C':'G'} def melting_temp(p): Tm = 0 for n in p: if n == 'A' or n == 'T': Tm += 2 if n == 'G' or n == 'C': Tm += 4 return Tm def reverse_comp(p): reverse = "" for n in p[::-1]: reverse += re...
false
ae6a511723cc0f54dc39d56b2c9ed70ed3bb9305
lnbe10/Math-Thinking-for-Comp-Sci
/combinatory_analysis/dice-game.py
2,755
4.1875
4
# dice game: # a shady person has various dices in a table # the dices can have arbitrary values in their # sides, like: # [1,1,3,3,6,6] # [1,2,3,4,5,6] # [9,9,9,9,9,1] # The shady person lets you see the dices # and tell if you want to choose yor dice before # or after him # after both of you choose, # them roll your ...
true
a60df60f1bd19896da30e8d46be5fee3a020413c
battyone/Practical-Computational-Thinking-with-Python
/ch4_orOperator.py
220
4.125
4
A = True B = False C = A and B D = A or B if C == True: print("A and B is True.") else: print("A and B is False.") if D == True: print("A or B is True.") else: print("A or B is False.")
true
1c9483e36d864bd7a8f5722f60801cda7e6c521f
tx621615/pythonlearning
/02tab.py
223
4.15625
4
# 测试缩进,python中没有大括号,通过相同的缩进表示同一个代码块 if True: print("Answer") print("True") else: print("Answer") print("False") # 缩进不同则不在同一个块中
false
255c09b29bc9cd76e730a64a0722d24b003297c8
ugneokmanaite/api_json
/json_exchange_rates.py
1,068
4.3125
4
import json # create a class Exchange Rates class ExchangeRates: # with required attributes def __init__(self): pass # method to return the exchange rates def fetch_ExchangeRates(self): with open("exchange_rates.json", "r") as jsonfile: dataset = json.load(jsonfile) ...
true
9445b358d4c35b1caec4c3bc2620b47ef514d331
MathewsPeter/PythonProjects
/biodata_validater.py
1,124
4.5625
5
'''Example: What is your name? If the user enters * you prompt them that the input is wrong, and ask them to enter a valid name. At the end you print a summary that looks like this: - Name: John Doe - Date of birth: Jan 1, 1954 - Address: 24 fifth Ave, NY - Personal goals: To be the best programmer there ever was. ''...
true
f105606ceb0d3a72e2d35e88a78952fed10f38a7
MathewsPeter/PythonProjects
/bitCountPosnSet.py
408
4.15625
4
''' input a 8bit Number count the number of 1s in it's binary representation consider that as a number, swap the bit at that position ''' n = (int)(input("enter a number between [0,127] both inclusive")) if n<0 or n>127: print("enter properly") else: n_1= n c = 0 while n: if n&0b1: ...
true
3966d55212271c1a681156beaee25f6820a076fc
zsamantha/coding_challenge
/calc.py
1,217
4.125
4
import math print("Welcome to the Calculator App") print("The following operations are available: + - / *") print("Please separate entries with a space. Ex: Use 1 + 2 instead of 1+2") print("Type \"Q\" to quit the program.") result = None op = None while(True): calc = input().strip().split() if calc[0].lower...
true
31d0b19e04fce106e14c19aec9d7d6f463f0d852
panchaly75/MyCaptain_AI
/AI_MyCaptainApp_03(1).py
863
4.3125
4
#Write a Python Program for Fibonacci numbers. def fibo(input_number): fibonacci_ls=[] for count_term in range(input_number): if count_term==0: fibonacci_ls.append(0) elif count_term==1: fibonacci_ls.append(1) else: fibonacci_ls.append(fibonacci_ls[count_term-2]+fibonacci_ls[count_ter...
true
ebb169123be03b88cdd6dcfab33657bd4a60f573
Devlin1834/Games
/collatz.py
1,792
4.15625
4
## Collatz Sequence ## Idea from Al Sweigart's 'Automate the Boring Stuff' def collatz(): global over over = False print("Lets Explore the Collatz Sequence") print("Often called the simplest impossible math problem,") print("the premise is simple, but the results are confusing!") print("Lets s...
true
26a77eaf507d1b0107e311ee09706bc352e70ced
ScottG489/Task-Organizer
/src/task/task.py
2,528
4.125
4
"""Create task objects Public classes: Task TaskCreator Provides ways to instantiate a Task instance. """ from textwrap import dedent # TODO: Should this be private if TaskCreator is to be the only # correct way to make a Task instance? class Task(): """Instantiate a Task object. Provides att...
true
3ac26042891246dead71c85f0fd59f5f7316a516
akhilpgvr/HackerRank
/iterative_factorial.py
408
4.25
4
''' Write a iterative Python function to print the factorial of a number n (ie, returns n!). ''' usersnumber = int(input("Enter the number: ")) def fact(number): result = 1 for i in range(1,usersnumber+1): result *= i return result if usersnumber == 0: print('1') elif usersnumber < 0: print(...
true
a412e958ac2c18dd757f6b5a3e91fd897eda6658
akhilpgvr/HackerRank
/fuzzbuzz.py
435
4.1875
4
''' Write a Python program to print numbers from 1 to 100 except for multiples of 3 for which you should print "fuzz" instead, for multiples of 5 you should print 'buzz' instead and for multiples of both 3 and 5, you should print 'fuzzbuzz' instead. ''' for i in xrange(1,101): if i % 15 == 0: print 'fuzzb...
true
0cacf9f1b270d2814847c7d4091de5592bc47bad
SherriChuah/google-code-sample
/python/src/playlists.py
1,501
4.1875
4
"""A playlists class.""" """Keeps the individual video playlist""" from .video_playlist import VideoPlaylist class Playlists: """A class used to represent a Playlists containing video playlists""" def __init__(self): self._playlist = {} def number_of_playlists(self): return len(self._playlist) def get_all_p...
true
861ada8af86a6060dfc173d19e0364e2132a447e
DataActivator/Python3tutorials
/Decisioncontrol-Loop/whileloop.py
944
4.21875
4
''' A while loop implements the repeated execution of code based on a given Boolean condition. while [a condition is True]: [do something] As opposed to for loops that execute a certain number of times, while loops are conditionally based so you don’t need to know how many times to repeat the code going in. ''' ...
true
7646890051144b6315cd22fd1b5e04a44d9b266a
jabedude/python-class
/projects/week3/jabraham_guessing.py
1,625
4.1875
4
#!/usr/bin/env python3 ''' This program is an implementation of the "High-Low Guessing Game". The user is prompted to guess a number from 1 to 100 and the program will tell the user if the number is greater, lesser, or equal to the correct number. ''' from random import randint def main(): ''' This function i...
true
fcdebbb78ba2d4c5b41967801b0d537c35e85c3a
jabedude/python-class
/chapter5/ex6.py
384
4.125
4
#!/usr/bin/env python3 def common_elements(list_one, list_two): ''' returns a list of common elements between list_one and list_two ''' set_one = set(list_one) set_two = set(list_two) return list(set_one.intersection(set_two)) test_list = ['a', 'b', 'c', 'd', 'e'] test_list2 = ['c', 'd', 'e', 'f', ...
true
53c1ca380af737aabe9ce0e265b18011a3e290a2
jabedude/python-class
/chapter9/ex4.py
655
4.3125
4
#!/usr/bin/env python3 ''' Code for exercise 4 chapter 9 ''' import sys def main(): ''' Function asks user for two file names and copies the first to the second ''' if len(sys.argv) == 3: in_name = sys.argv[1] out_name = sys.argv[2] else: in_name = input("Enter the name of ...
true
c722a49a7f8b4b80ed4238b53759e922299957e2
jabedude/python-class
/chapter7/restaurant.py
1,686
4.21875
4
#!/usr/bin/env python3 class Category(): ''' Class represents Category objects. Only has a name ''' def __init__(self, name): self.name = name @property def name(self): return self._name @name.setter def name(self, name): self._name = name def __str__(self): ...
false
9e3dac800bd632b85beb9c905687e1141547732c
UlisesND/CYPUlisesND
/listas2.py
1,361
4.40625
4
# arreglos #lectura #escritura/ asignacion #actualizacion: insercion, eliminacion, modificacion #busqueda #escritura frutas = ["Zapote", "Manzana" , "Pera", "Aguaquate", "Durazno", "uva", "sandia"] #lectura, el selector [indice] print (frutas[2]) # Lectura con for #for opcion 1 for indice in range (0,7,1): print ...
false
ed544f53a3a328aff0bdd1246a7a1db33867589c
Dulal-12/Python-basic-300
/50+/Test6.py
202
4.15625
4
#Find BMI height = float(input("Enter height ft(foot) : ")) weight = float(input("Enter weight Kg : ")) height = (height*12*2.54)/100 BMI = round(weight/height**2) print(f'Your BMI is {BMI} KGM^2')
false
4bfff67203f0ab60a696bdb49cbc00de7db79767
govindak-umd/Data_Structures_Practice
/LinkedLists/singly_linked_list.py
2,864
4.46875
4
""" The code demonstrates how to write a code for defining a singly linked list """ # Creating a Node Class class Node: # Initialize every node in the LinkedList with a data def __init__(self, data): # Each of the data will be stored as self.data = data # This is very important becaus...
true
dc8e36cdd048bcff0c3bfaa69c71923fd53ec7bc
pgrandhi/pythoncode
/Assignment2/2.VolumeOfCylinder.py
367
4.15625
4
#Prompt the use to enter radius and length radius,length = map(float, input("Enter the radius and length of a cylinder:").split(",")) #constant PI = 3.1417 def volumeOfCylinder(radius,length): area = PI * (radius ** 2) volume = area * length print("The area is ", round(area,4), " The volume is ", round(vo...
true
670e2caa200e7b81c4c67abe0e8db28c9d3bce5d
pgrandhi/pythoncode
/Class/BMICalculator.py
584
4.3125
4
#Prompt the user for weight in lbs weight = eval(input("Enter weight in pounds:")) #Prompt the user for height in in height = eval(input("Enter height in inches:")) KILOGRAMS_PER_POUND = 0.45359237 METERS_PER_INCH = 0.0254 weightInKg = KILOGRAMS_PER_POUND * weight heightInMeters = METERS_PER_INCH * height #Compute ...
true
7b8241125841ad4f17077ed706af394576f6a0dc
briand27/LPTHW-Exercises
/ex20.py
1,172
4.15625
4
# imports System from sys import argv # creates variables script and input_file for arguments script, input_file = argv # define a function that takes in a file to read def print_all(f): print f.read() # define a function that takes in a file to seek def rewind(f): f.seek(0) # defines a function that prints...
true
38aa94d68254fe0903e6eb1de10d10c23eab47b6
mlbudda/Checkio
/home/sort_by_frequency.py
542
4.34375
4
# Sort Array by Element Frequency def frequency_sort(items): """ Sorts elements by decreasing frequency order """ return sorted(items, key=lambda x: (-items.count(x), items.index(x))) # Running some tests.. print(list(frequency_sort([4, 6, 2, 2, 6, 4, 4, 4])) == [4, 4, 4, 4, 6, 6, 2, 2]) print(list(frequency_...
false
03389bd8ab6b7f1a14d681c6f209c264e2e27aad
mlbudda/Checkio
/o_reilly/index_power.py
440
4.15625
4
# Index Power def index_power(array: list, n: int) -> int: """ Find Nth power of the element with index N. """ try: return array[n] ** n except IndexError: return -1 # Running some tests.. print(index_power([1, 2, 3, 4], 2) == 9, "Square") print(index_power([1, 3, 10, 100], 3)...
true
473d7d7500ffc160f056d661b0ef8a1d297a84a7
mnsupreme/artificial_intelligence_learning
/normal_equation.py
2,911
4.3125
4
#This code solves for the optimum values of the parameters analytically using calculus. # It is an alternative way to optimizing iterarively using gradient descent. It is usually faster # but is much more computationally expensive. It is good if you have 1000 or less parameters to solve for. # complexity is O(n^3) # ...
true
ef2fb36ea0588d36aa6b49ad55d57ee4a5d64bc0
dguest/example-text-parser
/look.py
1,851
4.15625
4
#!/usr/bin/env python3 import sys from collections import Counter from csv import reader def run(): input_name = sys.argv[1] csv = reader(open(input_name), skipinitialspace=True) # first read off the titles titles = next(csv) indices = {name:number for number, name in enumerate(titles)} # ke...
true
21ebaf035e0a5bda9b9836a8c77221f20c9f4388
timomak/CS-1.3
/First try 😭/redact_problem.py
692
4.21875
4
def reduct_words(given_array1=[], given_array2=[]): """ Takes 2 arrays. Returns an array with the words from the first array, that were not present in the second array. """ output_array = [] # Array that is gonna be returned for word in given_array1: # For each item in the first array, ...
true
5f21ab9fdf6d7bab8a4572054ca007bc62db42d8
Win-Victor/algs
/algs_2_t8.py
835
4.1875
4
"""8. Посчитать, сколько раз встречается определенная цифра в введенной последовательности чисел. Количество вводимых чисел и цифра, которую необходимо посчитать, задаются вводом с клавиатуры.""" num = input('Введите цифру для подсчета в наборе чисел:\n') count = int(input('Укажите сколько наборов чисел Вы будете ввод...
false
dfa668f57584dc42dbc99c5835ebc0a5c0b1e0cd
avir100/ConsultAdd
/task2/task2_10.py
815
4.125
4
from random import randint ''' Write a program that asks five times to guess the lucky number. Use a while loop and a counter, such as counter=1 While counter <= 5: print(“Type in the”, counter, “number” counter=counter+1 The program asks for five guesses (no matter whether the correct number was ...
true
0386d42dfae2e6489d916e10af178dd42a31cf26
TimeMachine00/pythonProject-4
/Chose-rock-paper-scissor.py
871
4.21875
4
print("created by hussainatphysics@gmail.com(hussainsha syed)") print("welcome to the game") rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = '...
false
8fdb362aa4fb0de01b740a5a840904bf329b5f22
lzeeorno/Python-practice175
/terminal&py.py
696
4.125
4
#how to use python in terminal def main(): while True: s = input('do you come to learn how to open py doc in terminal?(yes/no):') if s.lower() == 'yes': print('cd use to enter doc, ls to look the all file, python filename.py to open the py document') s1 = input('do you unders...
true
14a84fdbc18ce604fc44ae7faff93686e7622761
Degureshaff/python.itc
/python/day17/def_1.py
447
4.15625
4
def calculator(num1, num2, suff): if suff == '*': print(num1 * sum2) elif suff == '/': print(num1 / num2) elif suff == '**': print(num1 ** num2) elif suff == '+': print(num1 + num2) elif suff == '-': print(num1 - num2) num1 = int(input('Число 1: ')) num2 = in...
false
94e971d062803bda0dbee06307607932b0654849
zongrh/untitled_python
/test02.py
1,008
4.15625
4
# coding=utf-8 print("hello world") print "你好,世界!"; counter = 100 # 赋值整型变量 miles = 1000.0 # 浮点型 name = "john" # 字符串 print counter print miles print name # -----------------------------标准数据类型 # Numbers(数字) # String(字符串) # List(列表) # Tuple(元组) # Dictionary(字典) # -------------------------------Python数字 var1 = 1 var...
false
4f21735e9b85b9072567a6aa2df7d17ac121f39c
Leahxuliu/Data-Structure-And-Algorithm
/Python/Binary Search/33.Search in Rotated Sorted Array.py
1,766
4.28125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # @Time : 2020/03/26 # @Author : XU Liu # @FileName: 33.Search in Rotated Sorted Array.py ''' 1. 题目理解: 找到目标值 给到的arr是部分sort,都是升序,旋转 Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand 输出target的index(0-based) 如果...
false
5952daff834f8f713be39ef520f25d896034a006
sahthi/backup2
/backup_files/practice/sample/exp.py
374
4.125
4
import math x=[10,-5,1.2,'apple'] for i in x: try: fact=math.factorial(i) except TypeError: print("factorial is not supported for given input:") except ValueError: print ("factorial only accepts positive integers") else: print ("factorial of a", x, "is",fact) fin...
true
c980d7814d270c5f4ab39a023b3fd81d4313046e
JuneJoshua/Python-MITx-
/MITx I/Problem Set 1/vowels.py
249
4.125
4
vowels = 0 s = str(input("Enter a string: ")) for falchion in s: if falchion == 'a' or falchion == 'e' or falchion == 'i' or falchion == 'o' or falchion == 'u': vowels += 1 else: vowels += 0 print("Number of vowels: " , vowels)
false
b3b0800b6add715999684c41393d1df9a636459d
All-I-Do-Is-Wynn/Python-Codes
/Codewars_Challenges/get_sum.py
547
4.28125
4
# Given two integers a and b, which can be positive or negative, # find the sum of all the integers between and including them and return it. # If the two numbers are equal return a or b. # Note: a and b are not ordered! def get_sum(a,b): sum = 0 if a < b: for x in range(a,b+1): sum += x ...
true
15fdbc037475927e58bf3b36a60c5cffc95264bc
rayvantsahni/after-MATH
/Rotate a Matrix/rotate_matrix.py
1,523
4.40625
4
def rotate(matrix, n, d): while n: matrix = rotate_90_clockwise(matrix) if d else rotate_90_counter_clockwise(matrix) n -= 1 return matrix def rotate_90_counter_clockwise(matrix): """ The function rotates any square matrix by 90° counter clock-wise. """ for row in matrix: ...
true
1adada8a6b7d5332bed5c37d411571ca2ab1eae8
ursawd/springboardexercises
/Unit18/Unit18-2/fs_4_reverse_vowels/reverse_vowels.py
1,200
4.25
4
def reverse_vowels(s): """Reverse vowels in a string. Characters which re not vowels do not change position in string, but all vowels (y is not a vowel), should reverse their order. >>> reverse_vowels("Hello!") 'Holle!' >>> reverse_vowels("Tomatoes") 'Temotaos' >>> reverse_vowels("Re...
false
c6d2d5095d319fdfe43ad2dc712cd97cbe44cb9e
rohit-kuma/Python
/List_tuples_set.py
1,822
4.1875
4
courses = ["history", "maths", "hindi"] print(courses) print(len(courses)) print(courses[1]) print(courses[-1]) print(courses[0:2]) courses.append("art") courses.insert(1, "Geo") courses2 = ["Art", "Education"] print(courses) #courses.insert(0, courses2) #print(courses) courses2.extend(courses) print(courses2) print(co...
true
598a1c47c454c6e31408824cdec50d9d4a262cef
mswinkels09/Critters_Croquettes_server
/animals/petting_animals.py
2,463
4.3125
4
# import the python datetime module to help us create a timestamp from datetime import date from .animals import Animal from movements import Walking, Swimming # Designate Llama as a child class by adding (Animal) after the class name class Llama(Animal): # Remove redundant properties from Llama's initialization,...
true
c27892b565bb1731b02f2fa7f6258419bad34edd
Uma-Ravi22/Bertelsmann-Technology-Scholarship-Python-Challenges
/Day42_RedactText.py
1,421
4.6875
5
# Day 42 Challenge: Redacting Text in a File # Sensitive information is often removed, or redacted, from documents before they are released to the public. # When the documents are released it is common for the redacted text to be replaced with black bars. In this exercise # you will write a program that redacts all ...
true
dc24942f5115667462dd5c11064d903c92d38825
Uma-Ravi22/Bertelsmann-Technology-Scholarship-Python-Challenges
/Day67_LastlineFile.py
553
4.46875
4
# Day 67 Challenge: Print last Line of a File. # Function iterates over lines of file, store each line in lastline. # When EOF, the last line of file content is stored in lastline variable. # Print the result. def get_final_line(fname): fhand = open(fname, "r") for line in fhand: fhand = line.rstrip()...
true
ec508478bbd76531f1ef8e2a7a849254092cb3e4
Uma-Ravi22/Bertelsmann-Technology-Scholarship-Python-Challenges
/Day45_RecurStr.py
689
4.28125
4
# Day 45: Recursive (String) Palindrome def Palindrome(s): # If string length < 1, return TRUE. if len(s) < 1: return True else: # Last letter is compared with first, function called recursively with argument as # Sliced string (With first & last character removed.) if s[0...
true
a3cb102f415dfe67c53f3ff697b3d78369b5da11
sehammuqil/python-
/day18,19.py
481
4.1875
4
#list student =['sara','nora','hind'] print(student) #append student =['sara','nora','hind'] student.append("seham") print(student) #insert student =['sara','nora','hind'] student.insert(2,"seham") print(student) #pop student =['sara','nora','hind'] student.pop(2) print(student) #clear stu...
false
ae91ee6ae54b217b4db050fdb6312e1a1ba116b8
sehammuqil/python-
/day16.py
572
4.34375
4
thistuple = ("apple","banana","cherry") print(thistuple) thistuple=() print(thistuple) thistuple=(3,) print(thistuple) thistuple=(3,1.3,4.1,7) print(thistuple) thistuple=("ahmad",1.1,4,"python") print(thistuple) thistuple = ("apple","banana","cherry") print(thistuple[1]) thistupl...
false
1645420882248e7ffa84200b538f9294884da028
jmohit13/Algorithms-Data-Structures-Misc-Problems-Python
/data_structures/queue.py
1,719
4.25
4
# Queue Implementation import unittest class Queue: """ Queue maintain a FIFO ordering property. FIFO : first-in first-out """ def __init__(self): self.items = [] def enqueue(self,item): """ Adds a new item to the rear of the queue. ...
true
dcb72ba1322aa085b0851b78b2d3e29f17b2ff99
haidragon/Python
/Python基础编程/Python-04/items/ItemDemo.py
813
4.28125
4
info = {"name": "laowang", "age": 18} # 遍历key for temp in info.keys(): print(temp) # 遍历value for temp in info.values(): print(temp) # 遍历items #Python 字典(Dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组。 info_Item = info.items() print(info_Item) #打印字典内的数据 #方法一:直接打印元组 for temp in info.items(): print(temp) '''结果: (...
false
9b4e92729e98d64c54dc2e77720ad805deecde1b
haidragon/Python
/Python基础编程/Python-09/对象/创建对象.py
778
4.15625
4
#创建一个类 class cat: #属性 #方法 def __init__(self,a,b): self.name = a self.age = b def __str__(self): return "--str--" def eat(self): print("猫在吃饭") def drink(self): print("猫在喝水") #若需要创建多个对象都调用这个方法,则形参需要都为self def introduce(self): print("%s的年龄为%d"...
false
1a6b2d6da21f7e87c107dd45b2ffeec143c2aef6
nivetha-ashokkumar/python-basics
/factorial.py
459
4.125
4
def factorial(number1, number2): temp = number1 number1 = number2 number2 = temp return number1, number2 number1 = int(input("enter first value:")) number2 = int(input("enter second vakue:")) result = factorial(nnumber1, number2) print("factorial is:", result) def check(result): if(result != int...
true
8a1e5c9a01cdf662d892e06dd1344f44be378593
luhralive/python
/AK-wang/0001/key_gen_deco.py
837
4.15625
4
#!/usr/bin/env python # -*-coding:utf-8-*- # 第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券), # 使用 Python 如何生成 200 个激活码(或者优惠券)? import string import random KEY_LEN = 20 KEY_ALL = 200 def base_str(): return (string.letters+string.digits) def key_gen(): keylist = [random.choice(base_str()) for ...
false
36d4bb1df1b94b7d8abcac43da7c482453cf0f4c
luhralive/python
/sarikasama/0011/0011.py
507
4.1875
4
#!/usr/bin/env python3 #filter sensitive words in user's input def filter_sensitive_words(input_word): s_words = [] with open('filtered_words','r') as f: line = f.readline() while line != '': s_words.append(line.strip()) line = f.readline() if input_word in s_words: ...
false
2c8697bc9d189648ee827974fa2051fc02ada2c5
luhralive/python
/AK-wang/0012/f_replace.py
985
4.28125
4
#!/usr/bin/env python # -*-coding:utf-8-*- # 第 0012 题: 敏感词文本文件 filtered_words.txt,里面的内容 和 0011题一样,当用户输入敏感词语,则用 星号 * 替换, # 例如当用户输入「北京是个好城市」,则变成「**是个好城市」。 def f_words(f_file): filtered_list = [] with open(f_file, 'r') as f: for line in f: filtered_list.append(line.strip()) return filter...
false
a31fcd621eacd25158fe063530c23c9caa0e8955
luhralive/python
/renzongxian/0012/0012.py
1,016
4.125
4
# Source:https://github.com/Show-Me-the-Code/show-me-the-code # Author:renzongxian # Date:2014-12-22 # Python 3.4 """ 第 0012 题: 敏感词文本文件 filtered_words.txt,里面的内容 和 0011题一样,当用户输入敏感词语,则用 星号 * 替换, 例如当用户输入「北京是个好城市」,则变成「**是个好城市」。 """ def filter_words(words): # Read filtered words from file named 'filtered_words.txt'...
false
231490f1ba7aa8be510830ec4a16568b5e4b2adb
THUEishin/Exercies-from-Hard-Way-Python
/exercise15/ex15.py
503
4.21875
4
''' This exercise is to read from .txt file Pay attention to the operations to a file Namely, close, read, readline, truncate, write(" "), seek(0) ''' from sys import argv script, filename = argv txt = open(filename) print(f"Here is your file {filename}") #readline() is to read a line from the file #strip(*) is to ...
true
5cfafd423c1d2d315dadc17c6796ec3cc860dad4
aav789/pengyifan-leetcode
/src/main/python/pyleetcode/keyboard_row.py
1,302
4.4375
4
""" Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. Example 1: Input: ["Hello", "Alaska", "Dad", "Peace"] Output: ["Alaska", "Dad"] Note: - You may use one character in the keyboard more than once. - You ...
true
98ca0cf6d09b777507091ea494f28f756f6ca1e1
aav789/pengyifan-leetcode
/src/main/python/pyleetcode/Reverse_Words_in_a_String_III.py
682
4.40625
4
""" Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc" Note: In the string, each word is separated by single space and there will not...
true
91e826ad0ea139bf3abe1a4889c86338f833edfa
Sandy134/FourthSem_Material
/Python_Lab/Termwork1b.py
1,068
4.1875
4
#11/5/2021 MAX = 3 def add(q, item): if len(q) == MAX: print("\nQueue Overflow") else: q.append(item) def delete(q): if len(q) == 0: return '#' else: return q.pop(0) def disp(q): if len(q) == 0: print("\nQueue is empty") re...
false
1af36f5047e5ed15218cdc84f3b2bc9ea77bc57c
faridmaamri/PythonLearning
/PCAP_Lab Palindromes_method2.py
1,052
4.34375
4
""" EDUB_PCAP path: LAB 5.1.11.7 Plaindromes Do you know what a palindrome is? It's a word which look the same when read forward and backward. For example, "kayak" is a palindrome, while "loyal" is not. Your task is to write a program which: asks the user for some text; checks whether the entered text is a ...
true
7a7e4c2393928ca31e584f184f4a6c51689a42c5
DominiqueGregoire/cp1404practicals
/prac_04/quick_picks.py
1,351
4.4375
4
"""asks the user how many "quick picks" they wish to generate. The program then generates that many lines of output. Each line consists of 6 random numbers between 1 and 45. pseudocode get number of quick picks create a list to hold each quick pick line generate a random no x 6 to make the line print the line repeat th...
true