blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
a6b2127082c3e3eccf8098d8e370d701c5a876db
BlackMetall/trash
/lesson 9 (practice1).py
959
4.1875
4
#Задача 1. Курьер #Вам известен номер квартиры, этажность дома и количество квартир на этаже. #Задача: написать функцию, которая по заданным параметрам напишет вам, #в какой подъезд и на какой этаж подняться, чтобы найти искомую квартиру. room = int(input('Введите номер квартиры ')) # кол-во квартир floor = int...
false
a40410c97ef48d989ce91b6d23262720f60138dc
rajeshberwal/dsalib
/dsalib/Stack/Stack.py
1,232
4.25
4
class Stack: def __init__(self): self._top = -1 self.stack = [] def __len__(self): return self._top + 1 def is_empty(self): """Returns True is stack is empty otherwise returns False Returns: bool: True if stack is empty otherwise returns False ...
true
04d70de92bfca1f7b293f344884ec1e23489b7e4
rajeshberwal/dsalib
/dsalib/Sorting/insertion_sort.py
547
4.375
4
def insertion_sort(array: list) -> None: """Sort given list using Merge Sort Technique. Time Complexity: Best Case: O(n), Average Case: O(n ^ 2) Worst Case: O(n ^ 2) Args: array (list): list of elements """ for i in range(1, len(array)): current_num = array[...
true
6705bd7dfa677bd27dbcf200aaa3f7dc6cd6cb55
laurenc176/PythonCrashCourse
/Lists/simple_lists_cars.py
938
4.5
4
#organizing a list #sorting a list permanently with the sort() method, can never revert #to original order cars = ['bmw','audi','toyota','subaru'] cars.sort() print(cars) #can also do reverse cars.sort(reverse=True) print(cars) # sorted() function sorts a list temporarily cars = ['bmw','audi','toyota'...
true
68654f6011396a2f0337ba2d591a7939d609b3ed
laurenc176/PythonCrashCourse
/Files and Exceptions/exceptions.py
2,711
4.125
4
#Handling exceptions #ZeroDivisionError Exception, use try-except blocks try: print(5/0) except ZeroDivisionError: print("You can't divide by zero!") #Using Exceptions to Prevent Crashes print("Give me two numbers, and I'll divide them") print("Enter 'q' to quit.") #This will crash if second number is ...
true
fbc01f2c549fae60235064d839c55d98939ae775
martinskillings/tempConverter
/tempConverter.py
2,231
4.3125
4
#Write a program that converts Celsius to Fahrenheit or Kelvin continueLoop = 'f' while continueLoop == 'f': celsius = eval(input("Enter a degree in Celsius: ")) fahrenheit = (9 / 5 * celsius + 32) print(celsius, "Celsius is", format(fahrenheit, ".2f"), "Fahrenheit") #User prompt t...
true
79723bc580e8f7ccd63a8b86c182c783a56d3329
SuzanneRioue/programmering1python
/Lärobok/kap 8/kap. 8, sid. 103 - list comprehensions.py
1,297
4.34375
4
#!/usr/local/bin/python3.9 # Filnamn: kap. kap. 8, sid. 103 - list comprehensions.py # Kapitel 8 - Listor och tipplar # Programmering 1 med Python - Lärobok # Exempeldata listaEtt = [9, 3, 7] # Med listomfattningar (list comprehensions) menas att man skapar en ny lista # där varje element är resultatet av någon op...
false
f38757087bf31b61d8238f3e98798a8799f1b6f8
SuzanneRioue/programmering1python
/Lärobok/kap 8/kap. 8, sid. 104 - sammanfattning med exempel.py
2,712
4.1875
4
#!/usr/local/bin/python3.9 # Filnamn: kap. 8, sid. 104 - sammanfattning med exempel.py # Kapitel 8 - Listor och tipplar # Programmering 1 med Python - Lärobok # Exempeldata lista = [7, 21, 3, 12] listaLäggTill = [35, 42] listaSortera = [6, 2, 9, 1] listaNamn = ['Kalle', 'Ada', 'Pelle', 'Lisa'] # len(x) Ta reda på an...
false
70a075b1fba763f3a12d1baecbc20c50930c0c3d
SourDumplings/CodeSolutions
/Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/010向列表中添加成绩.py
287
4.21875
4
#向列表中添加成绩 #Coding 酸饺子 print('-------------酸饺子学Python-------------') member = ['小甲鱼', '黑夜', '迷途', '怡静', '秋舞斜阳'] member.insert(1, 88) member.insert(3, 90) member.insert(5, 85) member.insert(7, 90) member.insert(9, 88) print(member)
false
d5a296818f6bd02b8c03c76b2aa042abbcb4ee17
AlexanderOHara/programming
/week03/absolute.py
336
4.15625
4
# Give the absolute value of a number # Author Alexander O'Hara # In the question, number is ambiguous but the output implies we should be # dealing with floats so I am casting the input to a flat number = float (input ("Enter a number: ")) absoluteValue = abs (number) print ('The absolute value of {} is {}'. format...
true
faf268ea926783569bf7e2714589f264ed4f3554
Teddy-Sannan/ICS3U-Unit2-02-Python
/area_and_perimeter_of_circle.py
606
4.1875
4
#!/usr/bin/env python3 # Created by: Teddy Sannan # Created on: September 16 # This program calculates the area and perimeter of a rectangle def main(): # main function print("We will be calculating the area and perimeter of a rectangle") print("") # input length = int(input("Enter the length (mm...
true
158450f4cb59c6890e6de4931de18e66a4f5ef48
FraserTooth/python_algorithms
/01_balanced_symbols_stack/stack.py
865
4.21875
4
class Stack: def __init__(self): self.items = [] def push(self, item): """Adds an item to end Returns Nothing Time Complexity = O(1) """ self.items.append(item) def pop(self): """Removes Last Item Returns Item Time Complexity = O(1)...
true
14d98d23d3617c08a2aefd1b4ced2d80c5a9378c
168959/Datacamp_pycham_exercises2
/Creat a list.py
2,149
4.40625
4
# Create the areas list areas = ["hallway", 11.25, "kitchen", 18.0, "living room", 20.0, "bedroom", 10.75, "bathroom", 9.50] "# Print out second element from areas" print(areas[1]) "# Print out last element from areas" print(areas[9]) "# Print out the area of the living room" print(areas[5]) "# Create the areas lis...
true
a65aa34ef32d7fced8a91153dae77e48f5cc1176
2019-fall-csc-226/a02-loopy-turtles-loopy-languages-henryjcamacho
/Camachoh- A02.py
1,133
4.15625
4
###################################################################### # Author: Henry Camacho TODO: Change this to your name, if modifying # Username: HenryJCamacho TODO: Change this to your username, if modifying # # Assignment: A02 # Purpose: To draw something we lie with loop ########...
true
5c703ed90acda4eaba3364b6f510d28622ddc4a0
ndenisj/web-dev-with-python-bootcamp
/Intro/pythonrefresher.py
1,603
4.34375
4
# Variables and Concatenate # greet = "Welcome To Python" # name = "Denison" # age = 6 # coldWeather = False # print("My name is {} am {} years old".format(name, age)) # Concatenate # Comment: codes that are not executed, like a note for the programmer """ Multi line comment in python """ # commentAsString = """ ...
true
1c32272ef45f6e6958cee58d95088c5b475269b1
srgiola/UniversidadPyton_Udemy
/Fundamentos Python/Tuplas.py
808
4.28125
4
# La tupla luego de ser inicializada no se puede modificar frutas = ("Naranja", "Platano", "Guayaba") print(frutas) print(len(frutas)) print(frutas[0]) # Acceder a un elemento print(frutas[-1]) # Navegación inversa #Tambien funcionan los rangos igual que en las listas print(frutas[0:2]) # Una Lista se puede inici...
false
57bade1fd06c0bf6e9814bea60b5e4e6a8d35163
suyash248/ds_algo
/Queues/queueUsingStack.py
1,364
4.15625
4
class QueueUsingStack(object): __st1__ = list() __st2__ = list() def enqueue(self, elt): self.__st1__.append(elt) def dequeue(self): if self.empty(): raise RuntimeError("Queue is empty") if len(self.__st2__) == 0: while len(self.__st1__) > 0: ...
false
61e6633eeadf4384a18603640e30e0fa0a6998c8
suyash248/ds_algo
/Array/stockSpanProblem.py
959
4.28125
4
from Array import empty_1d_array # References - https://www.geeksforgeeks.org/the-stock-span-problem/ def stock_span(prices): # Stores index of closest greater element/price. stack = [0] spans = empty_1d_array(len(prices)) # Stores the span values, first value(left-most) is 1 as there is no previous g...
true
d21394227d4390b898fc1588593e43616ed7e502
suyash248/ds_algo
/Misc/sliding_window/substrings_with_distinct_elt.py
2,324
4.125
4
''' Given a string s consisting only of characters a, b and c. Return the number of substrings containing at least one occurrence of all these characters a, b and c. Example 1: Input: s = "abcabc" Output: 10 Explanation: The substrings containing at least one occurrence of the characters a, b and c are "abc", "abc...
true
80ebbfd1da7c991ac5810797b90fe493ec22b654
shangkh/github_python_interview_question
/11.简述面向对象中__new__和__init__区别.py
1,384
4.21875
4
""" __init__ 是初始化方法,创建对象后,就立刻被默认调用了,可以接收参数 """ """ __new__ 1.__new__ 至少要有一个参数 cls,代表当前类,此参数在实例化时由python解释器自动识别 2.__new__ 必须要有返回值,返回实例化出来的实例,这点在自己实现__new__时要特别注意, 可以return父类(通过super(当前类名, cls))__new__出来的实例, 或者直接是object的__new__出来的实例 3.__int__有一个参数self,就是这个__new__返回的实例, __init__在__new__的基础上可以完成一些其他的初始化动作, ...
false
12562fa1658d275e15075f71cff3fac681c119ab
green-fox-academy/Angela93-Shi
/week-01/day-4/data_structures/data_structures/product_database.py
715
4.34375
4
map={'Eggs':200,'Milk':200,'Fish':400,'Apples':150,'Bread':50,'Chicken':550} # Create an application which solves the following problems. # How much is the fish? print(map['Fish']) # What is the most expensive product? print(max(map,key=map.get)) # What is the average price? total=0 for key in map: total=total+map...
true
587a7726500b091aea4511e4036f8750c229ecaa
green-fox-academy/Angela93-Shi
/week-05/day-01/all_positive.py
319
4.3125
4
# Given a list with the following items: 1, 3, -2, -4, -7, -3, -8, 12, 19, 6, 9, 10, 14 # Determine whether every number is positive or not using all(). original_list=[1, 3, -2, -4, -7, -3, -8, 12, 19, 6, 9, 10, 14] def positive_num(nums): return all([num > 0 for num in nums]) print(positive_num(original_list))
true
8fcf16851182307c41d9c5dd77e8d42b783628c7
green-fox-academy/Angela93-Shi
/week-01/day-4/function/factorial.py
409
4.375
4
# - Create a function called `factorio` # that returns it's input's factorial num = int(input("Please input one number: ")) def factorial(num): factorial=1 for i in range(1,num + 1): factorial = factorial*i print("%d 's factorial is %d" %(num,factorial)) if num < 0: print("抱歉,负数没有阶乘") elif nu...
true
c5d9cfe8cdda4d4fdc98f77221c15bb23da5e100
green-fox-academy/Angela93-Shi
/week-01/day-4/data_structures/data_structures/telephone_book.py
478
4.1875
4
#Create a map with the following key-value pairs. map={'William A. Lathan':'405-709-1865','John K. Miller':'402-247-8568','Hortensia E. Foster':'606-481-6467','Amanda D. Newland‬':'319-243-5613','Brooke P. Askew':'307-687-2982'} print(map['John K. Miller']) #Whose phone number is 307-687-2982? for key,value in map.item...
false
c60df7c6d2aa3eaecdc1c95bc7bba9a96eff1add
kasemodz/RaspberryPiClass1
/LED_on_off.py
831
4.125
4
# The purpose of this code is to turn the led off and on. # The LED is connected to GPIO pin 25 via a 220 ohm resistor. # See Readme file for necessary components #! /usr/bin/python #We are importing the sleep from the time module. from time import sleep #We are importing GPIO subclass from the class RPi. We are ref...
true
99f64a174783c4a4f8a4a304672a096b0fe04ccc
Poter0222/poter
/PYTHON/03.04/string.py
697
4.1875
4
#coding=UTF-8 # 03 # 字串運算 # 字串會對內部的字元編號(索引),從 0 開始 s="hello\"o" # \ 在雙引號前面打入,代表跳脫(跟外面雙引號作區隔) 去避免你打的字串中有跟外面符號衝突的問題 print(s) # 字串的串接 s="hello"+"world" print(s) s="hello" "world" # 同 x="hello"+"world" print(s) # 字串換行 s="hello\nworld" # /n代表換行 print(s) s=""" hello world""" # 前後加入“”“可將字串具體空出你空的行數 print(s) s="hello"*3+"w...
false
e799fbff3d6be502d48b68fb1094b6dd4bcc4079
yihangx/Heart_Rate_Sentinel_Server
/validate_heart_rate.py
901
4.25
4
def validate_heart_rate(age, heart_rate): """ Validate the average of heart rate, and return the patient's status. Args: age(int): patient'age heart_rate(int): measured heart rates Returns: status(string): average heart rate """ status = "" if age < 1: tachyca...
true
43382e8fe8fac375b8bdbbda97a67d853a5a7e19
eleanorpark/Python-Dec-2018-CrashCourse
/areaofcircle.py
348
4.125
4
def area_of_circle(radius): 3.14*radius*radius radius=2 area = 3.14*radius*radius area_of_circle(radius) print('area of circle of radius {} is:{}'.format(radius,area)) def area_of_circle(radius): 3.14*radius*radius radius=10 area = 3.14*radius*radius area_of_circle(radius) print('area of circle of radius {} ...
false
0f7cfefeb124d76ef25dc904500246c9e843658d
xg04tx/number_game2
/guessing_game.py
2,282
4.125
4
def main(): while True: try: num = int( input("Please, think of a number between 1 and 1000. I am about to try to guess it in 10 tries: ")) if num < 1 or num > 1000: print("Must be in range [1, 100]") else: computer_guess...
true
4deedfe0dea559088f4d2652dfe71479fce81762
saman-rahbar/in_depth_programming_definitions
/errorhandling.py
965
4.15625
4
# error handling is really important in coding. # we have syntax error and exceptions # syntax error happens due to the typos, etc. and usually programming languages can help alot with those # exceptions, however, is harder to figure and more fatal. So in order to have a robust code you should # handle the errors and ...
true
0a8a9a0a4c6ca24fde6c09886c52d1d5c7817a24
Trietptm-on-Coding-Algorithms/Learn_Python_the_Hard_Way
/ex40b.py
974
4.53125
5
cities = {'CA': 'San Francisco', 'MI': 'Detroit', 'FL': 'Jacksonville'} cities['NY'] = 'New York' cities['OR'] = 'Portland' def find_city(themap, state): if state in themap: return themap[state] else: return "Not found." # ok pay attention! cities ['_find'] = find_city while True: print "State? (ENTER to qui...
true
5892f0c1c6cb36853a85e541cb6b3259346546e9
Trietptm-on-Coding-Algorithms/Learn_Python_the_Hard_Way
/ex06.py
898
4.1875
4
# Feed data directly into the formatting, without variable. x = "There are %d types of people." % 10 binary = "binary" do_not = "don't" #Referenced and formatted variables, within a variable. y = "Those who know %s and those who %s." % (binary, do_not) print x print y #r puts quotes around string print "I said: %r."...
true
59c54a778af80dc495ed27f83006893f36e9a9e7
saurabhslsu560/myrespository
/oop3.py
1,028
4.15625
4
class bank: bank_name="union bank of india" def __init__(self,bank_bal,acc_no,name): self.bank_bal=bank_bal self.acc_no=acc_no self.name=name return def display(self): print("bank name is :",bank.bank_name) print("account holder name is:",self.name) ...
false
71a2fe42585b7a6a2fece70674628c1b529f3371
pltuan/Python_examples
/list.py
545
4.125
4
db = [1,3,3.4,5.678,34,78.0009] print("The List in Python") print(db[0]) db[0] = db[0] + db[1] print(db[0]) print("Add in the list") db.append(111) print(db) print("Remove in the list") db.remove(3) print(db) print("Sort in the list") db.sort() print(db) db.reverse() print(db) print("Len in the list") print(len(db)) pr...
true
97745f9a33b8e5653d050d3a5c875c57bc4e5780
WangMingJue/StudyPython
/Test/Python 100 example/Python 练习实例6.py
1,134
4.25
4
# 题目:斐波那契数列。 # # 程序分析:斐波那契数列(Fibonacci sequence),又称黄金分割数列,指的是这样一个数列:0、1、1、2、3、5、8、13、21、34、……。 # # 在数学上,费波那契数列是以递归的方法来定义: # F0 = 0 (n=0) # F1 = 1 (n=1) # Fn = F[n-1]+ F[n-2](n=>2) # 普通方法 def method_1(index): a, b = 1, 1 for i in range(index - 1): a, b = b, a + b return a # 使用递归 def method...
false
74bda556d528a9346da3bdd6ca7ac4e6bcac6654
adaoraa/PythonAssignment1
/Reverse_Word_Order.py
444
4.4375
4
# Write a program (using functions!) that asks the user for a long string containing multiple words. # Print back to the user the same string, except with the words in backwards order. user_strings = input('input a string of words: ') # prompts user to input string user_set = user_strings.split() # converts stri...
true
7b35393252d51e721ffddde3007105546240e5df
adaoraa/PythonAssignment1
/List_Overlap.py
1,360
4.3125
4
import random # Take two lists, say for example these two:... # and write a program that returns a list that # contains only the elements that are common between # the lists (without duplicates). Make sure your program # works on two lists of different sizes. a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, ...
true
7036212232a843fe184358c1b41e5e9cb096d31d
andrew5205/MIT6-006
/ch2/binary_search_tree.py
1,377
4.21875
4
class Node: # define node init def __init__(self, data): self.left = None self.right = None self.data = data # insert into tree def insert(self, data): # if provide data exist if self.data: # 1 check to left child # compa...
true
8eb212398880ce375cf3541eac5fcd73c1ab95fe
Srbigotes33y/Programacion
/Python/Aprendizaje/Condiociones anidadas/Taller Condiciones2/Ejercicio_5.py
1,767
4.125
4
# Programa que solicita 3 números,los muestra en pantalla de mayor a menor en lineas distintas. # En caso de haber numeros iguales, se pintan en la misma linea. # Solicitud de datos n1=int(input("Ingrese tres números.\nNúmero #1: ")) n2=int(input("Número #2: ")) n3=int(input("Número #3: ")) # En caso de que no se pr...
false
25b2d05140a1397680d93d95c6a305f6c39f5602
Srbigotes33y/Programacion
/Python/Aprendizaje/Condiociones anidadas/Taller Condiciones2/Ejercicio_4.py
1,043
4.15625
4
# Programa que pide 3 números y los muestra en pantalla de menor a mayor # Solicitud de datos n1=int(input("Ingrese tres números.\nNúmero #1: ")) n2=int(input("Número #2: ")) n3=int(input("Número #3: ")) # Determinacion y exposición de los resultados if n1>n2 and n2>n3: print("\nEl orden de los números es:\n",n3...
false
e9aa4621abbe5b8b60fa7bc02b3a54ba2f42531a
sharmar0790/python-samples
/misc/findUpperLowerCaseLetter.py
241
4.25
4
#find the number of upper and lower case characters str = "Hello World!!" l = 0 u=0 for i in str: if i.islower(): l+=1 elif i.isupper(): u+=1 else: print("ignore") print("Lower = %d, upper = %d" %(l,u))
true
4b6bf4b0865f101b5545c7cb1033c5738c33dc3b
sharmar0790/python-samples
/misc/factors.py
267
4.28125
4
nbr = int(input("Enter the number to find the factors : ")) for i in range(1, nbr+ 1 ): if (nbr % i == 0): if i % 2 == 0: print("Factor is :", i , " and it is : Even") else: print("Factor is :", i , " and it is : Odd")
false
ece16e9a25e880eaa3381b787b12cecf86625886
x223/cs11-student-work-Aileen-Lopez
/March21DoNow.py
462
4.46875
4
import random random.randint(0, 8) random.randint(0, 8) print(random.randint(0, 3)) print(random.randint(0, 3)) print(random.randint(0, 3)) # What Randint does is it accepts two numbers, a lowest and a highest number. # The values of 0 and 3 gives us the number 0, 3, and 0. # I Changed the numbers to (0,8) and the res...
true
016c7e2da4516be168d3f51b34888d12e0be1c5d
adrian-calugaru/fullonpython
/sets.py
977
4.4375
4
""" Details: Whats your favorite song? Think of all the attributes that you could use to describe that song. That is: all of it's details or "meta-data". These are attributes like "Artist", "Year Released", "Genre", "Duration", etc. Think of as many different characteristics as you can. In your text editor, create ...
true
4da4b5e0a87f9220caa5fb470cac464fe17975cb
aniketpatil03/Hangman-Game
/main.py
1,650
4.125
4
import random stages = [''' +---+ | | O | /|\ | / \ | Death| ========= ''', ''' +---+ | | O | /|\ | / | | ========= ''', ''' +---+ | | O | /|\ | | | ========= ''', ''' +---+ | | O | /| | | | =========''', ''' +---+ | | O | ...
false
4ce5c10eaf4a27ff54a1b12c87110659daf3f04a
aubreystevens/image_processing_pipeline
/text_files/Test.py
1,033
4.15625
4
#B.1 def complement(sequence): """This function returns the complement of a DNA sequence. The argument, 'sequence' represents a DNA sequence.""" for base in 'sequence': if 'A' in 'sequence': return 'T' elif 'G' in 'sequence': ...
true
33d73944bf28351346ac72cbee3f910bcf922911
maneeshapaladugu/Learning-Python
/Practice/Armstrong_Number.py
763
4.46875
4
#Python program to check if a number is Armstrong or not #If the given number is 153, and 1^3 + 5 ^ 3 + 3 ^ 3 == 153, then 153 is an Armstrong number def countDigits(num): result = 0 while num > 0: result += 1 num //= 10 print(result) return result def isArmstrong(...
true
37bd1683785377afe49b17d3aec9700665e3d3db
MyoMinHtwe/Programming_2_practicals
/Practical 5/Extension_3.py
1,804
4.1875
4
def bill_estimator(): MENU = """11 - TARIFF_11 = 0.244618 31 - TARIFF_31 = 0.136928 41 - TARIFF_41 = 0.156885 51 - TARIFF_51 = 0.244567 61 - TARIFF_61 = 0.304050 """ print(MENU) tariff_cost = {11: 0.244618, 31: 0.136928, 41: 0.156885, 51: 0.244567, 61: 0.304050} choice = int(input("Which tariff?...
false
8071c3f0f77261cb68e0c36d09a814ba95fdb474
MyoMinHtwe/Programming_2_practicals
/Practical 5/Extension_1.py
248
4.3125
4
name_to_dob = {} for i in range(2): key = input("Enter name: ") value = input("Enter date of birth (dd/mm/yyyy): ") name_to_dob[key] = value for key, value in name_to_dob.items(): print("{} date of birth is {:10}".format(key,value))
true
cb0c2a4c02c8fee656a94fe659ac0c25115bd4bc
MyoMinHtwe/Programming_2_practicals
/Practical 3/temperatures.py
1,045
4.125
4
MENU = """C - Convert Celsius to Fahreneit F - Convert Fahrenheit to Celsius Q - Quit""" print(MENU) choice = input("Input your choice: ").lower() def main(choice): #choice = input("Input your choice: ").lower() print(choice) i = True while i==True: if choice == "c": celsius = float(...
false
a288abbab98175fb70e1c1a34c5c6f4eeeed438a
HarshKapadia2/python_sandbox
/python_sandbox_finished_(by_harsh_kapadia)/tuples_sets.py
1,269
4.25
4
# A Tuple is a collection which is ordered and unchangeable. Allows duplicate members. # create tuple fruit_1 = ('mango', 'watermelon', 'strawberry', 'orange', 'dragon fruit') # using constructor fruit_2 = tuple(('mango', 'watermelon', 'strawberry', 'orange', 'dragon fruit')) print(fruit_1, fruit_2) fruit_3 = ('app...
true
828e176b7aae604d3f4d38a206d4f1cfa5d49197
HarshKapadia2/python_sandbox
/python_sandbox_finished_(by_harsh_kapadia)/loops.py
854
4.1875
4
# A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). people = ['Selena', 'Lucas', 'Felix', 'Brad'] # for person in people: # print(person) # break # for person in people: # if person == 'Felix': # break # print(person) # cont...
true
622589e96be15dc7e742ce2a1dc83ea91507b5dc
DeepanshuSarawagi/python
/ModulesAndFunctions/dateAndTime/datecalc.py
354
4.25
4
import time print(time.gmtime(0)) # This will print the epoch time of this system which is usually January 1, 1970 print(time.localtime()) # This will print the local time print(time.time()) # This will print the time in seconds since epoch time time_here = time.localtime() print(time_here) for i in time_here: ...
true
91bfc92d73cf257344dc1260e433bdbd9d6cb4d5
DeepanshuSarawagi/python
/freeCodeCamp/ConditionalExecution/conditionalExecution.py
309
4.1875
4
# This is a python exercise on freeCodeCamp's python certification curriculum x = 5 if x < 5: print("X is less than 5") for i in range(5): print(i) if i <= 2: print("i is less than or equal to 2") if i > 2: print("i is now ", i) print("Done with ", i) print("All done!")
true
7384fbb693486ec0f00158292487d6a2086fc2ac
DeepanshuSarawagi/python
/Data Types/numericOperators.py
485
4.34375
4
# In this lesson we are going to learn about the numeric operators in the Python. a = 12 b = 3 print(a + b) print(a - b) print(a * b) print(a / b) print(a // b) print(a % b) # We will learn about the operator precedence in the following example. print(a + b / 3 - 4 * 12) # This should evaluate to -35.0 as per the ...
true
6d34356e7e6d161aa6e838b8ca588e3dce3b01f4
DeepanshuSarawagi/python
/100DaysOfPython/Day2/DataTypes/typeConversion.py
944
4.25
4
# In this lesson we are going to convert the int data type to string data type num_char = len(input("What is your name?\n")) print("Your name has " + str(num_char) + " characters") # Type conversion happens here. Where we convert # the type integer to string # ...
true
a9aaf4e426597e6a54aff443fdadefad6e4fb9d6
DeepanshuSarawagi/python
/100DaysOfPython/Day1/main.py
647
4.375
4
print("Print something") print("Hello World!") print("Day 1 - Python Print Function") print("print('what to print')") print("Hello World!\nHello World again!\nHellooo World!!") print() # Day 1. Exercise 2 Uncomment below and debug the errors # print(Day 1 - String Manipulation") # print("String Concatenation is done...
true
34c3bcf8c09826d88ff52370f8c9ae9735d2f966
DeepanshuSarawagi/python
/100DaysOfPython/Day19/Turtle-GUI-2/main.py
796
4.21875
4
from turtle import Turtle, Screen tim = Turtle() screen = Screen() def move_forward(): tim.forward(10) screen.listen() # In order for our turtle to listen to the screen events, we need to call this screen method screen.onkey(fun=move_forward, key="Up") # The Screen.onkey() method accepts two arguments, 1. F...
true
e9e42890ea221e41dd51181364f24590d1b0ce6e
DeepanshuSarawagi/python
/whileLoop/whileLoop.py
423
4.125
4
# In this lesson we are going to learn about while loops in Python. # Simple while loop. i = 0 while i < 10: print(f"i is now {i}") i += 1 available_exit =["east", "west", "south"] chosen_exit = "" while chosen_exit not in available_exit: chosen_exit = input("Please enter a direction: ") if chosen_exi...
true
11bc279d354a5d57bcae0bd9d14b8ed52db97a4b
DeepanshuSarawagi/python
/100DaysOfPython/Day27/ArgsAndKwargs/kwargs_example.py
1,160
4.6875
5
""" In this lesson we are going to learn about unlimited keyword arguments and how it can be used in functions. The general syntax is to define a function with just one parameter **kwargs. We can then loop through the 'many' keyword arguments and perform necessary actions. Syntax: def function(**kwargs): s...
false
ad0cf84f3a01da48c32aa7efae44cf3b964d44d1
DeepanshuSarawagi/python
/100DaysOfPython/Day2/DataTypes/BMICalculator.py
209
4.28125
4
height = float(input("Enter your height in meters: ")) weight = float(input("Enter your weight in kilograms: ")) print("Your BMI is {}".format(round(weight / (height * height), 2))) print(8 // 3) print(8 / 3)
true
31a342ddff6fade8595b45f6127868b7525feca1
DeepanshuSarawagi/python
/DSA/Arrays/TwoDimensionalArrays/main.py
2,074
4.40625
4
import numpy # Creating two dimensional arrays # We will be creating it using a simple for loop two_d_array = [] for i in range(1, 11): two_d_array.append([i * j for j in range(2, 6)]) print(two_d_array) twoDArray = numpy.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) pr...
true
4bde74d331959c0b3ca9002de605e7b39066c22d
DeepanshuSarawagi/python
/100DaysOfPython/Day3/IfElseAndConditionaloperators/BMICalculator.py
575
4.375
4
# BMI calculator 2.0 height = float(input("Please enter your height in meters: ")) weight = float(input("Please enter your weight in kgs: ")) bmi = float(round(weight / (height ** 2), 2)) if bmi < 18.5: print("BMI = {:.2f}. You are underweight".format(bmi)) elif 18.5 <= bmi <= 25: print("BMI = {:.2f}. You are ...
false
c32944fc92021af6a9aab1d68844287921f5f7dd
DeepanshuSarawagi/python
/100DaysOfPython/Day21/InheritanceBasics/Animal.py
563
4.375
4
class Animal: def __init__(self): self.num_eyes = 2 def breathe(self): print("Inhale, Exhale") # Now we are going to create a class Fish which will inherit properties from the Animal class and also has it's own # properties class Fish(Animal): def __init__(self): super().__init...
true
1117ab86b491eca4f879897af51ccc69112e854b
shaonsust/Algorithms
/sort/bubble_sort.py
1,074
4.40625
4
""" Python 3.8.2 Pure Python Implementation of Bubble sort algorithm Complexity is O(n^2) This algorithm will work on both float and integer type list. Run this file for manual testing by following command: python bubble_sort.py Tutorial link: https://www.geeksforgeeks.org/bubble-sort/ """ def bubble_sort(arr): ...
true
a0118ebfc3e690eb89439727e45ac0c5085c382d
destinysam/Python
/step_argument_slicing.py
769
4.40625
4
# CODED BY SAM@SAMEER # EMAIL: SAMS44802@GMAIL.COM # DATE: 15/08/2019 # PROGRAM: STEP ARGUMENT IN STRING SLICING language = "programming language" print("python"[0:6]) print("python"[0:6:1]) # SYNTAX STRING_NAME[START ARGUMENT:STOP ARGUMENT:STEP] print("python"[0:6:2]) # TAKING 2 STEPS TO AHEAD TO PRINT POSITION[2] A...
false
81a8bce1fd4ad1426104d8f4b662f0c0ca3c52c5
destinysam/Python
/more inputs in one line.py
435
4.15625
4
# CODED BY SAM@SAMEER # EMAIL: SAMS44802@GMAIL.COM # DATE: 12/09/2019 # PROGRAM: TAKING MORE THAN ONE INPUT FROM THE USER name, age, address = "sameer", "23", "tarigam" # ASSIGNING VALUES BY ORDER print("YOUR NAME,AGE AND ADDRESS IS " + name + " " + age + " " + address) x = y = z = 2 print(x+y+z) name, age, address = ...
true
0eaf2afa9cc1c3f161504fc2c9254b92fb3f4262
venkatadri123/Python_Programs
/100_Basic_Programs/program_43.py
280
4.53125
5
# 43. Write a program which accepts a string as input to print "Yes" # if the string is "yes" or "YES" or "Yes", otherwise print "No". def strlogical(): s=input() if s =="Yes" or s=="yes" or s=="YES": return "Yes" else: return "No" print(strlogical())
true
01158919c0c3b66a38f8094fe99d22d9d3f53bed
venkatadri123/Python_Programs
/100_Basic_Programs/program_35.py
322
4.15625
4
# 35. Define a function which can generate a dictionary where the keys are numbers between 1 and 20 # (both included) and the values are square of keys. The function should just print the keys only. def sqrkeys(): d=dict() for i in range(1,21): d[i]=i**2 for k in d: print(k) sqrkeys...
true
b1adffe626fa1a1585012689ec2b1c01925c181c
venkatadri123/Python_Programs
/core_python_programs/prog78.py
334
4.15625
4
# Write a python program to accept values from keyboard and display its transpose. from numpy import* r,c=[int(i) for i in input('enter rows,columns:').split()] arr=zeros((r,c),dtype=int) print('enter the matrix:') for i in range(r): arr[i]=[int(x) for x in input().split()] m=matrix(arr) print('transpose:') print(m...
true
3625b577e1d82afc31436473149cc7ff1e3ce96c
venkatadri123/Python_Programs
/100_Basic_Programs/program_39.py
318
4.1875
4
# 39. Define a function which can generate a list where the values are square of numbers # between 1 and 20 (both included). Then the function needs to print all values # except the first 5 elements in the list. def sqrlis(): l=[] for i in range(1,20): l.append(i**2) return l[5:] print(sqrlis())
true
fa7b092a720e7ce46b2007341f4e70de60f8e6ca
venkatadri123/Python_Programs
/100_Basic_Programs/program_69.py
375
4.15625
4
# 69. Please write assert statements to verify that every number in the list [2,4,6,8] is even. l=[2,4,6,8] for i in l: assert i%2==0 # Assertions are simply boolean expressions that checks if the conditions return true or not. # If it is true, the program does nothing and move to the next line of code. # However...
true
7a26e4bc77d34fd19cf4350c78f4764492d32064
venkatadri123/Python_Programs
/core_python_programs/prog83.py
250
4.25
4
# Retrive only the first letter of each word in a list. words=['hyder','secunder','pune','goa','vellore','jammu'] lst=[] for ch in words: lst.append(ch[0]) print(lst) # To convert into List Comprehension. lst=[ch[0] for ch in words] print(lst)
true
b1c41d7bfbc80bdd15642bcb0f02291c7867779e
ProgrammingForDiscreteMath/20170830-bodhayan
/code.py
700
4.15625
4
# 1 # Replace if-else with try-except in the the example below: def element_of_list(L,i): """ Return the 4th element of ``L`` if it exists, ``None`` otherwise. """ try: return L[i] except IndexError: return None # 2 # Modify to use try-except to return the sum of all numbers in L, ...
true
b6834d2bf0af216c26a7a2b92880ab566685caea
planetblix/learnpythonthehardway
/ex16.py
1,436
4.40625
4
#/bin/python from sys import argv script, filename = argv print "We're going to erase %r." % filename print "If you don't want that, hit CTRL-C (^C)." print "If you do want that, hit RETURN." raw_input("?") print "Open the file..." #rw doesn't mean read and write, it just means read! #You could open the file twice...
true
9522b6a465c1644ff8399a838eb3a7fb3b9cbcec
seriouspig/homework_week_01_day_01
/precourse_recap.py
566
4.15625
4
print("Guess the number I'm thinking from 1 to 10, What do you think it is?") guessing = True number_list = [1,2,3,4,5,6,7,8,9,10] import random selected_number = random.choice(number_list) while guessing == True: answer = int(input('Pick a number from 1 to 10: ')) if answer == selected_number: prin...
true
961b6639cb292351bff3d4ded8c366ab0d860ed8
IshaqNiloy/Any-or-All
/main (1).py
980
4.25
4
def is_palindromic_integer(my_list): #Checking if all the integers are positive or not and initializing the variable is_all_positive = all(item >= 0 for item in my_list) #Initializing the variable is_palindrome = False if is_all_positive == True: for item in my_list: #Converting...
true
de3f02e8416760c40ab208ff7ee372313040fcd1
bishal-ghosh900/Python-Practice
/Practice 1/main30.py
992
4.1875
4
# Sieve of Eratosthenes import math; n = int(input()) def findPrimes(n): arr = [1 for i in range(n+1)] arr[0] = 0 arr[1] = 0 for i in range(2, int(math.sqrt(n)) + 1, 1): if arr[i] == 1: j = 2 while j * i <= n: arr[j*i] = 0 j += 1 for i...
true
eaadca4eda12fc7af10c3a6f70437a760c14358f
bishal-ghosh900/Python-Practice
/Practice 1/main9.py
595
4.6875
5
# Logical operator true = True false = False if true and true: print("It is true") # and -> && else: print("It is false") # and -> && # Output --> It is true if true or false: print("It is true") # and -> || else: print("It is false") # and -> || # Output --> It is true if true and not true: ...
true
460ea4d25a2f8d69e8e009b70cdec588b8ca7b20
bishal-ghosh900/Python-Practice
/Practice 1/main42.py
782
4.28125
4
# set nums = [1, 2, 3, 4, 5] num_set1 = set(nums) print(num_set1) num_set2 = {4, 5, 6, 7, 8} # in set there is not any indexing , so we can't use expression like num_set1[0]. # # Basically set is used to do mathematics set operations #union print(num_set1 | num_set2) # {1, 2, 3, 4, 5, 6, 7, 8} # intersection pr...
true
789e675cb561a9c730b86b944a0a80d6c423f475
bishal-ghosh900/Python-Practice
/Practice 1/main50.py
804
4.75
5
# private members # In python there we can prefix any data member with __ (dunder sign) , then it will be private. In reality it don't get private, if we declare any data member with __ , that data member actually get a differet name from python , which is like => _classname__fieldname. So in the below implementation...
true
c35759cf6ddf382cd6ec14e90bd013707af13fd6
learninfo/pythonAnswers
/Task 5 - boolean.py
236
4.375
4
import turtle sides = int(input("number of sides")) while (sides < 3) or (sides > 8) or (sides == 7): sides = input("number of sides") for count in range(1, sides+1): turtle.forward(100) turtle.right(360/sides)
true
a8a5edf3c6cf3f5a6470016eb6c5802e18df4338
bharath-acchu/python
/calci.py
899
4.1875
4
def add(a,b): #function to add return (a+b) def sub(a,b): return (a-b) def mul(a,b): return (a*b) def divide(a,b): if(b==0): print("divide by zero is not allowed") return 0 else: return (a/b) print('\n\t\t\t SIMPLE...
true
85be56b1f4f0ae5e51463b8ef7005fcef33fa357
parasmaharjan/Python_DeepLearning
/ICP4/ClassObject.py
1,226
4.125
4
# Python Object-Oriented Programming # attribute - data # method - function associated with class # Employee class class Employee: # special init method - as initialize or constructor # self == instances def __init__(self, first, last, pay, department): self.first = first self.last = last...
false
49629b071964130f6fb9034e96480f7b5a179e51
aakhriModak/assignment-1-aakhriModak
/01_is_triangle.py
2,117
4.59375
5
""" Given three sides of a triangle, return True if it a triangle can be formed else return False. Example 1 Input side_1 = 1, side_2 = 2, side_3 = 3 Output False Example 2 Input side_1 = 3, side_2 = 4, side_3 = 5 Output True Hint - Accordingly to Triangle inequality theorem, the sum of any two sides of a triangl...
true
5097aa5c089e31d239b06bbd76e99942694cbdd7
CBehan121/Todo-list
/Python_imperative/todo.py
2,572
4.1875
4
Input = "start" wordString = "" #intializing my list while(Input != "end"): # Start a while loop that ends when a certain inout is given Input = input("\nChoose between [add], [delete], [show list], [end] or [show top]\n\n") if Input == "add": # Check if the user wishes to add a new event/task to the list check...
true
813e9e90d06cb05c93b27a825ac14e5e96abcc9b
bparker12/code_wars_practice
/squre_every_digit.py
520
4.3125
4
# Welcome. In this kata, you are asked to square every digit of a number. # For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1. # Note: The function accepts an integer and returns an integer def square_digits(num): dig = [int(x) **2 for x in str(num)] dig...
true
312b662283a4f358cfaeec5bfd0e7793bf03816d
unisociesc/Projeto-Programar
/Operadores/Exercícios Aritméticos.py
994
4.21875
4
#Exercícios Operadores Aritméticos # 1- Faça um Programa que peça dois números e imprima a soma. print('Soma de valores...\n') num1 = float(input('Digite um número: ')) num2 = float(input('Digite outro número: ')) soma = num1 + num2 #%s = string #%d = inteiros #%f = floats #%g = genéricos print('O resultado da...
false
f9b9cc936f7d1596a666d0b0586e05972e94cefa
jamiekiim/ICS4U1c-2018-19
/Working/practice_point.py
831
4.375
4
class Point(): def __init__(self, px, py): """ Create an instance of a Point :param px: x coordinate value :param py: y coordinate value """ self.x = px self.y = py def get_distance(self, other_point): """ Compute the distance between the...
true
318a80ce77b542abc821fa8ff2983b0760da2838
aaronstaclara/testcodes
/palindrome checker.py
538
4.25
4
#this code will check if the input code is a palindrome print('This is a palindrome checker!') print('') txt=input('Input word to check: ') def palindrome_check(txt): i=0 j=len(txt)-1 counter=0 n=int(len(txt)/2) for iter in range(1,n+1): if txt[i]==txt[j]: counte...
true
f0754dfa5777cd2e69afa26e2b73b216d0ff5313
sb1994/python_basics
/vanilla_python/lists.py
346
4.375
4
#creating lists #string list friends = ["John","Paul","Mick","Dylan","Jim","Sara"] print(friends) #accessing the index print(friends[2]) #will take the selected element and everyhing after that print(friends[2:]) #can select a range for the index print(friends[2:4]) #can change the value at specified index friends[...
true
1deb78c1b1af35d46bf3fef07643a25ba7a1c5f1
naveen882/mysample-programs
/classandstaticmethod.py
2,569
4.75
5
""" Suppose we have a class called Math then nobody will want to create object of class Math and then invoke methods like ceil and floor and fabs on it.( >> Math.floor(3.14)) So we make them static. One would use @classmethod when he/she would want to change the behaviour of the method based on which subclass is call...
true
fc8bde15b9c00120cb4d5b19920a58e288100686
CHemaxi/python
/003-python-modules/008-python-regexp.py
2,984
4.34375
4
""" MARKDOWN --- Title: python iterators and generators MetaDescription: python regular, expressions, code, tutorials Author: Hemaxi ContentName: python-regular-expressions --- MARKDOWN """ """ MARKDOWN # PYTHON REGULAR EXPRESSIONS BASICS * Regular Expressions are string patterns to search in other strings * PYTHON Re...
true
bcd7c3ee14dd3af063a6fea74089b02bade44a1c
hussein343455/Code-wars
/kyu 6/Uncollapse Digits.py
729
4.125
4
# ask # You will be given a string of English digits "stuck" together, like this: # "zeronineoneoneeighttwoseventhreesixfourtwofive" # Your task is to split the string into separate digits: # "zero nine one one eight two seven three six four two five" # Examples # "three" --> "three" # "eightsix" ...
true
ab31c3e1a33bbe9ec2eb8ef5235b2206c022a8d7
kritikhullar/Python_Training
/day1/factorial.py
288
4.25
4
#Fibonacci print("-----FIBONACCI-----") a= int(input("Enter no of terms : ")) def fibonacci (num): if num<=1: return num else: return (fibonacci(num-1)+fibonacci(num-2)) if a<=0: print("Enter positive") else: for i in range(a): print (fibonacci(i), end = "\t")
false
64e73cb395d25b53a166a6e491e70a7834c96aee
sajjadm624/Bongo_Python_Code_Test_Solutions
/Bongo_Python_Code_Test_Q_3.py
2,330
4.1875
4
# Data structure to store a Binary Tree node class Node: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right # Function to check if given node is present in binary tree or not def isNodePresent(root, node): # base case 1 ...
true
92156b23818ebacfa3138e3e451e0ed11c0dd343
brianspiering/project-euler
/python/problem_025.py
1,139
4.375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Solution to "1000-digit Fibonacci number", Problem 25 http://projecteuler.net/problem=25 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6...
true
5448d28db97a609cafd01e68c875affe1f97723c
brianspiering/project-euler
/python/problem_004.py
992
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Solution to "Largest palindrome product", aka Problem 4 http://projecteuler.net/problem=4 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the...
true
bd009da4e937a9cfc1c5f2e7940ca056c1969ae5
brianspiering/project-euler
/python/problem_024.py
1,489
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Solution to "Lexicographic permutations", Problem 24 http://projecteuler.net/problem=24 A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or...
true
5e2ae02f6553cbe7c31995ba76abf564c596d346
serenechen/Py103
/ex6.py
767
4.28125
4
# Assign a string to x x = "There are %d types of people." % 10 # Assign a string to binary binary = "binary" # Assign a string to do_not do_not = "don't" # Assign a string to y y = "Those who knows %s and those who %s." % (binary, do_not) # Print x print x # Print y print y # Print a string + value of x print "I sai...
true