blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
cb48aff62616fd3fe4888d6a4fde3aef185d99c1
pancakewaffles/Stuff-I-learnt
/Python Refresher/Python Math/1 Numbers, Fractions, Complex, Factors, Roots, Unit Conversion/quadraticRootsCalc.py
517
4.15625
4
#! quadraticRootCalc.py # Finds roots of quadratic equations, including even complex roots! def roots(a,b,c): # a,b,c are the coefficients D = (b*b - 4*a*c)**0.5; x_1 = (-b+D)/(2*a); x_2 = (-b-D)/(2*a); print("x1: {0}".format(x_1)); print("x2: {0}".format(x_2)); #print("x1: %f"%(x_1)); Doesn'...
true
4e8a52d1b2563727ac655e2c84ad0b80af626e29
fpert041/experiments_in_ML_17
/LB_02_TestEx.py
1,274
4.21875
4
#PRESS <Ctrl>+<Enter> to execute this cell #%matplotlib inline #In this cell, we load the iris/flower dataset we talked about in class from sklearn import datasets import matplotlib.pyplot as plt iris = datasets.load_iris() # view a description of the dataset print(iris.DESCR) %matplotlib inline #above: directive ...
true
1adb144238abf3ad518e644c680a44e7b66cca15
ianjosephjones/Python-Pc-Professor
/8_11_21_Python_Classs/Exercise_5-11.py
723
4.5625
5
""" 5-11: Ordinal Numbers --------------------- Ordinal numbers indicate their position in a list, such as 1st or 2nd. Most ordinal numbers end in th, except 1, 2, and 3. Store the numbers 1 through 9 in a list. Loop through the list. Use an if-elif-else chain inside the loop to print the proper ordinal ending for each...
true
15a517a5443e03e322d9c2fbfcdbb31c9418cf25
awesomeleoding1995/Python_Learning_Process
/python_crash_course/chapter-9/user.py
1,773
4.125
4
class User(): """this class is used to create user-related profile""" def __init__(self, first_name, last_name): self.f_name = first_name self.l_name = last_name self.login_attempts = 0 def describe_user(self): formatted_name = self.f_name + " " + self.l_name return formatted_name.title() def greet_use...
true
27dc85dad52a603c8df7ca93ef2f35da27ed262d
danielvillanoh/conditionals
/secondary.py
2,425
4.59375
5
# author: Daniel Villano-Herrera # date: 7/23/2021 # --------------- # Section 2 # --------------- # # ---------- # Part 1 # ---------- # print('----- Section 2 -----'.center(25)) print('--- Part 1 ---'.center(25)) # 2 - Palindrome print('\n' + 'Task 1' + '\n') # # Background: A palindrome is a word that is the same...
true
b74184838111476129625eb2f3b1f26e6f189b4f
interviewprep/InterviewQuestions
/stacksandqueues/python/reverse_parentheses.py
1,304
4.15625
4
# You are given a string s that consists of lower case English letters and brackets. # Reverse the strings in each pair of matching parentheses, starting from the innermost one. # Your result should not contain any brackets. # Example 1: # # Input: s = "(abcd)" # Output: "dcba" # # Example 2: # # Input: s = "(u(love)...
true
66af55819c15092e3431065410c26c302cf2e279
Tayyab-Ilahi12/Python-Programs-for-practice
/FlashCard Game.py
1,900
4.46875
4
""" This flashcard program allows the user to ask for a glossary entry. In response,if user select show flash card the program randomly picks an entry from all glossary entries. It shows the entry. After the user presses return, the program shows the definition of that particular entry. If user select show_defi...
true
4f58cdbfa6c6e24a07ad1305632cca0e50dfb70b
Ananya31-tkm/PROGRAMMING_LAB_PYTHON
/CO2/CO2-Q1.py
213
4.1875
4
n=int(input("enter number:")) fact=1 if n<0: print("cannot find factorial") elif n==0: print("Factorial is 0") else: for i in range(1,n+1): fact=fact*i print("Fctorial of ",n," is",fact)
true
a22fca2b62384a297e2feea5dbfa57a3dc509313
ArtHouse5/python_progs
/simple_tasks.py
2,303
4.21875
4
#1 print('Create list of 6 numbers and sort it in ascending order') l=[4,23,15,42,16,8] print('The initial list is ',l) l.sort() print(l) print() #2 print('Create dictionary with 5 items int:str and print it pairwise') d = {1 : 'one', 2 : 'two', 3 : 'three', 4 : 'four', 5 : 'five'} print('The initial dictionaty is ',d...
true
d16fca91d7550b7a22417b6730d2d92cde1b217b
annamaryjacob/Python
/OOP/Polymorphism/2str.py
508
4.25
4
class Person(): def setPerson(self,age,name): self.age=age self.name=name def __str__(self): return self.name+str(self.age) ob=Person() ob.setPerson(25,"name") print(ob) #When we give print(ob) we get '<__main__.Person object at 0x7f92fee45ba8>'. This is the method called 2string met...
true
6c048cc77e200c6e6a379addf34afc63bf910e5a
mherr77m/pg2014_herrera
/HW2/HW2_q1.py
1,280
4.3125
4
# !env python # Michael Herrera # 10/18/14 # HW2, Problem 1 # Pass the function two arrays of x,y points and returns # the distance between all the points between the two arrays. import numpy as np def distance(array1,array2): """ Calculates the distance between all points in two arrays. The arrays don't...
true
ca7c7c91bf638b4e18660677fe8fb4f7630c4c01
Neenu1995/CHPC-PYTHON
/bisection_cuberoot.py
322
4.125
4
number = input('Enter the number : ' ) number = float(number) change = 0.00001 low =0.0 high = max(1.0,number) mid = (low+high)/2.0 while (abs(mid**3-number)>=change): if mid**3<number: low = mid else: high = mid mid =(low+high)/2.0 print 'The cube root of ', number ,' is ', mid...
true
185abd0b12115a2cf3f91ac799fccc664c403a14
LessonsWithAri/textadv
/next.py
1,803
4.15625
4
#!/usr/bin/env python3 INVENTORY = [] room_learning_took_soda = False def room_learning(): global room_learning_took_soda print("You are in room #312. You see a Kellan, a Maria, and a Brooke.") if not room_learning_took_soda: print("There is a can of soda on the table.") print("Exits: DOOR") comma...
true
6a8b4dab5c7639a003dc530cb9d4bf6c5fb5c552
Michaeloye/python-journey
/simp-py-code/Password_Validation_sololearn.py
1,044
4.40625
4
# Password Validation : You are interviewing to join a security team. They want to see you build a password evaluator for your technical interview to validate #the input. #task: Write a program that takes in a string as input and evaluates it as a valid password. The password is valid if it has a minimum 2 numbers, 2 ...
true
9940f0e66b71ed701e9ee4440772a39b4f0d8726
Michaeloye/python-journey
/simp-py-code/Tkinter_trial_DL.py
2,046
4.5625
5
from tkinter import * # Import all definitions from tkinter window = Tk() # Create a window label = Label(window, text = "Welcome to Python") # Create a label button = Button(window, text = "Click Me") # Create a button label.pack() # Place the label in the window button.pack() # Place the button in the window window...
true
338d446f53b76308220122fdd2b1115eaf3906db
Michaeloye/python-journey
/simp-py-code/raise_to_power.py
588
4.40625
4
#raise to power base_num = int(input("Enter the base number: ")) pow_num = int(input("Enter the power number: ")) def raise_to_power(base_num, pow_num): result = 1 for num in range(pow_num): '''since the pow_num is what the base_num will multiply itself by. so pow_num if 3 will cause the code lo...
true
a68f609d435c84d30dc569699894df16d8db9354
Michaeloye/python-journey
/simp-py-code/New_driver's_license_sololearn.py
1,372
4.1875
4
# New Driver's License #You have to get a new driver's license and you show up at the office at the same time as 4 other people. The office says that they will see everyone in #alphabetical order and it takes 20 minutes for them to process each new license. All of the agents are available now and they can each see one...
true
24f8a43e73503662cd2a930ad44a5fe1cb29e16f
Michaeloye/python-journey
/simp-py-code/task21.py
658
4.125
4
# Bob has a strange counter. At the first second t=1, it displays the number 3. At each subsequent second, the number displayed by the counter decrements by 1. # the counter counts down in cycles. In the second after the counter counts down to 1, the number becomes 2 times the initial number for that countdown cycle # ...
true
25b83260765a26cab0ba821ad5b69b5161ffc171
Michaeloye/python-journey
/simp-py-code/task7.py
672
4.1875
4
# Given a string input count all lower case, upper case, digits, and special symbols def findingchars(string): ucharcount = 0 lcharcount = 0 intcount = 0 symcount = 0 for char in string: if char.isupper(): ucharcount+=1 elif char.islower(): lcharcount+=1 ...
true
a802e0447e69c9e42b353305575d0762fcbc3f86
fish-py/PythonImpl
/collections/dict.py
237
4.125
4
dict1 = { "firstName": "Jon", "lastName": "Snow", "age": 33 } """ 遍历dict """ for key in dict1.keys(): print(key) for value in dict1.values(): print(value) for key, value in dict1.items(): print(key, value)
true
e58d6c0bc2831729f65f722de7e4bb30b7291a4b
DanielSouzaBertoldi/codewars-solutions
/Python/7kyu/Isograms/solution.py
508
4.15625
4
# Calculates the ocurrence of every letter of the word. # If it can't find more than one ocurrence for every letter, # then it's an isogram. def is_isogram(string): string = string.lower() for char in string: if string.count(char) > 1: return False return True # That was my first try a...
true
b20046be773df17575d2c87213cc2c55aa70e186
n8951577/scrapy
/factorial.py
253
4.1875
4
def factorial(x): if x == 1: return 1 else: return x * factorial(x - 1) try: n = int(input("enter a number to find the factorial of a digit")) print ("The factorial of n is %d" % factorial(n)) except: print("Invalid")
true
dc0d64d1c54a204ecebbb0a589f354f13447c876
priyanshi1996/Advanced_Python_Course
/Ex_Files_Adv_Python/Exercise Files/04 Collections/defaultdict_finished.py
1,272
4.5
4
# Demonstrate the usage of defaultdict objects from collections import defaultdict def main(): # define a list of items that we want to count fruits = ['apple', 'pear', 'orange', 'banana', 'apple', 'grape', 'banana', 'banana'] fruitCount = {} # Count the elements in the list # This...
true
5af4158a8ff3d270b35e6b6b02332ca3cb82ce43
IfthikarAliA/python
/Beginner/3.py
261
4.125
4
#User input no. of Element a=int(input("Enter the number of Element: ")) #Empty List l=[] #Function to get list of input for i in range(a): l.append(int(input(f"Enter the {i+1} item: "))) #Iterator over a list for i in l: if(i%2==0): print(i)
true
f707d8fc6cf42c70d569c187792d1fa674f17bc0
austindrenski/GEGM-Programming-Meetings
/ProgrammingMeeting1_Python/Example.py
428
4.125
4
class Example: """Represents an example.""" def __init__(self, value): self.value = value def increase_value(self, amount): """Increases the value by the specified amount.""" self.value = self.value + amount return self.value > 0 def __repr__(self): """Returns a...
true
663c8604ccf16d20dd92c597ba4b5f33fd26bb39
austinrhode/SI-Practical-3
/shortest_word.py
488
4.4375
4
""" Write a function that given a list of word, will return a dictionary of the shortest word that begins will each letter of the alphabet. For example, if the list is ["Hello", "hi", "Goodbye", "ant", "apple"] your dictionary would be { h: "Hi", g: "Goodbye", a: "ant" } because those are the shortest wo...
true
3f63aac86bed8b98276e9850fbb00421121d6eae
BridgitA/Week10
/mod3.py
713
4.125
4
maximum_order = 150.00 minimum_order = 5.00 def cheese_program(order_amount): if order_amount.isdigit() == False: print("Enter a numeric value") elif float(order_amount) > maximum_order: print(order_amount, "is more than currently available stock") elif float(order_amount) < minimum_order...
true
f8293c7294cc10da6dab7dfedf7328c865f899fe
michellesanchez-lpsr/class-sampless
/4-2WritingFiles/haikuGenerator.py
794
4.3125
4
# we are writing a program that ask a user for each line of haiku print("Welcome to the Haiku generator!") print("Provide the first line of your haiku:") # create a list to write to my file firstL = raw_input() print(" ") print("Provide the second line of your haiku:") secondL = raw_input() print(" ") print("Provide...
true
9e20d9bab577aba6e39590e3365b56b9325dd32a
michellesanchez-lpsr/class-sampless
/msanchez/university.py
584
4.1875
4
# print statements print(" How many miles away do you live from richmond state?") miles = raw_input() miles = int(miles) #if else and print statements if miles <=30: print("You need atleast 2.5 gpa to get in") else: print("You need atleast 2.0 gpa to get in") print(" What is your gpa?") gpa = float(raw_input()) gpa...
true
5ff742b0b2ec95157cc738b9668d911db3ee6e7e
ceden95/self.py
/temperature.py
445
4.46875
4
#the program convert degrees from F to C and the opposite. temp = input("Insert the temperature you would like to convert(with a 'C' or 'F' mark):") temp_type = temp[-1].upper() temp_number = float(temp[:-1]) C_to_F = str(((9*temp_number)+(160))/5) F_to_C = str((5*temp_number-160)/9) if (temp_type == "C"): pr...
true
76f0e060b29af72dd5420918b10a0b2034073891
ceden95/self.py
/9.3.1.fileFor_listOfSongs.py
2,791
4.34375
4
#the program uses the data of file made from a list of songs details in the following structure: #song name;artist\band name;song length. #the function my_mp3_playlist in the program returns a tuple of the next items: #(name of the longest song, number of songs in the file, the most played artist) def main(): ...
true
266f1eef9643832e942c30fec52406331b26b8ae
ceden95/self.py
/for_loop.py
816
4.3125
4
#the program creates a new list(from the list the user created) of numbers bigger then the number the user choosed. def main(): list1 = input('type a sequence of random numbers devided by the sign ",": ') my_list = list1.split(",") n = int(input("type a number which represent the smallest number in yo...
true
f55a6562de4c30e76723c61ef0a3a60ef178bec2
ceden95/self.py
/shift_left.py
713
4.4375
4
#the program prints the new list of the user when the first item moving to the last on the list. def shift_left(my_list): """the func receives a list, replace the items on the list with the item on the left :param my_list: list from user. :type my_list: list. :return: my_shift_list :rtype: l...
true
c32e466c8f7004bc5e9b8fd23cfe9714d39cad09
Andrewctrl/Final_project
/Visting_Mom.py
744
4.25
4
import Visting_mom_ending import Getting_help def choice(): print("You get dressed up quicky as you rush out to visit your mom in the hospital. " + "You visit your mom in the hospital, she is doing well. But you have a pile of bills. You get a job working at In-and-Out. Balancing work and school is hard, your grad...
true
ea5a201812b6f4ad9ba49505a53e99bcbf207a42
ar021/control-flow-lab
/exercise-2.py
305
4.15625
4
# exercise-02 Length of Phrase while True: phrase = input('Please enter a word or phrase or "quite" to Exit:') if phrase == 'quite': print('Goodbye') break else: phrase_length = len(phrase) print(f'What you entered is {phrase_length} characters long')
true
d2cc0691e0e05128e98144d19206b7a6f2df3f70
EVgates/VSAproject
/proj02/proj02_02.py
1,100
4.3125
4
# Name: # Date: # proj02_02: Fibonaci Sequence """ Asks a user how many Fibonacci numbers to generate and generates them. The Fibonacci sequence is a sequence of numbers where the next number in the sequence is the sum of the previous two numbers in the sequence. The sequence looks like this: 1, 1, 2, 3, 5, 8, 13....
true
0c6f697432c64e2ff1dfd39192c3e2d5d7938ba9
H0bbyist/hero-rpg
/hero_rpg.py
2,112
4.1875
4
from math import * #!/usr/bin/env python # In this simple RPG game, the hero fights the goblin. He has the options to: # 1. fight goblin # 2. do nothing - in which case the goblin will attack him anyway # 3. flee class Character: def alive(self): if self.health > 0: return True def attack...
true
e2af114dca2a51f5802980c84b596e2e794ae15e
Percapio/Algorithms-and-Data-Structures
/lib/algorithms/quick_sort.py
1,957
4.15625
4
# Quick Sort: # Sort an unsorted array/list by first indexing an element as the pivot point, # check if this index is our target. If not, then check if target is more than # the indexed point. If it is then we check the right half of the list, otherwise # we check the left half. ####################################...
true
48ff5efd50d6150ab8bf1b0e5e30fb7f0bd6e585
bhandarisudip/learn_python_the_hard_way_book_exercises
/ex6-studydrills.py
1,535
4.6875
5
#ex06-study drills #assign a string to x that includes a formatting character, which is then replaced by 10 x = "There are %d types of people."%10 #create a variable, binary, and assign the string "binary" to it binary = 'binary' #assign a new variable a string "don't" to a variable 'do_not' do_not = "don't" #cre...
true
a957213cad27ef8e8fcb5fcad84e18a9ff3ffa33
Arun-9399/Simple-Program
/binarySearch.py
550
4.15625
4
#Binary Search Algorithm def binarySearch(alist, item): first=0 last= len(alist)-1 found= False while first<= last and not found: midpoint= (first+last)//2 if alist[midpoint]== item: found= True else: if item<alist[midpoint]: last= mid...
true
342ddc75e963daefe5348880baeaee70eb1d58f1
nikita-sh/CSC148
/Lab 3/queue_client.py
1,219
4.375
4
""" Queue lab function. """ from csc148_queue import Queue def list_queue(lst: list, q: Queue): """ Takes all elements of a given list and adds them to the queue. Then, checks the queue for items that are not lists and prints them. If the item being checked is a list, it is added to the queue. This p...
true
677822cf2d9796a31de51f13477c5f31d097da76
hicaro/practice-python
/sorting/insertionsort.py
502
4.125
4
class InsertionSort(object): ''' Insertion Sort sorting algorithm implementation - Best case: O(n) - Average case: O(n^2) - Worst case: O(n^2) ''' @staticmethod def sort(numbers=None): _len = len(numbers) for i in range(1, _len): to_insert = numbe...
true
7df9e746b8e11f1e8d3dee1f840275f5e9763d68
ruchitiwari20012/PythonTraining-
/operators.py
693
4.53125
5
# Arithmetic Operators print(" 5+ 6 is ", 5+6) print(" 5- 6 is ", 5-6) print(" 5* 6 is ", 5*6) print(" 5/6 is ", 5/6) print(" 5//6 is ", 5//6) # Assignment Operator x=5 print(x) x+=7 print(x) x-=7 print(x) x/=7 print(x) #Comparison Operator i=8 print(i==5) print(i!=5)# i not equal to 5 print(i>=5...
true
f2121f4abcd95f8f5a98aaee6103f703cd5aa357
danismgomes/Beginning_Algorithms
/isPalindromeInt.py
603
4.15625
4
# isPalindrome # It verifies if a integer number is Palindrome or not answer = int(input("Type a integer number: ")) answer_list = [] while answer != 0: # putting every digit of the number in a list answer_list.append(answer % 10) # get the first digit answer = answer // 10 # remove the first digit def ...
true
d257b52336940b64bc32956911164029f56c5f22
maxz1996/mpcs50101-2021-summer-assignment-2-maxz1996
/problem3.py
1,587
4.40625
4
# Problem 3 # Max Zinski def is_strong(user_input): if len(user_input) < 12: return False else: # iterate through once and verify all criteria are met number = False letter = False contains_special = False uppercase_letter = False lowercase_letter = False...
true
56c94622c6852985b723bf52b0c2f20d2617f6c8
kaozdl/property-based-testing
/vector_field.py
2,082
4.125
4
from __future__ import annotations from typing import Optional import math class Vector: """ representation of a vector in the cartesian plane """ def __init__(self, start: Optional[tuple]=(0,0), end: Optional[tuple]=(0,0)): self.start = start self.end = end def __str__(self) ...
true
d629fb9d9ce965a27267cbc7db6a33662e0ff1d1
vusalhasanli/python-tutorial
/problem_solving/up_runner.py
403
4.21875
4
#finding runner-up score ---> second place if __name__ == '__main__': n = int(input("Please enter number of runners: ")) arr = map(int, input("Please enter runners' scores separated by space: ").split()) arr = list(arr) first_runner = max(arr) s = first_runner while s == max(arr): arr.r...
true
0844afed653ec7311aa6e269867e2723f131deca
atg-abhijay/Fujitsu_2019_Challenge
/EReport.py
1,374
4.34375
4
import pandas as pd def main(): """ main function that deals with the file input and running the program. """ df = pd.DataFrame() with open('employees.dat') as infile: """ 1. only reading the non-commented lines. 2. separating the record by ',' or ' ' into 3 ...
true
c3e6a8a88cce32769e8fe867b8e0c166255a8105
hansen487/CS-UY1114
/Fall 2016/CS-UY 1114/HW/HW6/hofai/q6.py
488
4.25
4
password=input("Enter a password: ") upper=0 lower=0 digit=0 special=0 for letter in password: if (letter.isdigit()==True): digit+=1 elif (letter.islower()==True): lower+=1 elif (letter.isupper()==True): upper+=1 elif (letter=='!' or letter=='@' or letter=='#' or letter=='$'): ...
true
d82eafc8998a0a3930ee2d868158da93fca0329b
hansen487/CS-UY1114
/Fall 2016/CS-UY 1114/HW/HW2/hc1941_hw2_q5.py
844
4.15625
4
""" Name: Hansen Chen Section: EXB3 netID: hc1941 Description: Calculates how long John and Bill have worked. """ john_days=int(input("Please enter the number of days John has worked: ")) john_hours=int(input("Please enter the number of hours John has worked: ")) john_minutes=int(input("Please enter the number of minu...
true
a7e9f749651d491f1c84f088ea128cbeaf18d9a5
lindsaymarkward/cp1404_2018_2
/week_05/dictionaries.py
505
4.125
4
"""CP1404 2018-2 Week 05 Dictionaries demos.""" def main(): """Opening walk-through example.""" names = ["Bill", "Jane", "Sven"] ages = [21, 34, 56] print(find_oldest(names, ages)) def find_oldest(names, ages): """Find oldest in names/ages parallel lists.""" highest_age = -1 highest_age_...
true
d0b18dd59833733b72f5ef43a9b3d53ea0d1d429
Abarna13/Floxus-Python-Bootcamp
/ASSIGNMENT 1/Inverted Pattern.py
278
4.21875
4
''' Write a python program to print the inverted pyramid? * * * * * * * * * * * * * * * ''' #Program rows = 5 for i in range(rows,0,-1): for j in range(0,rows-1): print(end="") for j in range(0,i): print("*",end= " ") print()
true
d9918e166dc1f669bed7f96b01cce30470f0a85a
nealsabin/CIT228
/Chapter5/hello_admin.py
599
4.21875
4
usernames = ["admin","nsabin","jbrown","arodgers","haaron"] print("------------Exercise 5-8------------") for name in usernames: if name == "admin": print("Hello, admin. Would you like to change any settings?") else: print(f"Hello, {name}. Hope you're well.") print("------------Exercise 5-9---...
true
31d8a9230ed12e4d4cb35b2802a9c721c1d23d15
nealsabin/CIT228
/Chapter9/restaurant_inheritance.py
1,049
4.21875
4
#Hands on 2 #Exercise 9-2 print("\n----------------------------------------------------------") print("-----Exercise 9-6-----\n") class Restaurant: def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self.number_served =...
true
5e2463436e602ab6a8764adee0e48605f50a7241
Jay07/CP2404
/billCalc.py
252
4.125
4
print("Electricity Bill Estimator") Cost = float(input("Enter cents per kWh: ")) Usage = float(input("Enter daily use in kWh: ")) Period = float(input("Enter number of billing days: ")) Bill = (Cost*Usage*Period)/100 print("Estimated Bill: $", Bill)
true
42c4caab27c4cdd3afc59c6270f372c6e388edb3
mvanneutigem/cs_theory_practice
/algorithms/quick_sort.py
1,936
4.40625
4
def quick_sort(arr, start=None, end=None): """Sort a list of integers in ascending order. This algorithm makes use of "partitioning", it recursively divides the array in groups based on a value selected from the array. Values below the selected value are on one side of it, the ones above it on the ...
true
1c7605d505ea2a2176883eaba72cfc04ff2fb582
knowledgewarrior/adventofcode
/2021/day1/day1-p1.py
1,590
4.40625
4
''' As the submarine drops below the surface of the ocean, it automatically performs a sonar sweep of the nearby sea floor. On a small screen, the sonar sweep report (your puzzle input) appears: each line is a measurement of the sea floor depth as the sweep looks further and further away from the submarine. For exampl...
true
2c05503575eccf27161b3217d13da4027c91affb
dharunsri/Python_Journey
/Inheritance.py
738
4.3125
4
# Inheritance # Accessing another classes is calles inheritance class Songs: # Parent class / super class def name(self): print("People you know") def name2(self): print("Safe and sound") class selena(Songs): # Child class/ sub class - ...
true
aabb79dc9eb7d394bf9a87cd51d9dacde5eabf3e
dharunsri/Python_Journey
/Python - Swapping of 2 nums.py
1,286
4.3125
4
# Swapping of two numbers a = 10 # 1010 b = 20 # 10100 # Method 1 temp = a a = b b = temp print(" Swapping using a temporary variable is : " ,'\n',a, '\n',b) # Method 2 a = a+b # 10 + 20 = 30 b = a-b # 30 - 20 = 10 a = a-b # 30 - 10 = 20 pr...
true
2dd468406342dc6e8f767ba6d469613b19eed0ad
samanthamirae/Journey
/Python/OrderCostTracking.py
2,862
4.25
4
import sys totalOrders = 0 #tracks number of orders in the batch batchCost = 0 #tracks the total cost across all orders in this batch # our functions def orderprice(wA,wB,wC): #calculates the cost total of the order cTotal = 2.67 * wA + 1.49 * wB + 0.67 * wC if cTotal > 100: cTotal = cTota...
true
788e78bede5679bcb0f93f4642602520baead921
shirisha24/function
/global scope.py
372
4.1875
4
# global scope:-if we use global keyword,variable belongs to global scope(local) x="siri" def fun(): global x x="is a sensitive girl" fun() print("chinni",x) # works on(everyone) outside and inside(global) x=2 def fun(): global x x=x+x print(x) fun() print(x) # another example x=9 def fun() : ...
true
9332d185e61447e08fc1209f52ae41cecdc90132
mchoimis/Python-Practice
/classroom3.py
701
4.3125
4
print "This is the grade calculator." last = raw_input("Student's last name: ") first = raw_input("Student's first name: ") tests = [] test = 0 #Why test = 0 ? while True: test = input("Test grade: ") if test < 0: break tests.append(test) total = 0 ...
true
7fb16ee09b9eb2c283b6e6cd2b2cabab06396a58
mchoimis/Python-Practice
/20130813_2322_len-int_NOTWORKING.py
1,302
4.1875
4
""" input() takes values raw_input() takes strings """ # Asking names with 4-8 letters name = raw_input("Choose your username.: ") if len(name) < 4: print "Can you think of something longer?" if len(name) > 8: print "Uhh... our system doesn't like such a long name." else: print 'How are you, ', nam...
true
f91a713fff27f167f0c6e9924a2f8b39b5d99cd3
Manuferu/pands-problems
/collatz.py
919
4.40625
4
# Manuel Fernandez #program that asks the user to input any positive integer and outputs the successive values of the following calculation. # At each step calculate the next value by taking the current value and, if it is even, divide it by two, but if it is odd, # multiply it by three and add one. Have the program...
true
5a388d39dbab1a59a8bf51df96b26eb51192e70e
manojkumarpaladugu/LearningPython
/Practice Programs/largest_num.py
358
4.53125
5
#Python Program to Find the Largest Number in a List num_list = [] n = input("Enter no. of elements:") print("Enter elements") for i in range(n): num = input() num_list.append(num) print("Input list is: {}".format(num_list)) big = 0 for i in num_list: if i > big: big = i print("Largest num...
true
4655d4a9c07fdc83d990068507bb7a614bee7321
manojkumarpaladugu/LearningPython
/Practice Programs/print_numbers.py
310
4.34375
4
#Python Program to Print all Numbers in a Range Divisible by a Given Number print("Please input minimum and maximum ranges") mini = input("Enter minimum:") maxi = input("Enter maximum:") divisor = input("Enter divisor:") for i in range(mini,maxi+1,1): if i % divisor == 0: print("%d" %(i))
true
35b61f8813afb1b2f2fcbed2f6f0e9cb97097503
manojkumarpaladugu/LearningPython
/Practice Programs/second_largest.py
377
4.4375
4
#Python Program to Find the Second Largest Number in a List num_list = [] n = input("Enter no. of elements:") print("Enter elements:") for i in range(n): num_list.append(input()) print("Input list is: {}".format(num_list)) num_list.sort(reverse=True) print("The reversed list is: {}".format(num_list)) p...
true
56b022638dff063eefcda1b732613b1441b0bde3
vinromarin/practice
/python/coursera-programming-for-everbd/Exercise_6-3.py
402
4.125
4
# Exercise 6.3 Encapsulate this code in a function named count, and generalize it # so that it accepts the string and the letter as arguments. def count(str, symbol): count = 0 for letter in str: if letter == symbol: count = count + 1 return count str_inp = raw_input("Enter string:") smb...
true
e70a3ca8aeb66c993ba550fa3261f51f5c4ea845
PurneswarPrasad/Good-python-code-samples
/collections.py
2,017
4.125
4
#Collections is a module that gives container functionality. We'll discuss their libraries below. #Counter from collections import Counter #Counter is a container that stores the elemnts as dictionary keys and their counts as dictionary values a="aaaaaabbbbcc" my_counter=Counter(a) #makes a dictionary of a print(my_c...
true
3798ed579d458994394902e490bd4afb781c843d
petr-jilek/neurons
/models/separationFunctions.py
1,055
4.25
4
import math """ Separation and boundary function for dataGenerator and separators. Separation function (x, y): Return either 1 or 0 in which region output is. Boundary function (x): Return value of f(x) which describing decision boundary for learning neural network. """ # Circle separation and boundary functions. # ...
true
dc11626d5790450752c98f192d4ddee383b21aae
teebee09/holbertonschool-higher_level_programming
/0x03-python-data_structures/3-print_reversed_list_integer.py
227
4.59375
5
#!/usr/bin/python3 def print_reversed_list_integer(my_list=[]): "prints all integers of a list, in reverse order" if my_list: for n in range(0, len(my_list)): print("{:d}".format(my_list[(-n) - 1]))
true
4a4c9eb5d19396aa917b6ea5e9e74ab168b7287d
jramos2153/pythonsprint1
/main.py
2,176
4.40625
4
"""My Sweet Integration Program""" __author__ = "Jesus Ramos" #Jesus Ramos # In this program, users will be able to solve elementary mathematical equations and graph. name = input("Please enter your name: ") print("Welcome", name, "!") gender = input("Before we start, tell us a bit about your self. Are you male or fe...
true
06f51bde337c4f60bae678ada677654c4bab7afd
ramjilal/python-List-Key-concept
/shallow_and_deep_copy_list.py
1,400
4.53125
5
#use python 2 #first simple copy of a list, List is mutable so it can be change by its copy. x = [1,2,3] y = x # here list 'y' and list 'x' point to same content [1,2,3]. y[0]=5 # so whenever we will change list 'y' than list 'x' would be change. print x #print -> [5,2,3] print y #print -> [5,2,3] #...
true
00c319cb96b7c226943266109c4e48c723fc4ff5
bhargavpydimalla/100-Days-of-Python
/Day 1/band_generator.py
487
4.5
4
#1. Create a greeting for your program. print("Hello there! Welcome to Band Generator.") #2. Ask the user for the city that they grew up in. city = input("Please tell us your city name. \n") #3. Ask the user for the name of a pet. pet = input("Please tell us your pet's name. \n") #4. Combine the name of their city a...
true
7a183fdbe4e63ee69c2c204bfaa69be6e7e29933
demelziraptor/misc-puzzles
/monsters/monsters.py
2,634
4.125
4
import argparse from random import randint """ Assumptions: - Two monsters can start in the same place - If two monsters start in the same place, they ignore eachother and start by moving! - All monsters move at each iteration - For some reason, the monsters always move in the same order... - This monster world runs p...
true
d927fecd196dab0383f022b4a5669a47e7f9fb37
Oyelowo/GEO-PYTHON-2017
/assignment4/functions.py
2,671
4.40625
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 27 11:15:48 2017 @author: oyeda """ ##You should do following (also criteria for grading): #Create a function called fahrToCelsius in functions.py #The function should have one input parameter called tempFahrenheit #Inside the function, create a variable called converte...
true
8913aa3c08840276a068ebe6b6d6d69afe519167
AndrewKalil/holbertonschool-machine_learning
/unsupervised_learning/0x02-hmm/1-regular.py
2,114
4.28125
4
#!/usr/bin/env python3 """ Regular Markov chain """ import numpy as np def markov_chain(P, s, t=1): """determines the probability of a markov chain being in a particular state after a specified number of iterations Args: P is a square 2D numpy.ndarray of shape (n, n) represent...
true
26144b4784b9602b473a8d1da19fe8b568fdc662
blackdragonbonu/ctcisolutions
/ArrayStringQ3.py
948
4.4375
4
''' The third question is as follows Write a method to decide if two strings are anagrams or not. We solve this by maintaining counts of letters in both strings and checking if they are equal, if they are they are anagrams. This can be implemented using a dictionary of byte array of size 26 ''' from collections impor...
true
6aa56313f436099121db045261afc16dbcac9595
Adrianbaldonado/learn_python_the_hard_way
/exercises/exercise_11.py
304
4.25
4
"""Asking Qestions The purpose of this exercise is to utilize all ive learned so far """ print("How old are you?", end=' ') age = (' 22 ') print("How tall are you?", end=' ') height = ( 5 ) print("How do you weigh?", end=' ') weight = ('160') print(f"So, you're{age} old, {height} tall and {weight}")
true
18b210811e067834d980f7b80b886d36e060d65b
deepikaasharma/unpacking-list
/main.py
310
4.34375
4
# Create a list some_list = ['man', 'bear', 'pig'] # Unpack the list man, bear, pig = some_list ''' The statement above is equivalent to: man = some_list[0] bear = some_list[1] pig = some_list[2] ''' # Show that the variables represent the values of the original list print(man, bear, pig) print(some_list)
true
9ee2d6ea090f939e7da651d7a44b204ff648168a
ShumbaBrown/CSCI-100
/Programming Assignment 3/guess_the_number.py
874
4.21875
4
def GuessTheNumber(mystery_num): # Continually ask the user for guesses until they guess correctly. # Variable to store the number of guesses guesses = 0 # loop continually ask the user for a guess until it is correct while (True): # Prompt the user of a guess guess = int(input('En...
true
d02467d8e5ec22b8daf6e51b007280d3f4c8a245
malav-parikh/python_programming
/string_formatting.py
474
4.4375
4
# leaning python the hard way # learnt the basics # string formatting using f first_name = 'Malav' last_name = 'Parikh' middle_name = 'Arunkumar' print(f"My first name is {first_name}") print(f"My last name is {last_name}") print(f"My middle name is {middle_name}") print(f"My full name is {first_name} {middle_name}...
true
e4e80522ce19e03c1c6bceee954741d324d79b44
ffabiorj/desafio_fullstack
/desafio_parte_1/question_1.py
504
4.1875
4
def sum_two_numbers(arr, target): """ The function receives two parameters, a list and a target. it goes through the list and checks if the sum of two numbers is equal to the target and returns their index. """ number_list = [] for index1, i in enumerate(arr): for index2, k...
true
58f0290c093677400c5a85267b1b563140feda85
FrancescoSRende/Year10Design-PythonFR
/FileInputOutput1.py
1,512
4.53125
5
# Here is a program that shows how to open a file and WRITE information TO it. # FileIO Example 3 # Author: Francesco Rende # Upper Canada College # Tell the user what the program will do... print ("This program will open a file and write information to it") print ("It will then print the contents to the screen for y...
true
2306ffb05eecd0dc048f36c8359b7684178f0634
MuhammadRehmanRabbani/Python
/Average of 2D Array python/average.py
1,260
4.28125
4
# defining the average function def average(matrix,matrix_size): my_sum = 0 # declaring variable to store sum count = 0 # declaring variable to count total elements of 2D array # this for loop is calculating the sum for i in range(0, matrix_size): for j in range(0, matrix_size): ...
true
356a8c8ecc88afd964c5a83dc438890a3326b483
girishsj11/Python_Programs_Storehouse
/Daily_coding_problems/daily_coding_2.py
737
4.125
4
''' Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expect...
true
9d3dad6f365a6e73d00d90411f80a1a6e165f0cf
girishsj11/Python_Programs_Storehouse
/codesignal/strstr.py
1,378
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 26 12:33:18 2021 @author: giri """ ''' Avoid using built-in functions to solve this challenge. Implement them yourself, since this is what you would be asked to do during a real interview. Implement a function that takes two strings, s and x, as a...
true
1f75ec5d58684cd63a770bd63c7aab3ee7b26de6
girishsj11/Python_Programs_Storehouse
/codesignal/largestNumber.py
569
4.21875
4
''' For n = 2, the output should be largestNumber(n) = 99. Input/Output [execution time limit] 4 seconds (py3) [input] integer n Guaranteed constraints: 1 ≤ n ≤ 9. [output] integer The largest integer of length n. ''' def largestNumber(n): reference = '9' if(n==1): return int(reference) eli...
true
478ed1b0685ac4fda3e3630472b2c05155986d50
girishsj11/Python_Programs_Storehouse
/codesignal/Miss_Rosy.py
2,510
4.15625
4
''' Miss Rosy teaches Mathematics in the college FALTU and is noticing for last few lectures that the turn around in class is not equal to the number of attendance. The fest is going on in college and the students are not interested in attending classes. The friendship is at its peak and students are taking turns fo...
true
b986d60ff29d4cf7ff66d898b5f0f17a29a168cb
girishsj11/Python_Programs_Storehouse
/prime_numbers_generations.py
577
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 14 16:00:24 2021 @author: giri """ def is_prime(num): """Returns True if the number is prime else False.""" if num == 0 or num == 1: return False for x in range(2, num): if num % x == 0: return False ...
true
8b6aad04e70312c2323d1a8392cef1bc10587b2e
Stone1231/py-sample
/loop_ex.py
413
4.125
4
for i in [0, 1, 2, 3, 4]: print(i) for i in range(5): print(i) for x in range(1, 6): print(x) for i in range(3): print(i) else: print('done') #A simple while loop current_value = 1 while current_value <= 5: print(current_value) current_value += 1 #Letting the user choose when to qu...
true
ded47265e7eda94698d63b24bd4665b2e8afb16e
mikvikpik/Project_Training
/whitespace.py
308
4.1875
4
"""Used in console in book""" # Print string print("Python") # Print string with whitespace tab: \t print("\tPython") # Print multiple whitespaces and strings print("Languages:\nPython\nC\nJavaScript") # variable set to string and call variable without print favorite_language = "python" favorite_language
true
7791023ad7a3561d91401b22faeff3fce3a1c7c8
EoinMcKeever/Test
/doublyLinkedListImplemention.py
1,028
4.4375
4
class Node: def __init__(self, data): self.data = data self.next = None self.previous = None class DoublyLinkedList: def __init__(self): self.head = None self.tail = None #insert at tail(end) of linked list def insert(self, data): new_node = Node(data) if self.head is None: self.head = new_node ...
true
6eb48816205257b528b1aefd8f03fa8206716aa9
sayee2288/python-mini-projects
/blackjack/src/Deck.py
1,401
4.1875
4
''' The deck class simulates a deck of cards and returns one card back to the player or the dealer randomly. ''' import random class Deck: ''' The deck class creates the cards and has functions to return a card or shuffle all cards ''' def __init__(self): print('Deck is ready for the game'...
true
0240991d2a500c398cfd17ea1ac3616d00dd09dd
Spandan-Madan/python-tutorial
/8_while_loops.py
2,147
4.40625
4
import random # ** While Loops ** # What if you want your code to do something over and over again until some # condition is met? # For instance, maybe you're writing code for a timer # and you want to keep checking how much time has passed until you have waited # the correct amount of time. # Then you should us...
true
e6bed67b87876e59d12ad8a0e2776649b169f3bf
Spandan-Madan/python-tutorial
/5_booleans.py
1,334
4.40625
4
# ** Boolean Comparisons ** print("Examples of boolean comparisons") # Python also supports logical operations on booleans. Logical operations take # booleans as their operands and produce boolean outputs. Keep reading to learn # what boolean operations Python supports. # And # The statement `a and b` evaluates t...
true
b6965d0d5ebe028780d4ba63d10d1c159fab97c7
jasonwee/asus-rt-n14uhp-mrtg
/src/lesson_text/re_groups_individual.py
407
4.1875
4
import re text = 'This is some text -- with punctuation.' print('Input text :', text) # word starting with 't' then another word regex = re.compile(r'(\bt\w+)\W+(\w+)') print('Pattern :', regex.pattern) match = regex.search(text) print('Entire match :', match.group(0)) print('Word ...
true
8025c47447a18c0f93b4c59c6c1191c6b0c6454a
shail0804/Shail-Project
/word_series.py
2,137
4.125
4
def Character_to_number(): """ This function converts a given (User Defined) Character to Number\ as per the given Pattern (2*(Previous Character) + counter) """ nb = input('please enter the character: ') nb = nb.upper() count = 1 sum = 0 for s in range(65,ord(nb)+1): sum = sum*2...
true
e8596535535979655079184dbf2d61899b8610b3
diptaraj23/TextStrength
/TextStrength.py
324
4.25
4
#Calculating strength of a text by summing all the ASCII values of its characters def strength (text): List=[char for char in text] # storing each character in a list sum=0 for x in List: sum=sum+ord(x) #Extracting ASCII values using ord() function and then adding it in a loop return...
true
1775f4ecf0c6270b6209dd68358899fa92c8387c
jasonchuang/python_coding
/27_remove_element.py
897
4.40625
4
''' Example 1: Given nums = [3,2,2,3], val = 3, Your function should return length = 2, with the first two elements of nums being 2. It doesn't matter what you leave beyond the returned length. Example 2: Given nums = [0,1,2,2,3,0,4,2], val = 2, Your function should return length = 5, with the first five elements of n...
true