blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ec5b56efd27c6d6c232e3c21f80bdccba626b68b
ramlingamahesh/python_programs
/conditionsandloops/FindNumbers_Divisible by Number.py
646
4.15625
4
# Python Program - Find Numbers divisible by another number print("Enter 'x' for exit."); print("Enter any five numbers: "); num1 = input(); if num1 == 'x': exit(); else: num2 = input(); num3 = input(); num4 = input(); num5 = input(); number1 = int(num1); number2 = int(num2); number3 = ...
true
5209c52949500091bda483d0b6b7fba199098637
shohanurhossainsourav/python-learn
/program28.py
341
4.375
4
matrix = [ [1, 2, 3], [4, 5, 6], ] print(matrix[0][2]) # print matrix value using nested loop matrix = [ [1, 2, 3], [4, 5, 6], ] for row in matrix: for col in row: print(col) matrix1 = [ [1, 2, 3], [4, 5, 6], ] # 0 row 2nd coloumn/3rd index value changed to 10 matrix1[0][2] = 10 ...
true
ff6a9327111545c69ad4f59c5b5f2878def92431
ikki2530/holbertonschool-machine_learning
/math/0x02-calculus/10-matisse.py
740
4.53125
5
#!/usr/bin/env python3 """Derivative of a polynomial""" def poly_derivative(poly): """ -Description: calculates the derivative of a polynomial. the index of the list represents the power of x that the coefficient belongs to. -poly: is a list of coefficients representing a polynomial - Returns:...
true
d82167ca61a739e2d8c6919137e144a987ee22a3
ikki2530/holbertonschool-machine_learning
/math/0x00-linear_algebra/8-ridin_bareback.py
1,123
4.3125
4
#!/usr/bin/env python3 """multiply 2 matrices""" def matrix_shape(matrix): """ matrix: matrix to calcuted the shape Return: A list with the matrix shape [n, m], n is the number of rows and m number of columns """ lista = [] if type(matrix) == list: dm = len(matrix) lista.ap...
true
181117260d2bcdc404dcd55a6f51966afa880e83
ikki2530/holbertonschool-machine_learning
/supervised_learning/0x07-cnn/0-conv_forward.py
2,649
4.53125
5
#!/usr/bin/env python3 """ performs forward propagation over a convolutional layer of a neural network """ import numpy as np def conv_forward(A_prev, W, b, activation, padding="same", stride=(1, 1)): """ - Performs forward propagation over a convolutional layer of a neural network. - A_prev is a nump...
true
d5435c2f2cca0098f13f5d2ca37100b58eed8515
David-Papworth/qa-assessment-example-2
/assessment-examples.py
2,639
4.1875
4
# <QUESTION 1> # Given a word and a string of characters, return the word with all of the given characters # replaced with underscores # This should be case sensitive # <EXAMPLES> # one("hello world", "aeiou") β†’ "h_ll_ w_rld" # one("didgeridoo", "do") β†’ "_i_geri___" # one("punctation...
true
0875700b5375f46ffcb44da81fff916e10808e6d
siddarthjha/Python-Programs
/06_inheritance.py
1,338
4.28125
4
""" Concept of Inheritance. """ print('I am created to make understand the concept of inheritance ') class Upes: def __init__(self, i, n): print('I am a constructor of Upes ') self.i = i self.n = n print('Ok i am done bye....') def fun(self): print('I am ...
true
b9f0b7f7699c8834a9c3a7b287f7f68b09b100ee
GabrielByte/Programming_logic
/Python_Exersice/ex018.py
289
4.34375
4
''' Make a program that calculates sine, cosine and tangent ''' from math import sin, cos, tan, radians angle = radians(float(input("Enter an angle: "))) print(f"This is the result; Sine: {sin(angle):.2f}") print(f"Cosine: {cos(angle):.2f}") print(f"and Tangent: {tan(angle):.2f}")
true
45e8158ac5e78c5deea43e77bebb2773c3aee215
GabrielByte/Programming_logic
/Python_Exersice/ex017.py
230
4.1875
4
''' Make a program that calculates Hypotenouse ''' from math import pow,sqrt x = float(input("Enter a number: ")) y = float(input("Enter another one: ")) h = sqrt(pow(x,2) + (pow(y,2))) print(f"This is the result {h:.2}")
true
38b524a20fa88a549e0926230a63571a113c6249
tabssum/Python-Basic-Programming
/rename_files.py
997
4.21875
4
#!/usr/bin/python import os import argparse def rename_files(): parser=argparse.ArgumentParser() parser.add_argument('-fp','--folderpath',help="Specify path of folder to rename files") args=parser.parse_args() #Check for valid folderpath if args.folderpath : #Get files in particular folder ...
true
dbccaa5b83a7764eb172b0e1653f7f086dd7b95e
smakireddy/python-playground
/ArraysAndStrings/PrisonCellAfterNDays.py
2,265
4.21875
4
"""" There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to the following rules: If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied. Otherwise, it becomes vacant. (Note...
true
7d543273ad847de56beaae7761f9280640cfe012
smakireddy/python-playground
/ArraysAndStrings/hackerrank_binary.py
1,396
4.15625
4
""" Objective Today, we're working with binary numbers. Check out the Tutorial tab for learning materials and an instructional video! Task Given a base- integer, , convert it to binary (base-). Then find and print the base- integer denoting the maximum number of consecutive 's in 's binary representation. When working...
true
29bf475491bbb765a9e739822fe09e7e383a1fef
aototo/python_learn
/week2/week2 bisection.py
878
4.15625
4
print("Please think of a number between 0 and 100!") high = 100 low = 0 nowCorrect = int(( high + low ) / 2) print('Is your secret number '+ str(nowCorrect) + '?') while True: input_value = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed...
true
7bbe2bf4078108379bff6f1b4edcf1d61dad66fd
Jeremiah-David/codingchallenges
/python-cc.py
1,363
4.15625
4
# Write a function called repeatStr which repeats the given string # string exactly n times. # My Solution: def repeat_str(repeat, string): result = "" for line in range(repeat): result = result + string return (result) # Sample tests: # import codewars_test as test ...
true
55e74e7fa646c954cefac68cd885b63a639191a3
attaullahshafiq10/My-Python-Programs
/Conditions and loops/4-To Check Prime Number.py
646
4.1875
4
# A prime number is a natural number greater than 1 and having no positive divisor other than 1 and itself. # For example: 3, 7, 11 etc are prime numbers # Other natural numbers that are not prime numbers are called composite numbers. # For example: 4, 6, 9 etc. are composite numbers # Code num = int(input("...
true
bb69af4b9a1f55be425c9dbd16d19768cef3345d
winkitee/coding-interview-problems
/11-20/15_find_pythagorean_triplets.py
911
4.28125
4
""" Hi, here's your problem today. This problem was recently asked by Uber: Given a list of numbers, find if there exists a pythagorean triplet in that list. A pythagorean triplet is 3 variables a, b, c where a2 + b2 = c2 Example: Input: [3, 5, 12, 5, 13] Output: True Here, 5^2 + 12^2 = 13^2. """ def findPythagorea...
true
5c1c1b11dc666990e8344bf2cd5cc8e2a663d46f
winkitee/coding-interview-problems
/71-80/80_make_the_largest_number.py
586
4.15625
4
""" Hi, here's your problem today. This problem was recently asked by Uber: Given a number of integers, combine them so it would create the largest number. Example: Input: [17, 7, 2, 45, 72] Output: 77245217 def largestNum(nums): # Fill this in. print(largestNum([17, 7, 2, 45, 72])) # 77245217 """ class larges...
true
dd07fe905d62c6de15dd052c2b54ff82de8ced23
winkitee/coding-interview-problems
/31-40/34_contiguous_subarray_with_maximum_sum.py
876
4.21875
4
""" Hi, here's your problem today. This problem was recently asked by Twitter: You are given an array of integers. Find the maximum sum of all possible contiguous subarrays of the array. Example: [34, -50, 42, 14, -5, 86] Given this input array, the output should be 137. The contiguous subarray with the largest sum...
true
3a65bf1e00e3897174298a3dc7162b4c75c90742
GabuTheGreat/GabuTheGreat.github.io
/challange/recursion_1.py
467
4.1875
4
n= int(input("Enter number the first number: ")) def isPrime(num): """Returns True if num is prime.""" if (num == 1) or (num % 2 == 0) or (num % 3 == 0) : return False if (num == 2) or (num == 3) : return True check_var= 5 set_var = 2 while check_var * check_var <= num: ...
true
fbb50bc38f14354555cef3e2bf8cd66e2a3f9270
toufiq007/Python-Tutorial-For-Beginners
/chapter three/while_loop.py
412
4.21875
4
#loop #while loop # steps # first declare a variable # second write the while loop block # in while loop block you must declare a condition # find the odd and even number by using while number between 0-100 i = 0; while i<=100: print(f'odd number {i}') i+=2 # find the even and even number by using whi...
true
74bee5049a2462c78824fdee03bc35c9bcd6759e
toufiq007/Python-Tutorial-For-Beginners
/chapter twelve/lambda_expresion_intro.py
512
4.25
4
# lambda expression --> anonymous function # it means when a function has no name then we called it anonymous function # syntex # 1: first write lambda keyword # 2: second give the parameters # 3: then give : and give the operator tha'ts it def add(x,y): return x+y print(add(10,5)) add = lambda a,b : a+b p...
true
4024a43132422ded8732257256bfb91b98cf3582
toufiq007/Python-Tutorial-For-Beginners
/chapter thirteen/iterator_iterable.py
515
4.21875
4
# iterator vs iterables numbers = [1,2,3,4,5] # , tuple and string alls are iterables # new_number = iter(numbers) # print(next(new_number)) # print(next(new_number)) # print(next(new_number)) # print(next(new_number)) # print(next(new_number)) square_numbers = map(lambda x:x**2,numbers) # map , filter this al...
true
e7557d739edf11756cbec9759a5e7afaefa7955e
toufiq007/Python-Tutorial-For-Beginners
/chapter two/exercise3.py
975
4.125
4
# user_name,user_char = input('enter your name and a single characte ==>').split(',') name,character = input('please enter a name and character ').split(',') #another times # print(f'the lenght of your name is = {len(name)}') # print(f'character is = {(name.lower()).count((character.lower()))}') # (name.lower()).c...
true
bd809f3954aded9bef550a88b32eb1a958b7b1b5
toufiq007/Python-Tutorial-For-Beginners
/chapter thirteen/zip_part2.py
978
4.1875
4
l1= [1,2,3,4,5,6] l2 = [10,20,30,40,50,60] # find the max number of those list coupe item and store them into a new list def find_max(l1,l2): new_array = [] for pair in zip(l1,l2): new_array.append(max(pair)) return new_array print(find_max(l1,l2)) # find the smallest numbers and stored...
true
60b9af30be744aec3de24fd4f422c688570644f3
toufiq007/Python-Tutorial-For-Beginners
/chapter eleven/args_as_arguement.py
452
4.28125
4
# Args as arguements def multiply_nums(*args): print(args) print(type(args)) # [1,2,3,4,5] mutiply = 1 for i in args: mutiply *= i return mutiply # when you pass a list or tuple by arguemnts in your function then you must give * argument after give your list or tuple name number = [1,...
true
21647313d550a72c49db44ddb740922b2199c2e1
toufiq007/Python-Tutorial-For-Beginners
/chapter eight/set_intro.py
984
4.375
4
# set data type # unordered collection of unique items # i a set data type you can't store one data in multipying times it should be use in onetime # set removes which data are in mulple times # the main use of set is to make a unique collection of data it means every data should be onetimes in a set # s = {1,2,3,4...
true
080bf5bb5c575a0dfc6b1d805c252097b2fe6389
joannarivero215/i3--Lesson-2
/Lesson3.py
1,577
4.15625
4
#to comment #when naming file, do not add spaces #age_of_dog = 3, meaningful variable name instead of using x names = ["corey", "philip", "rose","daniel"] #assigning variables values to varibale name in a list(need braket) print names #without quotation to print value print names[1] #says second name print '\n' for ...
true
095615f1bac4635998d783a8c1e6aad0f17c1930
hmedina24/Python2021
/Practice/basic_python_practice/practice04.py
431
4.3125
4
#Create a program that asks the user for a number and then prints out a list of all the divisors that number. #(If you don't know what a divisor is, it is a number that divides evely into another number.) For example, 13 is a divisor of 26 /13 has no remainder.) def main(): num = int(input("Enter a number")) d...
true
077dd6078669f3ff73df753fa86ace4b7c38ccae
hmedina24/Python2021
/Sort_Algorithms /insertionSort.py
582
4.15625
4
def insertionSort(arr): #traverse through 1 to len(arr) for i in range(1, len(arr)): key = arr[i] #move elements of arr[0..i-1], that greater #than key, to one position ahead #of their current position j = i-1 while(j >= 0 and key < arr[j]): arr[j+1] ...
true
257f16e47cff4e8ac9c09a2c612c26514a144272
eternalAbyss/Python_codes
/Data_Structures/zip.py
585
4.34375
4
# Returns an iterator that combines multiple iterables into one sequence of tuples. Each tuple contains the elements in # that position from all the iterables. items = ['bananas', 'mattresses', 'dog kennels', 'machine', 'cheeses'] weights = [15, 34, 42, 120, 5] print(list(zip(items, weights))) item_list = list(zip(it...
true
c24e68e1d77ba3e532987225382ae2f325424426
muha-abdulaziz/langs-tests
/python-tests/sqrt.py
419
4.3125
4
""" This program finds the square root. """ x = int(input('Enter an integer: ')) def sqrt(x): ''' This program finds the square root. ''' x = x ans = 0 while ans ** 2 < abs(x): ans = ans + 1 if ans ** 2 != abs(x): print(x, "is not a perfect square.") else: if x...
true
4e77c72219eec3043169f21e5ea39683d274d768
vssousa/hacker-rank-solutions
/data_structures/linked_lists/merge_two_sorted_linked_lists.py
982
4.34375
4
""" Merge two linked lists head could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node return back the head of the linked list in the below method. """ def MergeLists(headA, headB): ...
true
866d69100bf11fa6508f0831af38d793fcbc1203
CapstoneProject18/Twitter-sentiment-analysis
/s3.py
711
4.34375
4
#function to generate list of duplicate values in the list def remove_Duplicate(list): final_list = [] for letter in list: #empty final list to store duplicate values in list ...
true
6a95042055f70c57d1b7f162d425999f4ea0b9ef
rhaeguard/algorithms-and-interview-questions-python
/string-questions/reverse_string_recursion.py
368
4.28125
4
""" Reverse the string using recursion """ def reverse_recurse(string, st, end): if st > end: return ''.join(string) else: tmp_char = string[st] string[st] = string[end] string[end] = tmp_char return reverse_recurse(string, st+1, end-1) def reverse(string): return...
true
29780713ccfde18c564112343872fc00415e994b
rhaeguard/algorithms-and-interview-questions-python
/problem_solving/triple_step.py
449
4.4375
4
""" Triple Step: A child is running up a staircase with n steps and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many possible ways the child can run up the stairs. """ def triple_steps(step_size): if step_size == 1 or step_size == 0: return 1 elif step_size ==...
true
4a5ff8792e2f2106205376b2e4ac135045abf3d9
akashgkrishnan/HackerRank_Solutions
/language_proficiency/symmetric_difference.py
741
4.34375
4
# Given sets of integers, and , print their symmetric difference in ascending order. The term symmetric difference indicates those values that exist in either or but do not exist in both. # Input Format # The first line of input contains an integer, . # The second line contains space-separated integers. # The th...
true
c4b02fa604cfbaeda727970e16450d9caceb3cd0
namanm97/sl1
/7a.py
744
4.375
4
# 7A # Write a python program to define a student class that includes name, # usn and marks of 3 subjects. Write functions calculate() - to calculate the # sum of the marks print() to print the student details. class student: usn = " " name = " " marks1 = 0 marks2 = 0 marks3 = 0 def __init__(self,usn,name,ma...
true
de429dafc1e0289e1db3f2959c3898bf108da63f
zbloss/PythonDS-MLBootcamp
/Python-Data-Science-and-Machine-Learning-Bootcamp/Machine Learning Sections/Principal-Component-Analysis/PCA.py
1,536
4.125
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline # PCA is just a transformation of the data that seeks to explain what features really # affect the data from sklearn.datasets import load_breast_cancer cancer = load_breast_cancer() cancer.keys() cancer['...
true
46ec9a084ae3e98e217ccd160257b870111b8c4e
coshbar/Trabalhos
/Phyton/Max_Subarray.py
627
4.1875
4
#Have the function MaxSubarray(arr) take the array of numbers stored in arr and determine the largest sum that can be formed by any contiguous subarray in the array. #For example, if arr is [-2, 5, -1, 7, -3] then your program should return 11 because the sum is formed by the subarray [5, -1, 7]. #Adding any element b...
true
507d763a8196d7f37aeacc592130234b38cf3fa4
stevenjlance/videogame-python-oop-cli
/game.py
2,753
4.40625
4
import random class Player: # Class variables that are shared among ALL players player_list = [] #Each time we create a player, we will push them into this list. player_count = 0 def __init__(self, name): ## These instance variables should be unique to each user. Every user will HAVE a name, but each user...
true
9a52340002ffd0ac3b93cb796958deee21219aef
eguaaby/Exercises
/ex06.py
428
4.34375
4
# Check whether the input string # is a palindrome or not def ex6(): user_input = raw_input("Please enter a word: ") palindrome = True wordLength = len(user_input) for i in range(0, wordLength/2 + 1): if user_input[i] != user_input[wordLength-1-i]: palindrome = False if palindro...
true
4b5b369fafd5657f10492685af047a6604254d05
sandeepkundala/Python-for-Everybody---Exploring-Data-in-Python-3-Exercise-solutions
/ex5_1_2.py
901
4.1875
4
# Chapter 5 # Exercise 1 & 2: Write a program which repeatedly reads numbers until the user enters # β€œdone”. Once β€œdone” is entered, print out the total, count, average of the # numbers, maximum and minimum of the numbers. If the user enters anything other than a number, detect their mistake # using try and except ...
true
eb4b36ee61f4541e2334038e366428a3b570d815
sandeepkundala/Python-for-Everybody---Exploring-Data-in-Python-3-Exercise-solutions
/ex7_2.py
1,030
4.1875
4
# Chapter 7 # Exercise 2: Write a program to prompt for a file name, and then read through the # file and look for lines of the form: # X-DSPAM-Confidence:0.8475 # When you encounter a line that starts with β€œX-DSPAM-Confidence:” pull apart # the line to extract the floating-point number on the line. Count these lines ...
true
eee346b98c2726facf971db72ef2c5d6be0a7ee9
sandeepkundala/Python-for-Everybody---Exploring-Data-in-Python-3-Exercise-solutions
/ex8_4.py
472
4.3125
4
# Chapter 8 # Exercise 4: Write a program to open the file romeo.txt and read it line by line. For each line, # split the line into a list of words using the split function. # For each word, check to see if the word is already in a list. If the word is not in # the list, add it to the list. fh = input('Enter file: ...
true
697a943b2cceb74f2503fd1130bd3fa263ff57cf
Robbot/Teclado
/The Complete Python/Section1/main.py
1,533
4.28125
4
# Coding exercise 2 name = input("What is your name? ") print(f"Hello, {name}") age = int(input("What is your age? ")) print(f"You are {age*12} months old") # Coding exercise 3 nearby_people = {'Rolf', 'Jen', 'Anna'} user_friends = set() #This is an empty set friend = input("What is the name of your friend? ") user_fr...
true
d5b582a3938073bfb5355322b4fe492b41de1d73
johnahnz0rs/CodingDojoAssignments
/python/python_fundamentals/scores_and_grades.py
829
4.3125
4
# Write a function that generates ten scores between 60 and 100. Each time a score is generated, your function should display what the grade is for a particular score. Here is the grade table: # Score: 60 - 69; Grade - D # Score: 70 - 79; Grade - C # Score: 80 - 89; Grade - B # Score: 90 - 100; Grade - A def scor...
true
30ef3b36e9f9dddbf5526b068c1451796e78da89
nd-cse-34872-su21/cse-34872-su21-examples
/lecture02/cheatsheet.py
366
4.25
4
#!/usr/bin/env python3 v = [1, 2, 3] # Create dynamic array v.append(4) # Append to back of array v.insert(0, 0) # Prepend to front of array print(len(v)) # Display number of elements for e in v: # Traverse elements print(e) # Traverse elements with index for...
true
f1705276ec52154591de27009366f0e8c5e278be
anejaprerna19/LearninPython
/passwordchecker.py
396
4.25
4
#Password Checker Assignment from Udemy Course #In this simple assignment, we take user inputs for username and password and then calculate and print the length of password. username= input("What is your username? "); password= input("Enter the password "); pass_length= len(password) hidden_pass= '*' * pass_length pr...
true
839764c040251100e370a5b0f24b8c3e8044961f
dhitalsangharsha/GroupA-Baic
/question5.py
204
4.125
4
'''5) Take an arbitrary input string from user and print it 10 times.''' string=input("enter a string:") print("\nprinting {} 10 times ".format(string)) for i in range(1,11): print(str(i)+':',string)
true
fc46ee5a3d68857277ffca31aa3925943c139988
irffanasiff/100-days-of-python
/day5/range.py
382
4.1875
4
# for number in range(1, 10, 3): # print(number) # total = 0 # for number in range (1, 101): # total += number # print(total) #! sum of all the even numbers from 1 to 100 total =0 for number in range(0,101,2): total += number print(total) #? or total =0 for number in range (1,101): if number%2==0: ...
true
68ceeb0a35ee5de2f89d64d842496f112689b9ed
florinbrd/PY--
/python developer zero to mastery/Practice Exercises - pynative.com/Basic Exercises/Exercise10.py
509
4.15625
4
# Question 10: Given a two list of ints create a third list such that should contain only odd numbers from the first list and even numbers from the second list def odd_list(list1, list2): list3 = [] for item1 in list1: if item1 % 2 == 0: list3.append(item1) for item2 in list2: ...
true
5d2ac7e730a592f9063af6ae5366608611060c67
florinbrd/PY--
/python developer zero to mastery/Practice Exercises - pynative.com/Basic Exercises/Exercise02.py
398
4.3125
4
# Question 3: Accept string from the user and display only those characters which are present at an even index def even_char(string_defined): print(f'Your original string is: {string_defined}') for item in range(0, len(string_defined)-1, 2): if item % 2 == 0: print("index[", item,"]", strin...
true
0669fa9486066c0a53b54f782a5f9d4d0e816264
shashaank-shankar/OFS-Intern-2019
/Python Exercises/Condition Statements and Loops/Exercise 1.py
341
4.25
4
# Write a Python program to find those numbers which are divisible by 7 and multiple of 5, between 1500 and 2700 (both included). input = int(input("Enter a number: ")) if input >= 1500 and input <= 2700: if input%7 == 0: if input%5 == 0: print(input + " is between 1500 and 2700. It is also div...
true
11f50308cb6450ee304af690d61f072c70924277
shashaank-shankar/OFS-Intern-2019
/Python Exercises/Condition Statements and Loops/Exercise 2.py
1,088
4.5
4
# Write a Python program to convert temperatures to and from celsius, fahrenheit. print("\nThis program converts Celsius and Farenheit temperatures.") def tempConvert (type): if type == "C": # convert to C new_temp = (temp_input - 32) * (5/9) new_temp = round(new_temp, 2) print("\n"...
true
54518c4f1dcd313da6458e664f7f8c1fa2b95b5c
Susama91/Project
/W3Source/List/list10.py
273
4.21875
4
#Write a Python program to find the list of words that are longer than n #from a given list of words. def lword(str1,n): x=[] txt=str1.split() for i in txt: if len(i)>n: x.append(i) print(x) lword('python is a open',2)
true
d1573d6ad748eaceb5747f80a42477914ece741b
ItsPepperpot/dice-simulator
/main.py
644
4.1875
4
# Dice rolling simulator. # Made by Oliver Bevan in July 2019. import random def roll_die(number_of_sides): return random.randint(1, number_of_sides) print("Welcome! How many dice would you like to roll?") number_of_dice = int(input()) # TODO: Add type checking. print("Okay, and how many sides would you like t...
true
1f4d2489bcfa31d9c1d3b2e82828c1533fac81d2
MarvvanPal/foundations-sample-website
/covid_full_stack_app/covid_full_stack_app/controllers/database_helpers.py
2,107
4.65625
5
# connect to the database and run some SQL # import the python library for SQLite import sqlite3 # this function will connect you to the database. It will return a tuple # with two elements: # - a "connection" object, which will be necessary to later close the database # - a "cursor" object, which will neccesary t...
true
7e603d0a3d96c50104630187b700ccab8cf035d7
hemang249/py-cheatsheet
/conditions.py
479
4.15625
4
# Common Conditional Statements used in Python 3 # Basic if-else Condition x = 5 if x == 5: print("x = 5") else: print("x != 5") # Basic Logical operations # and or not a = 0 b = 1 boolean = False if a == 0 and b == 1: print("a = 0 and b = 1") if a == 0 or b == 1: print("Either a = 0 or b = 1")...
true
8ad114e4e5f63a56c8d560f60d05e19dcd77ee42
KimberleyLawrence/python
/for_loop_even_numbers.py
245
4.1875
4
a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] for number in a: # % 2 == 0 is dividing the number by 2, and seeing if there is any remainders, any remainders mean that the number is not even. if number % 2 == 0: print number
true
37e9fa37ff5e6cc968b0031e802538c1c902ad9c
Kristy16s/Think-Python-2-Exercises-By-Chapter
/2.1 Exercises.py
1,285
4.4375
4
# 2.10 Exercises # Date 8/4/2021 """ Exercise 1 Repeating my advice from the previous chapter, whenever you learn a new feature, you should try it out in interactive mode and make errors on purpose to see what goes wrong. """ # We’ve seen that n = 42 is legal. What about 42 = n? # 42 = n """ File "<input>", line 1 ...
true
41228a26ab53da47dabc59d4d0414c23e806d902
shanksms/python_cookbook
/iterators-generators/generator-examples.py
1,272
4.6875
5
""" Here’s a generator that produces a range of floating-point numbers. Below function returns a generator object. A generator object is also an iterator. an Iterator is an Iterable. That is why you can use it in while loop. """ def frange(start, stop, increment): i = start while i < stop: yield i ...
true
40a0f176eba2fed30a0c5ed96d9ee6fbe654a70a
ssummun54/wofford_cosc_projects
/Assignments/8and10.py
1,719
4.15625
4
# 8and10.py # This progam runs two functions. The first function uss Newton's Method to find the # square root of a number. The second function creates an acronym based on the phrase # given by the user. #importing math for square root from math import * #function for problem 8 def nextGuess(guess, ne...
true
d92640d7336759a48656c7df4bd333ceecca69aa
ssummun54/wofford_cosc_projects
/Assignments/numerology.py
615
4.4375
4
# numerology.py # This program sums up the Unicode values of the user's full name and displays the corresponding Unicode character # A program by Sergio Sum # 3/24/17 def main(): name = input("Please enter your full name: ") # not counting spaces by turning to list name = name.split() #j...
true
3ed869277d2d7958bc4d4012434c826f03e88eaf
dexterchan/DailyChallenge
/MAR2020/ScheduleTasks.py
648
4.1875
4
#A task is a some work to be done which can be assumed takes 1 unit of time. # Between the same type of tasks you must take at least n units of time before running the same tasks again. #Given a list of tasks (each task will be represented by a string), # and a positive integer n representing the time it takes to ru...
true
d6d4cc0dae2f1a1fc7a650798ee6dad83d6b57ed
dexterchan/DailyChallenge
/NOV2019/WordSearch.py
2,069
4.15625
4
#skills: array traversal #You are given a 2D array of characters, and a target string. Return whether or not the word target word exists in the matrix. # Unlike a standard word search, the word must be either going left-to-right, or top-to-bottom in the matrix. #Example: #[['F', 'A', 'C', 'I'], # ['O', 'B', 'Q', 'P']...
true
e76e31b3bce987ce0ed9b4a39f29ad6eb1221d92
dexterchan/DailyChallenge
/MAR2020/FilterBinaryTreeLeaves.py
2,112
4.15625
4
#Hi, here's your problem today. This problem was recently asked by Twitter: #Given a binary tree and an integer k, filter the binary tree such that its leaves don't contain the value k. Here are the rules: #- If a leaf node has a value of k, remove it. #- If a parent node has a value of k, and all of its children are...
true
2ea7d16b392e87f58bb97d39e40df65120963c28
JoseCintra/MathAlgorithms
/Algorithms/MatrixDeterminant.py
2,070
4.46875
4
""" Math Algorithms Name: MatrixDeterminant.py Purpose: Calculating the determinant of 3x3 matrices by the Sarrus rule Language: Python Author: JosΓ© Cintra Year: 2021 Web Site: https://github.com/JoseCintra/MathAlgorithms License: Unlicense, described in http://unlicense.org...
true
a893cd5e53c840925e54c60af40514bb8fa51d07
mansoniakki/PY
/Reverse_Input_String.py
412
4.40625
4
print("##################This script with reverse the string input by user###########") name=input("Please enter first and last name to reverse: ") print("name: ", name) words=name.split() print("words: ", words) for word in words: lastindex = len(word) -1 print("lastindex ", lastindex) for index in range...
true
63582443b16149b97f551b6a9f80845fa8b60a30
rbenf27/dmaimcoolshek6969
/PYTHON/COLOR GUESSER.py
530
4.125
4
import random color = random.randint(1,7) if color == 1: color = "yellow" if color == 2: color = "green" if color == 3: color = "orange" if color == 4: color = "blue" if color == 5: color = "red" if color == 6: color = "purple" user_choice = input("Choose a c...
true
f31a9a0fe3a3642263c05c365dffa4db220de581
rbrown540/Python_Programs
/Calculate.py
2,967
4.40625
4
# Richard Brown - SDEV 300 # March 16, 2020 # Lab_One - This program prompts the user to select a math function, # then performs that function on two integers values entered by the user. print ('\nWelcome to this awesome Python coded calculator\n') # provide user with the math function options print ('Select 1 for ADD...
true
f366a69f898f1bc46e0495605878eefb3dcb438e
richa18b/Python
/oops.py
2,829
4.15625
4
import random import sys import os class Animal : _name = None #this is equivalent to __name = "" _height = 0 #_ means that it is a private variable _weight = 0 _sound = "" #constructor def __init__(self,name,height,weight,sound): self._name = name self._height = height ...
true
7d6e9b19d7f2ba2da75911fc61a300d39cf1857f
kunlee1111/oop-fundamentals-kunlee1111
/Coin.py
1,790
4.21875
4
""" ------------------------------------------------------------------------------------------------------------------------ Name: Coin.py Purpose: Simulates 1000 flips of a coin, and tracks total count of heads and tails. Author: Lee.K Created: 2018/11/30 ---------------------------------------------------------...
true
d64728f99b0089fbca68bdef03db6982d570d8d4
gingij4/Forritun
/bmistudull.py
560
4.53125
5
weight_str = input("Weight (kg): ") # do not change this line height_str = input("Height (cm): ") # do not change this line height_float = (float(height_str) / 100) weight_float = float(weight_str) bmi = (weight_float / (height_float)**2) print("BMI is: ", bmi) # do not change this line #BMI is a number calcu...
true
7db3286c9184aa0405e47981b84fa87624ac8cee
rjrobert/daily_coding_problems
/daily12.py
1,580
4.125
4
""" Good morning! Here's your coding interview problem for today. This problem was asked by Amazon. There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters. ...
true
1901e6e18d17b4595391d581443e672a924e2089
cse210-spring21-team4/cse210-tc06
/src/mastermind/game/player.py
1,259
4.15625
4
class Player: """A person taking part in a game. The responsibility of Player is to record player moves and hints. Stereotype: Information Holder Attributes: _name (string): The player's name. _move (Move): The player's last move. """ def __init__(self, players=list)...
true
e17792c43909aeb873441ff67efb33b42c2d1f84
vburnin/PythonProjects
/CompoundInterestLoops.py
2,028
4.53125
5
import locale locale.setlocale(locale.LC_ALL, '') # Declare Variables nDeposit = -1 nMonths = -1 nRate = -1 nGoal = -1 nCurrentMonth = 1 # Prompt user for input, check input to make sure its numerical while nDeposit <= 0: try: nDeposit = int(input("What is the Original Deposit (positive value): ")) e...
true
343e43016f793b6f56dcca61a38bc7ee7eb479a5
ajuliaseverino/tutoring
/tut/basics.py
1,420
4.21875
4
# print('Hello world') # x = 5.6 # print(x) # # print("\nFor loop from 0 to 9.") # for i in range(10): # print(i) def input_switch(): """A function definition. Calling the function by typing input_switch() will run this code. The code does *not* get run when you create the function. """ user_i...
true
66536ba1353fcefb8951dec0ad9f47e4557f30b3
Hamsik2rang/Python_Study
/References_Of_Object/Tuple.py
764
4.40625
4
# tuple # tuple is immutable object. so when you create tuple once, you can't change or delete element(s) in it. t = (1,) print(t) print(" remark: you can't create tuple that have an element without using comma(,). because it is confused with parenthesis operation.\n") t = (1,2,3) print(t) t = 1,2,3 print(t) # ind...
true
cd0e80bafd2a6c761dab0c92e11c4aa82b145466
Hamsik2rang/Python_Study
/Day14/Sources/Day14_6.py
514
4.375
4
# Generator # Generator is a function contain 'yield' keyword. # Generator works like iterator object. def my_generator(): # When Interpreter(Compiler) meet 'yield' keyword, Literally yield program flow(resources) to main routine. # It means return value there is next 'yield' keyword, and stop routine until nex...
true
87578912fbfeadc41774c42416ce99bc646a57cf
Hamsik2rang/Python_Study
/Day13/Sources/Day13_11.py
958
4.125
4
# Multiple Inheritance # Python support Multiple Inheritance. class Dragon: def breath(self): print("브레슀!!!! ν”Όν•΄μš§!!!!!") class Elf: def heal(self): print("치유 λ§ˆλ²•") class Player(Dragon, Elf): def attack(self): print("얍!") me = Player() me.breath() me.heal() me.attack() # Diamond...
true
c00c114531ecc3ccf2d29dd7457ed7c6c68ede60
daniellehoo/python
/week 1/math2.py
467
4.1875
4
# in Python you can do math using the following symbols: # + addtion # - subtaction # * multiplication # / division # ** exponent (not ^) # > greater than # >= greater than or equal to # < less than # <= less than or equal to # and more! answer = (40 + 30 - 7) * 2 / 3 print("what is the answer to life, the universe, ...
true
114d909c19bfde24e1e4cbccf337b15d6479e418
zerformza5566/CP3-Peerapun-Sinyu
/assignment/Exercise5_1_Peerapun_S.py
436
4.25
4
firstNumber = float(input("1st number : ")) secondNumber = float(input("2nd number : ")) plus = firstNumber + secondNumber minus = firstNumber - secondNumber multiply = firstNumber * secondNumber divide = firstNumber / secondNumber print(firstNumber, "+", secondNumber, "=", plus) print(firstNumber, "-", secondNumber,...
true
5e0aa09e18545eb0db0f8e21b613e29007b6e25a
nicolesy/codecademy
/projects/codecademy_project_cho_han.py
1,342
4.53125
5
# codecademy_project_cho_han.py # Create a function that simulates playing the game Cho-Han. The function should simulate rolling two dice and adding the results together. The player predicts whether the sum of those dice is odd or even and wins if their prediction is correct. # The function should have a parameter t...
true
18868e88cc99d47da4052c5231e1d78d4cba6332
dmproia/java1301_myPythonPrograms
/lab8.py
934
4.28125
4
#============================ # PROGRAM SPECIFICATIONS # NARRATIVE DESCRIPTION:Lab8 # # @author (David Proia) # @version(1/27/12) #============================== repeat = "Y" print ("This program is designed to tell allow you to tell if you have a right triangle or not" ) print () while (repeat == "Y"): X = fl...
true
215504ad95354baf30674044d4eb285dc87e8193
Nayalash/ICS3U-Problem-Sets
/Problem-Set-Five/mohammad_race.py
1,491
4.28125
4
# Author: Nayalash Mohammad # Date: October 19 2019 # File Name: race.py # Description: A program that uses the Tortoise and Hare Algorithm to simulate a race. # Import Required Libraries import random import time # Helper Function To Display Name and Progress def display(name, progress): print(name + ": " + str(...
true
94d53ee92c8275a4b71070097047f3085972db20
Nayalash/ICS3U-Problem-Sets
/Problem-Set-Seven/mohammad_string_blank.py
1,094
4.25
4
# Author: Nayalash Mohammad # Date: November 01 2019 # File Name: string_blank.py # Description: A program that replaces multiple spaces with one # Main Code def main(): # Ask for string string = input("Enter a string with multiple blank spaces...\n") # Regex the string, and join it newString = ' '.join(string.sp...
true
2c3dd09d52eaa860167288b7192be1bcca2b176a
Nayalash/ICS3U-Problem-Sets
/Problem-Set-One/digit_breaker.py
277
4.125
4
# Author: Nayalash Mohammad # Date: September 20 2019 # File Name: digit_breaker.py # Description: A program that splits the digits in a number # Ask a number from the user number = input("Enter a Three Digit Number: ") # Iterate over the provided string for i in number: print(i)
true
2494877cda4f8f5ebc6f88de5bd26cc0726d695e
Isaac3N/python-for-absolute-beginners-projects
/reading files.py
1,110
4.53125
5
# read it # demonstrates reading from a text file print("opening and a closing file.") text_file= open("readit.txt", "r") text_file.close() print("\nReading characters from a file.") text_file= open ("readit.txt", "r") print(text_file.read(1)) print(text_file.read(5)) text_file.close() print("\nReading the entire fi...
true
f75b734c0b6c1848e23253466a2a637dd5220983
Isaac3N/python-for-absolute-beginners-projects
/limited tries guess my number game.py
608
4.21875
4
# welcome to the guess my number game # your to guess a number from 1-5 # your limited to 3 tries import random print (" welcome to the guess my number game \n your limited to a number tries before the game ends \n GOOD LUCK !") the_number = random.randint(1,5) guess = input (" take a guess: ") tries = 1 while guess...
true
988207876d95d5de27ef0fb9e14600343a9afe56
macheenlurning/python-classwork
/Chap3Exam.py
2,478
4.3125
4
# Ryan Hutchinson # Chapter 3 Exam # Programming Projects 1 & 3 #1 - Car Loan loan = int(input("Enter the amount of the loan: ")) if int(loan) >= 100000 or int(loan) < 0: print("Total loan value {} might be incorrect...".format(loan)) response1 = input("Would you like to correct this? Type Yes or No:...
true
a5405798c83b1ecc5b8095b4a8251ea3d6aa8fea
bapadman/PythonToddlers
/pythonTutorialPointCodes/IfElse.py
277
4.1875
4
#!/usr/bin/python # classic if else loop example flag = True if not flag: print("flag is true") print("Printing from if loop") else: print("flag is false") print("Printing from else part") #while loop sample i = 0 while i < 10: print("i = ",i) i = i +1
true
55306a5cb494265ccaec0969650a6f311fe7270f
finolex/Python_F18_Abhiroop
/Lab 3 - Booleans/q3.py
485
4.125
4
import math firstLeg = int(input("Please enter the length of the first leg: ")) secondLeg = int(input("Please enter the length of the second leg: ")) hyp = float(input("Please enter the length of the hypothenuse: ")) hypCalc = math.sqrt(firstLeg**2 + secondLeg**2) if hyp == hypCalc: print("This forms a right ang...
true
5c624b55e026aa8c9c506162767176dd19e4fd7c
finolex/Python_F18_Abhiroop
/Lab 3 - Booleans/q4.py
382
4.15625
4
num1 = int(input("Please enter your first integer: ")) num2 = int(input("Please enter your second integer: ")) if num2 == 0: print("This has no solutions.") elif (-num1/num2) > 0 or (-num1/num2) < 0: print("This has a single solution and x = .", (-num1/num2)) elif (-num1/num2) == 0: print("This has a singl...
true
172720a347baa8828443ba979fb4fe01b2e7f6f5
gabrielchase/MIT-6.00.1x-
/Week2/prob3.py
1,116
4.5
4
# Write a program that calculates the minimum fixed monthly payment needed # in order pay off a credit card balance within 12 months. By a fixed monthly # payment, we mean a single number which does not change each month, but # instead is a constant amount that will be paid each month. MONTHS_IN_A_YEAR = 12 # Given...
true
b785ed5bff4e17cb22b7ee84e0144ab222dedd45
green-fox-academy/FulmenMinis
/week-04/day-03/fibonacci.py
386
4.25
4
# Fibonacci # Write a function that computes a member of the fibonacci sequence by a given index # Create tests that covers all types of input (like in the previous workshop exercise) def fibonacci(n=0): if n < 0: return False elif n == 0: return 0 elif n == 1 or n == 2: ret...
true
a0aacffaecbcb78b56a2f2beecb7d2bf0b143f68
green-fox-academy/FulmenMinis
/week-03/day-04/number_adder.py
264
4.25
4
# Write a recursive function that takes one parameter: n and adds numbers from 1 to n. def recursive_function(n): if n == 0 or n == 1: return n else: return (recursive_function(n-1) + recursive_function(n-2)) print(recursive_function(10))
true
19684231d4bc2fa7ee4e71da4563451022e7c826
green-fox-academy/FulmenMinis
/week-04/day-03/sum.py
790
4.1875
4
# Sum # Create a sum method in your class which has a list of integers as parameter # It should return the sum of the elements in the list # Follow these steps: # Add a new test case # Instantiate your class # create a list of integers # use the assertEquals to test the resu...
true
3c7361f73a5fdee8d31f86f9961ba5f5239060cb
green-fox-academy/FulmenMinis
/week-02/day-05/armstrong_number.py
1,108
4.4375
4
#Exercise # #Write a simple program to check if a given number is an armstrong number. # The program should ask for a number. E.g. if we type 371, the program should print out: # The 371 is an Armstrong number. # What is Armstrong number? # An Armstrong number is an n-digit number that is equal to the sum of the nt...
true
8164ea4320540ca503dc3493c629c74666eeec1f
ShivaVkm/PythonPractice
/playWithTrueFalse.py
769
4.25
4
# True means 1 and False in 0 print(True) # you will get True print(False) # you will get False print(True+False) # you will get 1 because True = 1 and False = 0 print(True == 1) # verification for trueness' value as equal to 1 print(False == 0) # verification for falseness' value as equal to 0 print(True+True) print(...
true
fa1ead85ec576a9d9f3f7595e855b0afcc5c2abc
rpt/project_euler
/src/problem001.py
597
4.1875
4
#!/usr/bin/env python3 # Problem 1: # If we list all the natural numbers below 10 that are multiples of 3 or 5, # we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. # Answer: # 233168 def problem1(n): def sumd(x, n): k = (n - 1...
true