blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
9f12127bc115ea0c20b9cfb26eac5bb26eda4a7b
Steveno95/Whiteboard-Pairing-Problems
/Balanced Binary Tree/balancedBinaryTree.py
1,350
4.34375
4
# write a function that checks to see if a given binary tree is perfectly balanced, meaning all leaf nodes are located at the same depth. # Your function should return true if the tree is perfectly balanced and false otherwise. def checkBalance(root): # An empty tree is balanced by default if root == None: ...
true
85573993f237c888ad1f7e84e1a641c0ad7771d6
aritse/practice
/Unique Paths II.py
1,771
4.1875
4
# A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). # The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). # Now consider if some obstacles are added to...
true
2af620754b574963a8a7375553d0897e40c4827c
wenqianli150/hello-world
/palindrome.py
753
4.1875
4
""" Name: Wenqian Li UWNetId: wli6 TimeComplexity = O(n) """ """ Evaluates a given string and determines whether or not it is a palindrome. :param the_string: The string to evaluate. :returns: True when the string is a palindrome, False otherwise. """ def is_palindrome(the_string): # Run...
true
77617485ca3d6b3e799c5b242fc7154673ef2691
yuriyberezskyy/python-code-challege-loops
/code.py
1,843
4.375
4
# Create a function named exponents() that takes two lists as parameters named bases and powers. Return a new list containing every number in bases raised to every number in powers. # For example, consider th # Write your function here def exponents(lst1, lst2): new_list = [] for num1 in lst1: for nu...
true
05af06eabaf6395710df33a673938041e0e99ec3
Piinks/CSI_Python
/Exercises/Exercise17.py
1,399
4.1875
4
# Exercise 17 # Kate Archer # Program Description: This program reads a file name and the file’s contents # and determines the following: # 1) The number of alphabetic (upper and lower case) letters in the file # 2) The number of digits in the file # 3) The number of lines in the file # CSCI 1170-08 # Novembe...
true
407e1805d35d802fc9c319f454a215848c2a8731
Rokiis/Chat-Bot
/login_system.py
2,228
4.25
4
usernames = ['teacher','mentor','tutor','technican'] #storing usernames that (in theory) only uni staff has access to passwords = ['SecurePassword','password123','safepass','12345'] #storing passwords that (in theory) only uni staff has access to status = "" #set status to nill def login_menu(): #login function th...
true
996be87ec1c34eafac76dd401dc6248b15b7d847
PrashantRBhargude/Python
/Dictionary.py
1,842
4.21875
4
#Dictionary allows us to work with key value pairs similar to hash maps in other prog languages #The values in the dictionary can be of any datatype Lead_Details={'Name':'Nikunj','Role':'ETL','Associates':['Prashant','Dixita']} print(Lead_Details['Associates']) #print(Lead_Details['Phone']) -- gives a key error prin...
true
189d2878517aca5a838d14c0d72ef2fd120fb605
DJ-Watson/ICS3U-Unit3-01-Python
/adding.py
429
4.15625
4
#!/usr/bin/env python3 # Created by: DJ Watson # Created on: September 2019 # This program adds two numbers together def main(): # input number1 = int(input("type first number (integer): ")) number2 = int(input("type second number (integer): ")) # process answer = number1 + number2 # output ...
true
aab6031fc2c812af2a147e574c1e8e748fb38e6a
BazzaOomph/Templates
/python/fundamentals/01_beginner/01_print.py
1,648
4.8125
5
#A basic print statement, which will print out the text string "Hello, World!" #The expected output to the console is "Hello, World!" and includes a New Line character at the end print("Hello, World!") #Printing using two separate arguments #The expected outcome is "Hello how are you?" with a new line character at the...
true
a0a02a0b72762241bf5a5a32cb7e59e696529ccb
code-lighthouse/tests
/sushi_store.py
587
4.125
4
#! /usr/bin/env python # Creating a list to hold the name of the itens shopping = ['fugu', 'ramen', 'sake', 'shiitake mushrooms', 'soy sauce', 'wasabi'] # Creating a dictionary to hold the price of the itens prices = {'fugu': 100.0, 'ramen': 5.0, 'sake': 45.0, 'shiitake mushrooms': 3.5, 'soy sauce': 7.50, ...
true
3e8cf44f0c882fe70c5e83dc655108d109cc4b81
ssgantayat/cleaning-data-in-python
/1-exploring-your-data/06-visualizing-multiple-variables-with-boxplots.py
1,109
4.1875
4
''' Visualizing multiple variables with boxplots Histograms are great ways of visualizing single variables. To visualize multiple variables, boxplots are useful, especially when one of the variables is categorical. In this exercise, your job is to use a boxplot to compare the 'initial_cost' across the differen...
true
9c0e414567cb96f9942edbfbbb6688fd8b28185a
arnabs542/DS-AlgoPrac
/twoPointers/countSubarrays.py
1,344
4.1875
4
"""Count Subarrays Problem Description Misha likes finding all Subarrays of an Array. Now she gives you an array A of N elements and told you to find the number of subarrays of A, that have unique elements. Since the number of subarrays could be large, return value % 109 +7. Problem Constraints 1 <= N <= 105 1 <= A[...
true
d6c0ce60d39c532224a44cf1c423bffe359f5f44
eriktja/SEogT-oblig
/Leap_year/project/leap_year/main.py
270
4.40625
4
from is_leap_year import * print("This program will tell if you if a year is a leap year") year = int(input("Enter the year do you want to check: ")) if is_leap_year(year): print(str(year) + " is a leap year") else: print(str(year) + " is not a leap year")
true
70d71ef0d03cf708ec70da31211d8664833bffa2
hbreauxv/shared_projects
/simple_tests/whatsTheWord.py
201
4.21875
4
while True: word = input('Whats the word?') word = word.lower() if word != ('the bird'): continue else: print('The Bird Bird Bird, The Bird is the Word') break
true
542f107e72693592bbf1e253b06627f682a9ba73
MDCGP105-1718/portfolio-MichaelRDavis
/Python/Week 2/ex5.py
709
4.125
4
#Loop for number of bottles and print number of bottles for n in range(99, -1, -1): print("99 bottles of beer on the wall, 99 bottles of beer.") print(f"Take one down, pass it around, {n} bottles of beer on the wall…\n") #If number bottles equal to 1 print this message if(n == 1): print("1 bottl...
true
328a3dcb5ac2524b33cd18f8a5c7b60db4e12e2b
AhmedEissa30/SIC202
/Python week/Day 2/Checker.py
1,777
4.3125
4
def displayInstruction(): #display function to show the user instructions print("\nChoose your operation: ") print("Press (8) to check Palindrome. Press (1) to check if the number PRIME. \n") print(" Press (0) to EXIT... :(") return True def prim...
true
58b9f2c8704396d6302bfcb8223e034781a104fb
effyhuihui/leetcode
/uncategoried/rotateArray.py
2,407
4.25
4
__author__ = 'effy' #-*- coding: utf-8 -*- ''' Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note: Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem. hint: 看起来好多ro...
true
162f59fb97253adce1ff39b40fa641ddd1cfcf24
jcbrockschmidt/project_euler
/p010/solution.py
697
4.125
4
#!/usr/bin/env python3 from time import time def sum_primes_below(n): """ Calculates the sum of all primes below `n`. """ primes = [2, 3] num = primes[-1] + 2 while num < n: is_prime = True limit = int(num**0.5) for p in primes: if p > limit: break ...
true
c289fec7d585d06c696bd94d9c0b8590cfa30110
ibbocus/oop_polymorphism
/polymorphism.py
839
4.65625
5
""" This is the parent/base/super class """ class Planet: def __init__(self, mass, spin, magnetic_field): self.mass = mass self.spin = spin self.magnetic_field = magnetic_field # this is a subclass of planets, which includes the parent class attributes as well as attributes specific to th...
true
3d658085a747514cdadebcbf57479e6a57901d81
SperZ/PythonFirstPractice
/array.py
372
4.25
4
arr1 = [1,2,3,4,5] arr2 = [4,5,6,7,8] # combines to arrays together to create one array with all elements of both arrays arr3 = arr1 + arr2; print(arr3); # arr_repeat = []; arr_repeat.append("eat"); arr_repeat.append("sleep"); arr_repeat.append("repeat"); arr_repeat.pop();# removes the item from the array/list at...
true
d9e075e78cf95649c0a1b2fc7df2febff46b2e2b
grayey/hackerrank-playful-py
/recursion.py
520
4.21875
4
#!/bin/python3 """ Task Write a factorial function that takes a positive integer, N as a parameter and prints the result of N!(N factorial). """ import math import os import random import re import sys # Complete the factorial function below. def factorial(n): new_n = n-1; return 1 if new_n == 0 else n * fa...
true
592648f17627d10b2154f94c3dc20cc8136722d9
Nick2253/project-euler
/Python/euler007/euler007.py
1,233
4.15625
4
import math def isPrime(num): '''Determines if num is prime input: numList = list of ints maxNum = int output: sumTotal = int sum of all multiples of numbers in numList less than maxNum ''' isPrime = True i = 2 #We don't care if num is divi...
true
98796dc9365babd222ddd97216558daac34d7c9d
FlyingJ/kaggle-learn-python
/roulette_probabilites.py
1,901
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 7 17:44:46 2019 @author: jason """ def conditional_roulette_probs(history): """Given a history of roulette spins (as list of integer values) return a dictionary where the keys are numbers on the roulette wheel, and the values are dictio...
true
b934a8fa0d994cc3ae00ab2fe7a8e7d867db7dd8
zayzayzayzay/Introduction_python
/Comrehension_part2.py
757
4.28125
4
#Dictionary comprehension word = "letters" letter_count = {letter: word.count(letter) for letter in word} print(letter_count) letter_counts = {letter: word.count(letter) for letter in set(word)} print(letter_counts) #Set Comprehensions a_set = {number for number in range(1,6) if number % 3 == 1} print(a_set) #generator...
true
c6e9e1f1724312e6ec7213807ae5533a78a3da8a
cs-fullstack-2019-fall/python-classobject-b-cw-marcus110379
/cw.py
2,534
4.125
4
def main(): problem1() problem2() problem3() # Create a class Dog. Make sure it has the attributes name, breed, color, gender. Create a function that will print all attributes of the class. Create an object of Dog in your problem1 function and print all of it's attributes. class Dog: def __init__(self,...
true
9a60a94ac5ddd89bf5aab0c03d5a5bada2d0dc8f
Rastwoz/python101
/3. Data Structures/Challenges and Solutions/Dictionaries/homework2.py
921
4.53125
5
#create dictionary with Hello in each language translator = {"French":"Bonjour", "Spanish":"Hola", "Italian":"Ciao", "German": "Guten Tag", "Indian": "Namaste" } #if user enters a language in dictionary, translate the word. Otherwise, let ...
true
8905adda00560a3cf143b8faba96d4f17b4429af
priestd09/project_euler
/e_16.py
497
4.125
4
#!/usr/bin/env python """ ##--- # jlengrand #Created on : Fri Jan 13 15:24:59 CET 2012 # # DESCRIPTION : Solves problem 16 of Project Euler 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? ##--- """ def sum_power_2(value): """ Returns...
true
d0a181c79d71fa82a8fdc193768ebc54ace30937
priestd09/project_euler
/e_4.py
979
4.25
4
#!/usr/bin/env python """ #--- Julien Lengrand-Lambert Created on : Wed Jan 11 14:42:54 CET 2012 DESCRIPTION : Solves problem 4 of Project Euler 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 ...
true
38f49214e119612b127236bd230f2b11bba088ee
priestd09/project_euler
/e_6.py
924
4.125
4
#!/usr/bin/env python """ #--- Julien Lengrand-Lambert Created on : Wed Jan 11 14:42:54 CET 2012 DESCRIPTION : Solves problem 6 of Project Euler Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. #--- """ def diff_sum_squares(value): """ ...
true
75bbb63e6278cca0465f5ff4b1d7aebc10ce77ee
ChenlingJ/cj
/hackerrank/lists.py
1,663
4.125
4
# Consider a list (list = []). You can perform the following commands: # # insert i e: Insert integer e at position i. # print: Print the list. # remove e: Delete the first occurrence of integer e. # append e: Insert integer e at the end of the list. # sort: Sort the list. # pop: Pop the last element from the list. # r...
true
6c82dd1a17cb90a870d009e5ea8ac40772dafcf0
GeekGoutham/Python-Interactive-Challenges
/Unique_String.py
1,122
4.15625
4
#Author = Vignesh Goutham def check_unique_dict(string_input): #Implmented using dict -- Poor performance as you need to check if there is more than one entry char_dict = {} #Still O(n) but dict takes more space then list for character in string_input: if ch...
true
25bf8924786bb17333d9425a722c74755e8c5768
GeekGoutham/Python-Interactive-Challenges
/String_reverse_inplace.py
1,306
4.28125
4
#Author = Vignesh Goutham def string_reverse(charlist): if charlist == None: #strings are immutable in python, we cant do a strict in-place string reverse print("No character array sent") #In-place algo = where the input is changed to output and a new memory/variable for o/p i...
true
943e612b6887ec0ad85c23fd2a2c7f4383b8c29a
napte/python-learn
/08_list_for_each.py
578
4.1875
4
def main(): a = [1, 2, 3] print 'List a = ' + str(a) print 'Doing for-each loop and printing numbers and their squares\n' for num in a: print '\n------\n' print 'num = ' + str(num) print str(num) + '^2 = ' + str(num**2) print '\n------\n' a = [1, 2, 3, 4, 5, 6, 7, 8] even = [] print 'List a...
true
ec6cd149c7835a225125b541c44d6e33d1e69765
richardcinca/CursuriPY
/ex4.py
573
4.28125
4
iterator=0 reversed_word="" word = input("Insert word: ") print("Your word is '{}'".format(word)) length=len(word) print("The length of the word is {} letters".format(length)) for var in word: #print("Var is {}".format(var)) #print(word[iterator]) #iterator+=1 #reversed_word=var+reversed_word #pri...
true
72d3ee8cb18777b39a4d19f8c9ff1338b121681f
jayadams011/KalPython
/2_4_poundsToKilograms.py
628
4.1875
4
""" (Convert pounds into kilograms) Write a program that converts pounds into kilograms. The program prompts the user to enter a value in pounds, converts it to kilograms, and displays the result. One pound is 0.454 kilograms. Here is a sample run: Enter a value in pounds: 55.5 55.5 pounds is 25.197 kilograms """ #user...
true
e4bf2decd4a1b5c8c246d5a50908abbd9e7b9f89
stevenb92/PythonShizzle
/numchar.py
310
4.34375
4
#Prompts for an input string and then returns the input string #along with the number of charcters in the string inputString = "" length = 0 while length == 0: print ("Enter an input string:") inputString = str(input()) length = len(inputString) print ("{} has {} characters".format(inputString,length))
true
3864a6a4ed3038f46d45dd19ab2b41a930b2a8fd
JoshOrndorff/LearnPythonByExample
/Unit6-2DLists/lesson2-WheresWaldo.py
1,737
4.21875
4
# Let's make a 2D list that contains a bunch of people. Since all these strings # are different lengths it would be easy for this table to look messy. Using # white space effectively can help the data look more organized. people = [["Jack", "Abagail", "Waleed" ], ["Rebeca", "Obi", "Orndorff"], ...
true
d43109a47056775be354e96ff28de941555ba6a5
sghwan28/PythonSelf-Learning
/Data Structure/Linked List/Q_Reversal.py
912
4.15625
4
from linked_list import Node ''' Question: Define a function to reverse a linked list The function will take in the head of the list as input and return the new head of the list ''' def reverse(head:Node): current = head previous = None next = None while current: # assign the next according...
true
af0f883c0b23d83f653309ebc7285c26ab5a198b
Andre-Williams22/SPD-1.4
/technical_interview_problems/most_frequent.py
828
4.25
4
# Most Frequently Occuring Item in Array #Example: list1 = [1, 3, 1, 2, 3, 1] # Output: => 1 def most_frequent(given_list): hashtable = {} # O(n) Space Complexity max_num = 0 # O(1) space => tracks the most occuring number max_count = 0 # O(1) space => tracks num of times number appears for i in g...
true
e788d3bf4f1da7321d9a3d4e96d8f96b719a5982
Tianchi1998/Massey-Assignments
/159.171 1A Question 1.py
565
4.15625
4
# The function below caculates the amount of money that should be repaid each week. def weekly_pay_back(loan_amount,number_of_weeks): result=loan_amount/number_of_weeks return result # The 7 and 8 lines ask the user to enter his information. loan_amount=int(input("Enter an amount: ")) number_of_weeks=int(input...
true
493c73b4d9ac741382161a6239138923f7a76eab
Tokeshy/EpamPythonTraining
/01_DataTypes/Task 1.4.py
335
4.375
4
### Task 1.4 #Write a Python program to sort a dictionary by key. DefDict = {1: 2, 3: 4, 2: 9, 4:8} # as ex SortedDict = {} KeyList = [] for key, value in DefDict.items() : if key not in KeyList: KeyList.append(key) for SortedKey in sorted(KeyList): SortedDict[SortedKey] = DefDict[SortedKey] print(Sorte...
true
3cd9f4d176b7843ac085568d13ebad1525da4828
Tokeshy/EpamPythonTraining
/02_Functions/Task 4.1.py
362
4.3125
4
### Task 4.1 # Implement a function which receives a string and replaces all `"` symbols # with `'` and vise versa. def Replacer (in_str): out_str = '' for ch in in_str: if ch == '"' : ch = "'" elif ch == "'": ch = '"' out_str = out_str + ch return out_str ...
true
eef06c93d884a33eabb2ccb7acd2ab0d71b1182b
Bochkarev90/python2019
/turtle/task_14.py
278
4.25
4
import turtle turtle.shape('turtle') def draw_star(n, size): """ Draws a star with n vertices. size - length of the star's side """ angle = 180 - 180 / n for _ in range(n): turtle.forward(size) turtle.left(angle) draw_star(15, 150)
true
2346e66a526ad1773ab916166bcc69f2d77b0b9a
belug23/Belug-s-Project-Euler-python-answers-in-TDD
/pe_001/pe_001.py
938
4.3125
4
# 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. def sum_of_multiple_of_3_and_5_under(limit: int) -> int: if limit < 0: raise ValueError("Minimum num...
true
450a73aaf4e3e7ac0d71cc015d784e87d69394a1
LynnaOrm/PythonFundamentals
/String_and_List.py
838
4.25
4
#Find and Replace, replace day with month. words = "it's thanksgiving day. It's my birthday, too!" print words.find('day') newWord = words.replace('day','month') print newWord #Min and Max, print the min and max in a list. x = [2,54,-2,7,12,98] print min(x) print max(x) #First and Last, print the first and last value...
true
eca2a834d3860d5a5d2ed7d3bdd6bdff19ed0b1f
LynnaOrm/PythonFundamentals
/FindCharacters.py
490
4.125
4
#Write a program that takes a list of strings and a string containing a single character, and prints a new list of all the strings containing that character. #hint every word containing the letter "o" word_list = ['Hello','world','my','name','is','Lynna'] char = 'o' def characters(word_list, char): new_list= [] ...
true
246dfe73de2381ef10f837d60fbab0ffbc573306
code-drops/hackerrank
/Data structures/01. Arrays/04. Left Rotation.py
652
4.25
4
''' A left rotation operation on an array of size n shifts each of the array's elements 1 unit to the left. For example, if 2 left rotations are performed on array , then the array [1,2,3,4,5] would become [3,4,5,1,2]. Given an array of n integers and a number,d , perform d left rotations on the array. Then print the u...
true
31e655bd56214fd451d7b7a3650f99df06f843b4
code-drops/hackerrank
/contest/Hack The Interview IV(Asia Pacific)/arrange students.py
1,819
4.28125
4
/* A classroom has several students, half of whom are boys and half of whom are girls. You need to arrange all of them in a line for the morning assembly such that the following conditions are satisfied: The students must be in order of non-decreasing height. Two boys or two girls must not be adjacent to each other. ...
true
1421ac4a6580bdc60fdc0e05106f0828be93b937
code-drops/hackerrank
/Algorithms/01. Warmup/07. Staircase.py
419
4.375
4
''' Consider a staircase of size n=4: # ## ### #### Observe that its base and height are both equal to n, and the image is drawn using # symbols and spaces. The last line is not preceded by any spaces. Write a program that prints a staircase of size n. ''' n = int(input()) for i in range(n): for tab in rang...
true
8f222e213fd69c171b553e1a6006b98fea65b34a
iamsiva11/Codingbat-Solutions
/string1/left2.py
324
4.21875
4
""" Given a string, return a "rotated left 2" version where the first 2 chars are moved to the end. The string length will be at least 2. """ def left2(str): if len(str)<2: return str else: return str[2:]+str[:2] print left2('Hello') # 'lloHe' print left2('java') # 'vaja' print left2('Hi') # 'Hi' ...
true
bef196da12fbfa1af31ecb3c51ecf14e643a69a1
iamsiva11/Codingbat-Solutions
/list2/big_diff.py
1,151
4.15625
4
""" Given an array length 1 or more of ints, return the difference between the largest and smallest values in the array. Note: the built-in min(v1, v2) and max(v1, v2) functions return the smaller or larger of two values. """ def big_diff(nums): #Edge Cases if(len(nums)<1): return [] if(len(nums)<2): retur...
true
a6e77d06f5b4ba618a8c06343dc132f179cb2890
iamsiva11/Codingbat-Solutions
/string1/first_two.py
452
4.1875
4
# Given a string, return the string made of its first two chars, # so the String "Hello" yields "He". If the string is shorter than length 2, # return whatever there is, so "X" yields "X", and the empty string # "" yields the empty string "". def first_two(str): first2=str[:2] if len(str)<2: return str return ...
true
40a8dd0eb042c746ccf292335555be50c545cbbc
Enfioz/pands-problems
/squareroot.py
316
4.21875
4
# Enter positive floating-point number as input # Output an approximation of its square root from math import sqrt def squareroot(x): return(sqrt(x)) x = float(input("Please enter a positive number: ")) ans = (sqrt(x)) y = format(ans, ".1f") print("The square root of %s is approx." % x, y) # push to github
true
b723e7816fe7a6a70df9dde60283c319009dfa26
viruskingkk/PyMiscellaneous
/AI_guess_number.py
549
4.1875
4
while True: try: num = int(input('Enter a number: ')) except ValueError: print ("The input must be a integer!") continue break guess = num / 1.3 middle = num / 2 step = 0 while guess != num: if num > guess: guess += middle print (("I guess: "), guess) el...
true
ea95b3d2b93b3c8ecc05cf6c5d2bbf75858f7b87
Yihu4/Python_study
/2018_after_vacation/how_to_have_infinite_power/fibonacci_counting.py
436
4.15625
4
def fibonacci_counting(n): current = 0 after = 1 for i in range(n): current, after = after, current + after return current # 迭代 print(fibonacci_counting(36)) print(fibonacci_counting(5)) mass_of_earth = 5.9722 * 10**24 # kilograms print(2**10) mass_of_rabbit = 2 # 2 kilograms per rabbit ...
true
975a6b351292c23f64415f1eb6d0dce5c037dce0
hxtruong6/Python-bootcamp
/Generator/homework.py
970
4.5
4
# 1.Create a generator that generates the squares of numbers up to some number N def generates(N): for i in range(N): yield i**2 # 2.Create a generator that yields "n" random numbers between a low and high number (that are inputs). import random def rand_num(low,high, n): for x in range(n): ...
true
659a6a1d5a2daea427240d774f144919606e51d7
gurgalex/pythonmathbook
/ch2/golden_fib.py
944
4.15625
4
"""Compares the fibonacci sequence to the golden ratio using a graph""" from matplotlib import pyplot as plt def fiblist(n): """Returns a list of n fibonacci numbers""" sequence = [i for i in fibseq(n)] return sequence def fibseq(n): """Yields the next fibonacci number""" # Set values for fib 1 ...
true
b7163fc8ddc4386c6f98665b327c7073c513ab73
TulebaevTemirlan/ICT_labs
/Task1/ex33.py
390
4.15625
4
number_of_breads = float(input("Enter the number of breads you want to buy: ")) discount = 60 price = 3.49 answer = number_of_breads * price * ((100 - discount) / 100) print("\nThe regular price is -- $ " + "{0:.2f}".format(int(number_of_breads * price))) print("The discount is -- " + str(discount) + " %") print("Th...
true
fcad3fef0a680c9d900642c9ff2556a9f5ea95ee
TulebaevTemirlan/ICT_labs
/Task1/ex16.py
295
4.4375
4
# Hint: The area of a circle is area = πr2. # The volume of a sphere is volume= 4 3πr3. import math r = float(input("Enter the radius: ")) area = math.pi * (r**2) volume = math.pi * (r ** 3) print("\nThe area of a circle is " + str(area)) print("The volume of a sphere is " + str(volume))
true
362f8adc6335ea128392a3c2460f7fdfe8b15f7d
TulebaevTemirlan/ICT_labs
/Task1/ex28.py
321
4.15625
4
import math temperature = float(input("Enter the temperature of a wind in Celcius: ")) wind_speed = float(input("Enter the speed of a wind kilometers/hour: ")) WCI = 13.12+ 0.6215 * temperature - 11.37 * wind_speed**0.16 + 0.3965 * temperature * wind_speed**0.16 print("\nThe Wind Chill Index is: " + str(round(WCI))...
true
9a12ff9ff84c6c9e99035d19544678af1d77eab0
BrianCUNY/IS211_Assignment1
/assignment1_part2
459
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Coding assignment 1, P2""" class Book(object): author = " " title = " " def __init__(self, author, title): self.author = author self.title = title def display(self): bookinfo = '"{}, written by {}"'.format(self.title, self.author) print bo...
true
eb984ce3396e00273e331804620635d70dde108e
AdegokeFawaz/header
/Numbers.py
521
4.15625
4
#this code adds the first number and the second number first_number=4 second_number=4 print(first_number+second_number) #This code divides the first number and the second number first_number=16 second_number=2 print(first_number/second_number) #This code multiplies the first number and the second number first_number=4 ...
true
e1431f0ee27aa1b590a1cbd0039563baaa65cdef
wahabshaikh/problems-vs-algorithms
/problem_1.py
897
4.40625
4
def sqrt(number): """ Calculate the floored square root of a number Args: number(int): Number to find the floored squared root Returns: int: Floored Square Root """ try: if number == 0 or number == 1: return number start = 1 end = number while (start <= ...
true
f0cf672dad43443e587e08e37a2250f01312fa9c
shardul-shah/Project-Euler
/p4efficient.py
726
4.15625
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 product of two 3-digit numbers. """ from itertools import combinations_with_replacement def main(): domain = [] for i in range(100, 100...
true
579b9ce5760116e18c8c367d116540f3196b74ec
mariahabiba078/python-code
/.github/workflows/fizzbuzz prb method1.py
530
4.28125
4
#So the problem is basically to give you the numbers 1 to 100, if the number is divisible by 3, print # 'Fizz', if divisible by 5, print 'Buzz', if divisible by 3 and 5, print 'FizzBuzz'. For other numbers # just print out the number itself." for fizzbuzz in range(100): if fizzbuzz % 3 == 0 and fizzbuzz % 5 == ...
true
deeb87115360c28bf4ea428c637edfac3295040b
shenny88/python_casestudies
/cs4/7_factorial.py
282
4.21875
4
# 7. program which can compute the factorial of a given numbers. Use recursion # to find it. import sys def factorial(mynum): if mynum == 1: return 1 else: mynum = mynum * factorial(mynum -1) return(mynum) num = int(sys.argv[1]) print(factorial(num))
true
f01ff5ab3a092509e90471f44840c90a6fe0d257
mhayes2019/100-Days-of-Codeing-udemy
/day-3-1 Odd or Even.py
551
4.34375
4
# 🚨 Don't change the code below 👇 number = int(input("Which number do you want to check? ")) # 🚨 Don't change the code above 👆 #Write your code below this line 👇 #need to figure out if the number the user chose will come out zero after doing the modulous of 2, because any even number is divided by 2. if the numb...
true
bfdb276cd9717bc16c4b9de6ed6bd486c153f3d7
assafZaritskyLab/Intro_to_CS_SISE_2021-2022
/week_2/Example_12.py
577
4.21875
4
# # determine whether a number is prime or not # number = int(input("Enter a number larger than 1: ")) # is_prime = True # assuming the number is prime # # i in range(2, number) # i = 2 # while i < number: # check from 2 to number - 1 # if number % i == 0: # is_prime = False # i += 1 # i = i +1 # #...
true
c9b513abc057ff84ffd6d97bcca99b07d9d1849b
assafZaritskyLab/Intro_to_CS_SISE_2021-2022
/week_2/Example_13.py
391
4.25
4
# determine whether a number is prime or not number = int(input("Enter a number larger than 1: ")) is_prime = True # assuming the number is prime i = 2 while i < number and is_prime: # check from 2 to number - 1 if number % i == 0: is_prime = False i += 1 # i = i + 1 if is_prime: print("The cho...
true
3c794c0ee8fc7308acae66fdd6006b50ee531bbb
tenguterror/personal-growth
/messingWithStrings.py
367
4.40625
4
# This will ask for the user name and print it out last then first. # This was done using string formatting(f strings) and string methods so is the user inputs in lower it will titlecase it print('Hello, what is you first name?') firstName = input().title() print('What is you last name?') lastName = input().titl...
true
11fba9c4267e533ad849a9dc2458d88eb1c5e288
tejaswiniR161/fewLeetCodeSolutions
/Concepts/Sorting/Merge.py
1,311
4.375
4
#Merge sort uses the divide and conquer technique #time complexity is O(nlogn) #space however is array=input("Enter the numbers to sort them, enter space sepearted integers") array=array.split(" ") #for some reason remember this so, if you use list(array) it'll split even the spaces so spaces will also be in the res...
true
e748bfaff2149bcc6a08e7d7c47089efc08a0894
sanjipmehta/prime_number
/prime.py
237
4.21875
4
num=int(input("Enter the number:")) for x in range(2,num): if (x==2 or x==3 or x==5 or x==7): print(x,"is a prime number") elif(x%2!=0 and x%3!=0 and x%5!=0 and x%7!=0): print(x,"is a prime number") else: print(x,"is not prime")
true
bfb76e52a351bf9204af296325bca82da26cb5a0
adowdell18/HowMuchDoesItCostToPaintaTurtle
/paint-a-turtle.py
1,794
4.46875
4
#Computing area of shell import math diameter_shell = eval(input("Enter the diameter of the turtle's shell (in inches): ")) radius_inches_shell = diameter_shell/2 radius_feet_shell= radius_inches_shell/12 area_shell = (3.14* (radius_feet_shell)**2)/2 print("The area of the turtle's shell is ",area_...
true
16ebd39c87c1a35e69c7074700a0d4908580c556
suareasy/project_euler-python
/solutions/001.py
404
4.3125
4
""" 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. """ def run() -> int: res = 0 n = 1000 for i in range( n ): if i%3 == 0 or i%5 == 0: ...
true
32e49bff29d0eda5af5608ead6c78bd440fd7c2f
sunny0910/Data-Structures-Algorithms
/stacks & queue/next_greater_element.py
1,860
4.375
4
def next_greater_element(array): """ This approach uses two for loops, one to iterate over every element and second to iterate over subsequent elements to find the next greater element. The time complexity for this approach is O(n^2) :param array: List :return: None """ for i in range(le...
true
71497189bfae4f11e908d988842ec3adec70c55a
sunny0910/Data-Structures-Algorithms
/binary_trees/distance_between_nodes.py
1,269
4.28125
4
from binary_trees.path_to_node import path_to_node from binary_trees.binary_search_tree import BinarySearchTree def distance_between_nodes(root, a, b): """ Function to calculate the distance between two target nodes. Distance is the number of lines covered in the traversal till that node. :param root:...
true
21386b540c4d1a0bcc0e97a2e9f546ed7efeb34c
sunny0910/Data-Structures-Algorithms
/binary_trees/width_of_tree.py
1,324
4.4375
4
from binary_trees.binary_search_tree import BinarySearchTree def max_width(root): """ Function to calculate width of a binary tree. Width is the maximum number of nodes at any level in a binary tree. This approach uses level order traversal and return maximum length of levels in a tree. :param roo...
true
dca3ffd56ae472f37a3b3d73b1c84790d24d3c9c
sunny0910/Data-Structures-Algorithms
/binary_trees/zigzak_traversal.py
2,066
4.4375
4
from binary_trees.binary_search_tree import BinarySearchTree from binary_trees.print_level import print_level from binary_trees.height_of_btree import height def zigzak(root, clockwise): """ Function to print the zig-zak traversal of a binary tree. This function prints new levels by traversing the tree ag...
true
f843b65dec038a2c8db23ebb0200dd9503651273
sunny0910/Data-Structures-Algorithms
/matrix/matrix_path.py
1,681
4.28125
4
def path_exits(a): """ Function to check if a matrix path exists from top to bottom :param a: List # Matrix :return: String """ if 1 not in a[0]: return 'safe' q = [[] for i in range(len(a))] for i in range(len(a)): for j in range(len(a[0])): if a[i][j] == 1: ...
true
fc63aaa4ee0d2fb7da70c8046653fd67393f541e
dlfosterii/python-105
/exercise1.py
399
4.25
4
#prompt user for a single grocery item # -append it toa the 'grocieres' list #in an infinate loop, prompt the user, prompt the user for an item # -append the item to the list # -print()the list after you add the item #to exit out of the loopm oress Ctrl-C groceries = [] while True: item = input(f'Enter an i...
true
1d774247fe076f3c0648b0c1505ce9462de0822f
emord/project-euler
/python/prob51-60/prob55.py
1,692
4.25
4
#!/usr/bin/python3 """ If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, 349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337 That is, 349 took three iterations to arrive at a palindrome. Although no one has proved it yet, it is tho...
true
d213e7854b1fa806a55c1dad42715b3501929252
emord/project-euler
/python/prob1-10/prob2.py
961
4.21875
4
#!/usr/bin/python3 """ Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the ...
true
739ae13d86f18ce54b47007fc31abb8bab8e6ac2
adefowoke/coffee-machine
/task/machine/coffee_machine.py
2,928
4.125
4
# create inputs for the machine materials # initialize machine resources water, milk, coffee_beans, cups, money = 400, 540, 120, 9, 550 def remaining(): global water, milk, coffee_beans, cups, money # water += 0 # milk += 0 # coffee_beans += 0 # cups += 0 # money += 0 # if money >= 1: ...
true
9bad3f9582f4a8a85af82d0e0e6b3a7be9ca02ca
thhuynh91/Python_Practice
/Even_Fibonacci_numbers.py
478
4.46875
4
#The Fibonacci number is generated by adding the previous two terms. #For example: below is list of Fibonacci numbers: #1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... #Find the sum of the even-valued terms by considering the terms in Fibonacci sequence whose value do not exceed a given "n" def Fibo(n): total = 0 f1 =...
true
47e8ec41897b4d624f36816d17ed35ae7e2c4a0d
lisahachmann/SoftDesSp15
/toolbox/word_frequency_analysis/frequency.py
2,452
4.5625
5
""" Analyzes the word frequencies in a book downloaded from Project Gutenberg """ import string def get_word_list(file_name): """ Reads the specified project Gutenberg book. Header comments, punctuation, and whitespace are stripped away. The function returns a list of the words used in the b...
true
462dbe269a345d5bd7b08bf70c1375304a5c0b66
sajeendragavi/Learn-Python-Programming-Masterclass
/9_/dictionary_2.py
2,048
4.125
4
# fruit = {"orange" : "a sweet, orange, citrus fruit", # "apple" : "good for making cider", # "lemon" : "a sour, yellow citrus fruit", # "grape" : "a small, sweet fruit growing in bunches", # "lime" : "a sour, green citrus fruit", # "apple" : "round and crunchy"} ...
true
a56c6317f6cc132023f3eb645b7b580b0d67afaf
Dpoudel18/Data-Structures-in-Python
/distinct_elements.py
344
4.1875
4
# A python function to print all the distinct elements of the array. def distinct_elements(my_array): for i in range(len(my_array)): repeat = 1 for j in range(0, i): if (my_array[i] == my_array[j]): repeat = 2 break if (repeat == 1): ...
true
f777d76072a405e156c3c9fd7041eeb3dc068764
jwhitish/learning-python
/strong-pw-detection.py
863
4.15625
4
#simple password strength checker import re userPW = str(input("Enter a password: ")) if len(userPW) < 8: print('Password is not long enough') else: lowerTest = re.compile(r'[a-z]+') test1 = lowerTest.findall(userPW) if len(test1) > 0: print('has lower alpha') upperTest = re.compile...
true
6e83c0ca10ad51d8347fe4398ed02b3590937ac9
kgisl/pythonFDP
/code/mergesort.py
1,184
4.1875
4
import itertools # http://j.mp/zipLongest def mergesort(series): '''iterative mergesort implementation @author kgashok @param series is a sequence of unsorted elements @returns a list containing sorted elements Testable docstring? https://docs.python.org/2/library/doctest.html >>> mergeso...
true
961b618935e47a24fff62e37ada5bebba1308de8
ShiyuCheng2018/ISTA130-Intro-To-Programming
/assignments/assignment_3/try.py
482
4.34375
4
''' pseudocode: 1. define the function name and the argument: String 1.1 assign an empty string to a variable name called result 1.2 loop through the string that passed in as a local variable cha 1.21 assign double times cha to the result 1.3 print result to check if its expected 1.4 return the ...
true
fa76b3b7e329162fafea995c657b5b7517c80155
SherazKhan/DS-rep
/Utils/Visualization/box_plot.py
2,041
4.15625
4
# -*- coding: utf-8 -*- """ This file contains function(s) for creating box plots. Created on Thu Aug 10 09:05:23 2017 @author: imazeh """ import numpy as np import matplotlib.pyplot as plt def create_box_plot(df, x_discrete_variable, y_cont_variable, with_outliers=True, all_possible_x_vals=None, ...
true
839642c0f8764508a721f7a6a5a4dadb94a26a01
M-Usman-Tahir/PythonPrograms
/Problem Set 2 Task 4.py
1,764
4.125
4
# Programming Fundamentals # Problem Set 2 # Submitted By: Sundas Noreen # Task 4 # Using Tuples to test our program on a variety of choices of Package Sizes. print("\nProblem Set 2, Task 4") bestSoFar = 0 # Keeping track of largest number of McNuggets that cannot be bought in exact quantity. Combination_1 = ...
true
a10496cbfb02d3aec8cb034bb2b4f121a541b45e
M-Usman-Tahir/PythonPrograms
/Tuples and Lists Assignment.py
842
4.5625
5
#Tuples and List by Sundas Noreen #Writing a function that emulates the builtin zip function. #It will take iterables and return a list of tuples. #Each tuple will contain one element from each of the iterables passed to the function. def My_Function(x,y): # Defining the Function with two Input Paramete...
true
43fcedf50771bf61bfc70072c53ca04c1580662d
prajapati123476/clean-code-challenge
/challenge-7/largest_element.py
462
4.625
5
# Python3 program to print the largest element # in a list # Input Constraint: array_size >= 5 list_size = 0 # Input until Constraint satisfied while list_size < 5: list_size = int(input("Input size: ")) # Declare empty list elements = list() # Read list from user for i in range(list_size): num = int(input('Input...
true
454e460f003c75ec9c5fa4123d428afb1370a5d2
prajapati123476/clean-code-challenge
/challenge-9/count_vowel_words.py
904
4.40625
4
# Python3 program to count the number of words # in input string that start with a vowel # Input Constraint: max_string_size = 500 import sys # Count num of words starting with vowel in param def count_vowel_words(check_string): count = 0 # Generate list of words, on basis of ' ' list_of_words = check_string.spl...
true
acf3c0030603d0f6ccadada5af951d738fb47134
BW1ll/Projects
/Python/python_crash_course/Chapter 4/4.3-4.9.py
425
4.125
4
for i in range(1, 21): print(i) nums = [value for value in range(1,1_000_000)] print(nums) print(min(nums)) print(max(nums)) print(sum(nums)) odd_nums = list(range(1, 21, 2)) for num in odd_nums: print(num) multiple3 = list(range(3, 31, 3)) for num in multiple3: print(num) cubes1 = list(range(1, 11)) f...
true
0ab2aed573e8d75fcd62f649574e971c382bb224
SubhadeepSen/Python-Core-Basics
/4_Methods/3_Map_Filter.py
668
4.1875
4
def square(num): return num**2; numbers = [1,2,3,4,5,6,7,8]; #Using for loop for n in numbers: print("Square of {} is {}".format(n, square(n))); #Using map() function we can map a function to a list of elements #map(functionNeedsToBeExecuted, listOfElemetns) #returns map object print(map(square, numbers));...
true
33bb208d1b854e9c01ea723f1831fb473f252783
SubhadeepSen/Python-Core-Basics
/1_DataTypes/String_operation.py
1,430
4.53125
5
name = "Subhadeep Sen"; print("Name: ", name); #Length of a given string length = len(name); print("Length: ", length); #Character at particular index name_0 = name[0]; print("Name[0]: ", name_0); name_5 = name[5]; print("Name[5]: ", name_5); #Substring # str[startIndex:lastIndex] firstName = name[0:9]; print("Firs...
true
8f98824fdc04655806e918583498749abb515bcf
rzhao04/wave-2
/month name to number of days.py
290
4.1875
4
month = str month = raw_input ("what is month: ") if (month in ["january", "march", "may", "july", "august", "october", "december"]): print ("31 days") if (month in ["april", "june", "september", "november"]): print ("30 days") if (month == "february"): print ("28 or 29 days")
true
d5e5fb6e29e682d8e21f55bef8c16171768a4d44
fixitcode/Hello-python
/Fifo.py
1,102
4.25
4
# coding: utf-8 # In[16]: '''A queue follows FIFO (first-in, first-out). FIFO is the case where the first element added is the first element that can be retrieved. Consider a list with values [1,2,3]. Create functions queueadd and queueretrieve to add and pop elements from the list in FIFO order respectively. Aft...
true