blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
63a9ad33825620de6667c0d694471fbe8e939149
Garima-sharma814/The-faulty-calculator
/faultycalculator.py
1,596
4.3125
4
# faulty calculator # Design a calculator which will correctly solve all the problems except the following ones: # if the combination of number contain 56 and 9 it will give you 77 as the answer no matter what operation your perform # same for 45 and 3 , 56 and 6 # Your program should take operator and two numbers as i...
true
ce9b53ac17bff836d778e08c55000090e9a3b1c3
MAD-reasoning/Python-Programming
/Elementry/Elementry_04.py
324
4.28125
4
# Write a program that asks the user for a number and prints the sum of the numbers 1 to number. try: num_sum = 0 number = int(input("Enter a natural number: ")) for i in range(1, number+1): num_sum += i except ValueError: print("Enter a valid number") else: print("Sum = ", num_su...
true
e29ff540a0375f255ae163e88d222460ee72e8d9
jay-bhamare/Python_for_Everybody_Specialization_University_of_Michigan
/PY4E_Python_Data_Structures/Assignment 8.4.py
996
4.1875
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: jayvant # # Created: 08/04/2020 # Copyright: (c) jayvant 2020 # Licence: <your licence> #------------------------------------------------------------------------------- ...
true
6be03d03fa0505d440baa4a07c9726fb6c752644
TuhinChandra/PythonLearning
/Basics/Shaswata/test2_video8_Variables.py
889
4.53125
5
print('Variables examples are here...') x = 10 # Anything in python is an Object unlike other languages print('x=', x, sep='') print('type of x :', type(x)) print('id of x :', id(x)) y = 15 print('y=', y, sep='') print('id of y :', id(y)) # Now see the id of y will change to id of x y = 10 print('# Now see the id of y...
true
66858c07ada89061322b79ebf6898778d2bce2b8
aricaldoni/band-name-generator
/main.py
390
4.28125
4
#Welcome message print("Welcome to the authomatic Band Name generator.") #Ask the user for the city that they grew up in city = input("What city did you grow up in?: \n") #Ask the user for the name of a pet pet = input("What is the name of your pet: \n") #Combine the name of their city and pet and show them their band ...
true
5c90d207ec78f0c29467ad3e5f7a66bca9d21e44
JaredJWoods/CIS106-Jared-Woods
/ses8/PS8p5 [JW].py
1,144
4.1875
4
def incomeTax(gross): if gross >= 500001: rate = 0.30 print("You are in the highest tax bracket with a 30% federal income tax rate.") elif gross >= 200000 and gross <= 500000: rate = 0.20 print("You are in the middle tax bracket with a 20% federal income tax rate.") else: rate = 0.15 pr...
true
28cde805af45660b4d1f69504a1f709f5a9d28a9
sofiacavallo/python-challenge
/PyBank/Drafts/homework_attempt_4.py
2,126
4.1875
4
# Reading / Processing CSV # Dependencies import csv import os # Files to load and output budget_data = "budget_data.csv" budget_analysis = "budget_analysis.txt" # Read the csv and convert it into a list of dictionaries with open(budget_data) as budget_data: reader = csv.reader(budget_data) # Read the he...
true
67a4705ab7e55c17de86ac966540fb552e4b645c
qaespence/Udemy_PythonBootcamp
/6_Methods_and_Functions/Homework.py
2,178
4.4375
4
# Udemy course - Complete Python Bootcamp # Section 6 Homework Assignment # Write a function that computes the volume of a sphere given its radius def vol(rad): return (4.0/3)*(3.14159)*(rad**3) print(vol(2)) # Write a function that checks whether a number is in a given range # (Inclusive of high and low) def...
true
5948ceed31db511b3ec6894e8c76e9a3f80f9865
lynnvmara/CIS106-Lynn-Marasigan
/Session 5/Extra Credit.py
935
4.21875
4
print("What is your last name?") name = input() print("How many hours?") hours = int(input()) print("What is your rate per hour?") rate = int(input()) if hours > 40: print(name + "'s regular pay for the first 40 hours is $" + str(rate) + " per hour for a total of $" + str(40 * rate) + ". The " + str(hours - 40) + " h...
true
c25c418679ffdeb532dffb1409fbfe486167ca5a
lynnvmara/CIS106-Lynn-Marasigan
/Session 7/Assignment 2.py
237
4.125
4
print("What is the starting value?") start = int(input()) print("What is the stop value?") stop = int(input()) print("What is the increment value?") increment = int(input()) while start <= stop: print(start) start = start + increment
true
34c244ca5ffea4bd647dd29bc2eb7bccfa436db8
radunm/jobeasy-algorithms-course
/HW_1.py
1,789
4.1875
4
# Sum of 3 modified # Rewrite a program with any number of digits. # Instead of 3 digits, you should sum digits up from n digits number, # Where User enters n manually. n > 0 from random import randint min_rand = 1 max_rand = "9" result = 0 digit = int(input("Please, enter digit: ")) digit -= 1 while digit > 0...
true
998649baa7285122e041cdaf4a5dfbe984bc7c86
vishnuap/Algorithms
/Chapter-03-Arrays/Zip-It/Zip-It.py
1,449
4.875
5
# Chapter-3: Arrays # Zip-It # 1. Create a function that accepts two arrays and combines their values sequentially into a new array at alternating indices starting with the first array. Extra values of either array should be included afterwards. Given [1,2] and [10,20,30], return [1,10,2,20,30] # 2. Combine the two arr...
true
c847c6634e70a105c0fd65c0f83619e55e07937f
vishnuap/Algorithms
/Chapter-01-Fundamentals/You-Say-Its-Your-Birthday/You-say-its-your-Birthday.py
385
4.21875
4
# Chapter-1: Fundamentals # You-say-its-your-Birthday: # If 2 given numbers represent your birth month and day in either order, log "How did you know?", else log "Just another day..." myBDate = [3, 6] def bd(num1, num2): if num1 in myBDate and num2 in myBDate: print("How did you know?") else: ...
true
56c6b7dc97ec4603e5ab899bd72463ba3b15db7f
vishnuap/Algorithms
/Chapter-03-Arrays/Array-Nth-Largest/Array-Nth-Largest.py
2,588
4.40625
4
# Chapter-3: Arrays # Array-Nth-Largest # Given 'arr' and 'N', return the Nth largest element, where N-1 elements are larger. Return null if needed # Assume the arguments are an array with integers and an integer and both are passed to the function # Since we want Nth largest such that N-1 elements are larger, if ther...
true
3dc49d530e386fd3b266e007bc640f34d7046ef2
vishnuap/Algorithms
/Chapter-01-Fundamentals/Always-Hungry/Always-Hungry.py
489
4.1875
4
# Chapter-1: Fundamentals # Always-Hungry # Create a function that accepts an array and prints "yummy" each time one of the values is equal to "food". If no array element is "food", then print "I'm hungry" once # Assume the argument passed is an array def yummy(arr): hungry = 1 for i in range(0, len(arr)): ...
true
93cb895cbc0a72249e25dac5489153f304dcac91
vishnuap/Algorithms
/The-Basic-13/Print-Ints-and-Sum-0-255/Print-Ints-and-Sum-0-255.py
260
4.28125
4
# The Basic 13 # Print-Ints-and-Sum-0-255 # Print integers from 0 to 255. With each integer print the sum so far def printIntsSum(): sum = 0 for i in range(0, 256): sum += i print("{} - Sum so far = {}").format(i, sum) printIntsSum()
true
23355dd307a13236d38a8bde6571435771f8f1c2
vishnuap/Algorithms
/Chapter-03-Arrays/Array-Nth-to-Last/Array-Nth-to-Last.py
453
4.46875
4
# Chapter-3: Arrays # Array-Nth-to-Last # Return the element that is N from array's end. Given ([5,2,3,6,4,9,7], 3), return 4. If the array is too short return null # Assume the arguments are an array and an integer and both are passed def nthToLast(arr, num): return None if num > len(arr) else arr[-1 * num] myAr...
true
2dee4ac13bfc34d72b3a4bb04d199ab8be5de782
vishnuap/Algorithms
/Chapter-01-Fundamentals/What-Really-Happened/What-Really-Happened.py
1,334
4.15625
4
# Chapter-1: Fundamentals # What-really-Happened # (refer to Poor Kenny for background) # Kyle notes that the chance of one disaster is totally unrelated to the chance of another. Change whatHappensToday() to whatReallyHappensToday(). In this new function test for each disaster independantly instead of assuming exactly...
true
c86a6295b69a14f635b5433edd3ad9f1b6044ca6
vishnuap/Algorithms
/Chapter-04-Strings-AssociativeArrays/Drop-the-Mike/drop-the-mike.py
997
4.25
4
# Create a function that accepts an input string, removes leading and trailing white spaces (at beginning and ending only), capitalizes the first letter of every word and returns the string. If original string contains the word Mike anywhere, immediately return "stunned silence" instead. Given " tomorrow never dies ...
true
0d0ffaa8f3359bedd40bb5a1495339eecb8f03bc
vishnuap/Algorithms
/Chapter-01-Fundamentals/Multiples-of-3-But-Not-All/Multiples-of-3-but-not-all.py
386
4.65625
5
# Chapter-1: Fundamentals # Multiples of 3 - but not all: # Using FOR, print multiples of 3 from -300 to 0. Skip -3 and -6 # multiples from -300 down means multiply 3 with -100 and down. -3 and -6 are 3 * -1 AND 3 * -2. So if we skip them, the multipliers are -100 down to -3. for i in range(-100, 1): if ((i != -1...
true
905092abe8da1ea55e92a9d4a6b7f34565f2597b
vishnuap/Algorithms
/Chapter-02-Fundamentals-2/Statistics-Until-Doubles/Statistics-Until-Doubles.py
838
4.1875
4
# Chapter-2: Fundamentals-2 # Statistics-Until-Doubles # Implement a 20-sided die that randomly returns integers between 1 and 20 (inclusive). Roll the die, tracking statistics until you get a value twice in a row. After that display number of rolls, min, max and average import random as rd def stats(): done = Fa...
true
31b22e49ea518465e4e9b84f9bce3ff9ac222f46
f-alrajih/Simple-Calculator
/directions.py
2,879
4.5625
5
# Welcome, Faisal, to your first project in Python! # Today's project is to build a simple calculator that allows the user to choose what type of operation they want to do (add, subtract, multiply, or divide) and then takes the two numbers the user gives it and does the operation. # You will need to build four differ...
true
9d6b104a638a7d302a5aa5f89467ce47d7b5e972
tarunvelagala/python-75-hackathon
/input_output.py
239
4.125
4
# Input Example name, age = [i for i in input('Enter name and age:').split()] # Output Example print('Hello "{}", Your age is {}'.format(name, age)) print('Hello %s, Your age is %s' % (name, age)) print('Hello', name, 'Your age is', age)
true
2ccf71624478a3e9867ca75475630053040631b2
dheerajsharma25/python
/assignment8/assignment9/ass9_1.py
437
4.3125
4
#Q.1- Create a circle class and initialize it with radius. Make two methods getArea and getCircumference inside this class. import math class circle: def __init__(self,radius): self.radius=radius def area(self): getarea=math.pi*self.radius*self.radius print(getarea) def circumference(self): ...
true
47f111e1242d64f5655027c836ebfa25b802f312
dheerajsharma25/python
/assignment10/ass10_4.py
646
4.15625
4
#Q.4- Create a class Shape.Initialize it with length and breadth Create the method Area. class shape: def __init__(self,length,breadth): self.length=length self.breadth=breadth def area(self): self.result=self.length*self.breadth class rectangle(shape): def arearect(self): print("area of re...
true
c0c4d692956d733993d63a42fdfdcf609c9b7eba
sv1996/PythonPractice
/sortList.py
509
4.28125
4
number =[3,1,5,12,8,0] sorted_list =sorted(number) print("Sorted list is " , sorted_list) #original lst remain unhanged print("Original list is " , number) # print list in reverse order print("Reverse soretd list is " , sorted(number , reverse =True)) #original list remain unchanged print("Original list is " , number)...
true
a528ae279f5773160001dd56b9ffb7df47714a86
viditvora11/GK-quiz
/Python assements/v2 (Instructions and welcome)/v2a_instructions_and_welcome.py
707
4.4375
4
#Asking if they want to know the quiz rules. rule = input("\nDo you want to read the rules or continue without the rules? \npress y to learn the rules or x to continue without knowing the rules : ")#Asking for the input if rule == "y" or rule == "yes": #Use if function print("\nThe basic rules are as follows \n ...
true
c57799bb1ea76d52ec15085c90ede41dc76ea625
Punkrockechidna/PythonCourse
/advanced_python/functional_programming/map.py
294
4.125
4
# MAP # previous version # def multiply_by_2(li): # new_list = [] # for item in li: # new_list.append(items * 2) # return new_list # using map def multiply_by_2(item): return item * 2 print(list(map(multiply_by_2, [1, 2, 3]))) #not calling function, just running it
true
7c61b9cc81d4ae45d91866e38ec0051b045cdc00
khatriajay/pythonprograms
/in_out_list_.py
418
4.4375
4
#! /usr/bin/env python3 #Python3 program for checking if you have a pet with name entered. petname= ['rosie', 'jack', 'roxy', 'blossom'] #Define a list with pet names print (' Enter your pet name') name = input() if name not in petname: #Check if name exists in list print ('You dont hav...
true
0cc442ea2ed19f5130e5cdff5886b6dce22441c4
tayadehritik/NightShift
/fact.py
217
4.1875
4
args = int(input()) def factorial(num): fact = num for i in range(num-1,1,-1): fact = fact * i return fact for i in range(args): num = int(input()) fact = factorial(num) print(fact)
true
cd067c9c7ee918b908e31959d1e77d36dae5b36d
destrauxx/famped.github.io
/turtles.py
469
4.125
4
def is_palindrome(s): tmp = s[:] tmp.reverse() print(s, 'input list') print(tmp, 'reversed list') if tmp == s: return True else: return def word(n): result = [] for _ in range(n): element = input('Enter element: ') result.append(element...
true
42160b7b926a67cfea2f482584f39c38e11c4c17
ssenviel/Python_Projects-Udemy_zero_to_hero
/Generators_play.py
909
4.46875
4
""" problem 1: create a Generator that generates the squares of numbers up to some number 'N' problem 2: create a generator that yields "n" random number between a low and high number NOTE: use random.randrange or random.randint problem 3: use the iter() function to con...
true
bd160ff2bbf7bc2b6c004d39a51180a45c0e9a84
MarceloSaied/py
/python/helloworld/python1.py
485
4.15625
4
# print ("hello world") # counter = 100 # An integer assignment # miles = 1000.0 # A floating point # name = "John" # A string import datetime currentDate = datetime.date.today() currentDate=currentDate.strftime('%a %d %b %y') print(currentDate) # print (counter) # print (miles) # print (n...
true
c648e44b121c114f7fc4d4d28b83700720388604
jw3329/algorithm-implementation
/sort/selectionsort.py
600
4.1875
4
def swap(arr, i, j): temp = arr[i] arr[i] = arr[j] arr[j] = temp # find minimum element, and swap with its element from the start def selectionsort(arr): for i in range(len(arr)): min_index = i for j in range(i + 1, len(arr)): if arr[min_index] > arr[j]: min...
true
fbee41e0deb8a6a257f6a4a6977151eb79d273f0
akomawar/Python-codes
/Practise_Assignments/reverse.py
238
4.375
4
while 1: string=input("Eneter your string: ") reverse=string[::-1] print("Reverse order is : ",reverse) if(string==reverse): print('yes it is an palindrome') else: print('No it is not a palindrome')
true
01956a8f807fea39c05553178b47c9b4a81b73c8
MarkChuCarroll/pcomb
/python/calc.py
2,172
4.34375
4
# A simple example of using parser combinators to build an arithmetic # expression parser. from pcomb import * ## Actions def digits_to_number(digits, running=0): """Convert a list of digits to an integer""" if len(digits) == 0: return running else: r = (running * 10) + int(digits[0]) return digits...
true
7cfd67cc83713cec92f7ce1807bcaeed84028c0b
sprajwol/python_assignment_II
/assignment_Q11.py
863
4.71875
5
# # 11. Create a variable, filename. Assuming that it has a three-letter # # extension, and using slice operations, find the extension. For # # README.txt, the extension should be txt. Write code using slice # # operations that will give the name without the extension. Does your # # code work on filenames of arbitrary ...
true
487db65523fc0db80945c254b577d3a9a3cf7f61
sprajwol/python_assignment_II
/assignment_Q7.py
1,054
4.25
4
# 7. Create a list of tuples of first name, last name, and age for your # friends and colleagues. If you don't know the age, put in None. # Calculate the average age, skipping over any None values. Print out # each name, followed by old or young if they are above or below the # average age. import statistics list_of_da...
true
e53d462fc353654d6ebbc5e3b1ad3b654e135a75
korzair74/Homework
/Homework_4-20/family.py
235
4.34375
4
""" Create a variable called family Assign it a list of at least 3 names of family members as strings Loop through the list and print everyone's name """ family = ['Shea', 'Owen', 'Chris'] for name in family: print(name)
true
aebd73b4f15e97b86345ee31cd6e0df8e6e57b6d
matthpn2/Library-Database-Application
/backend_database.py
1,929
4.53125
5
import sqlite3 class Database: ''' SQLite database which can be viewed, searched, inserted, deleted, updated and closed upon. ''' def __init__(self, db): self.connection = sqlite3.connect(db) self.cursor = self.connection.cursor() self.cursor.execute("CREATE TABLE IF NOT EX...
true
4e5d7c36099415e09ff077fba1e06bc3262950dc
samhita-alla/flytesnacks
/cookbook/core/basic/task.py
2,089
4.15625
4
""" Tasks ------ This example shows how to write a task in flytekit python. Recap: In Flyte a task is a fundamental building block and an extension point. Flyte has multiple plugins for tasks, which can be either a backend-plugin or can be a simple extension that is available in flytekit. A task in flytekit can be 2 ...
true
5fe0ad7defc54cb146a4d187e0ec03c001da7b82
manrajpannu/ccc-solutions
/ccc-solutions/2014/Triangle.py
1,239
4.21875
4
# Triangle # Manraj Pannu # 593368 # ICS3U0A # 23 Oct 2018 firstAngle = int(input()) # input: the first angle of the triangle secondAngle = int(input()) # input: the second angle of the triangle thirdAngle = int(input()) # input: the third angle of the triangle totalAngle = (firstAngle + secondAngle + thi...
true
871d961154232ad57478058b1f58f6ca47c9f03f
JustinLaureano/python_projects
/python_practice/is_prime.py
563
4.3125
4
""" Define a function isPrime/is_prime() that takes one integer argument and returns true/True or false/False depending on if the integer is a prime. Per Wikipedia, a prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. """ def is_prime(num): if num ...
true
e84bee8c7f1151fde0a1d9be3c1bf96400ac5949
JustinLaureano/python_projects
/python_practice/max_subarray_sum.py
924
4.21875
4
""" The maximum sum subarray problem consists in finding the maximum sum of a contiguous subsequence in an array or list of integers: maxSequence([-2, 1, -3, 4, -1, 2, 1, -5, 4]) # should be 6: [4, -1, 2, 1] Easy case is when the list is made up of only positive numbers and the maximum sum is the sum of the whole arra...
true
dea1a14a5d21acab0295d8cf41cfc85deae87015
itspayaswini/PPA-Assignments
/exception.py
221
4.15625
4
numerator=int(input("enter the numerator ")) denominator=int(input("enter the denominator ")) try: result= (numerator/denominator) print(result) except ZeroDivisionError as error: print("Division by zero!")
true
5db2515b14384ef59c4dc2459305b3d4f0f91853
perfectgait/eopi
/python2/7.2-replace_and_remove/telex_encoding.py
1,401
4.25
4
""" Telex encode an array of characters by replacing punctuations with their spelled out value. """ __author__ = "Matt Rathbun" __email__ = "mrathbun80@gmail.com" __version__ = "1.0" def telex_encode(array): """ Telex encode an array of characters using the map of special characters """ special_strin...
true
2d9b2e241a24df7fa44ce2fd51be999d07a1d40e
Vangasse/NumPyTutorial
/NumPySortSearch.py
725
4.28125
4
# %% import numpy as np import matplotlib.pyplot as plt # %% How to get the indices of the sorted array using NumPy in Python? a = np.array([2, 4, 8, 6, 1, 9, 5, 3, 7]) print(np.argsort(a)) # %% Finding the k smallest values of a NumPy array a = np.array([2, 4, 8, 6, 1, 9, 5, 3, 7]) k = 3 print(np.sort(a)[:k]) # %% H...
true
c4d8a7398a895035637e2c36ca6c26f9a2fdf666
gmendiol-cisco/aer-python-game
/brehall_number-guessing-game.py
1,073
4.1875
4
#random number generator import random number=random.randint(1,100) #define variables. TOP_NUM=100 MAXGUESS=10 guesscount=0 #game rules print("Welcome to the Number Guessing Game...") print("I'm thinking of a number between 1 and", TOP_NUM,". You have", MAXGUESS,"chances to figure it out." ) #collect information ...
true
ac233558523fd4d10a3f327417816cf9aafcfa9c
kchaoui/me
/week2/exercise1.py
1,958
4.65625
5
""" Commenting skills: TODO: above every line of code comment what you THINK the line below does. TODO: execute that line and write what actually happened next to it. See example for first print statement """ import platform # I think this will print "hello! Let's get started" by calling the print function. print("h...
true
94101d0179b9826da4e12ed61fbb1f08cf93e7e5
sghosh1991/InterviewPrepPython
/LeetCodeProblemsEasy/543_Diameter_of_binary_tree.py
2,650
4.40625
4
''' Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. Example: Given a binary tree 1 / \ 2 3 / \ 4 ...
true
5ac54dd56d88f98d8a0877706ef05f53f0bcbec1
sghosh1991/InterviewPrepPython
/LeetCodeProblemsEasy/461_HammingDistance.py
1,254
4.15625
4
""" The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Hints: XOR followed by count set bits. Counting set bits can be done in many ways. Lookup table in O(1). Brutoforce O(n) Brian- Kerningha...
true
41df50dd1f20e926992b910468b7c44859377dfe
Aurales/DataStructuresHomework
/Data Structures/Lab 04/Lab04A_KyleMunoz.py
367
4.1875
4
#Kyle Munoz #Collatz Conjecture Recursively def CollatzConjecture(n, c = 0): if n == 1: print("Steps Taken: ",c) elif n % 2==0: return CollatzConjecture(n/2, c + 1) else: return CollatzConjecture(((n * 3) + 1), c + 1) def main(): x = int(input("What number would you like t...
true
736b387e21f6927a74aedffd1580eb89d92a4f06
feyfey27/python
/age_calculator.py
669
4.25
4
from datetime import datetime, date def check_birthdate(year, month, day): today = datetime.now() birthdate = datetime(year, month, day) if birthdate > today: return False else: return True def calculate_age(year,month,day): today = datetime.now() birthdate = datetime(year, month, day) age = today - birt...
true
84f9b09013e04222ed26dfc6af70fcc91dcf2324
aindrila2412/DSA-1
/Booking.com/power_set.py
1,609
4.1875
4
""" Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Example 2: Input: nums = [0] Output: [[],[0]] ...
true
b77cdbe352caec79714a00d9de8536ecb1bf15a6
aindrila2412/DSA-1
/Recursion/reverse_a_stack.py
1,350
4.25
4
""" Reverse a Stack in O(1) space using Recursion. Example 1 Input: st = [1, 5, 3, 2, 4] Output:[4, 2, 3, 5, 1] Explanation: After reversing the stack [1, 5, 3, 2, 4] becomes [4, 2, 3, 5, 1]. Example 2 Input: st = [5, 17, 100, 11] Output: [11, 100, 17, 5] Explanation: After reversing the stack [5, 17, 100, 11] becom...
true
391ce6e49583edf602e8dca5690384ca5e614bfe
aindrila2412/DSA-1
/Recursion/ways_to_climb_stairs.py
1,342
4.125
4
""" Given a staircase of n steps and a set of possible steps that we can climb at a time named possibleSteps, create a function that returns the number of ways a person can reach to the top of staircase. Example: Input: n = 10 possibleSteps = [2,4,5,8] Output: 11 Explanation: [2,2,...
true
03eaa82c091996233aece88866bdf83c04b43d0a
aindrila2412/DSA-1
/crackingTheCodingInterview/ArrayAndStrings/largest_number_at_least_twice_of_others.py
1,445
4.3125
4
""" You are given an integer array nums where the largest integer is unique. Determine whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, or return -1 otherwise. Example 1: Input: nums = [3,6,1,0] Output: 1 Expla...
true
9bb56f95c93a03afdd983e623f94dad18e526228
alicetientran/CodeWithTienAndHieu
/1-introduction/Task1-tien.py
914
4.3125
4
""" Task: Ask the user for a number Tell the user if the number is odd or even Hint: use % operator Extras: If the number is a multiple of 3, print "Third time's a charm" Ask the user for two numbers: one number to check (call it num) and one number to divide by (check). If {check} divides e...
true
b24e15f6714bd51c24148ecc514362f850623233
houtan1/Python_Data_Cleaner
/helloworld.py
888
4.25
4
# run with python helloworld.py # print("hello world") # tab delimited text dataset downloaded from https://doi.pangaea.de/10.1594/PANGAEA.885775 as Doering-etal_2018.tab # let's read in that data file = open("data/Doering-etal_2018.tab", "r") line = file.readlines() # print(line[28]) # print(len(line)) for x in rang...
true
adde8bcdf70592e681d642befa152e0737ffc754
marat-biriushev/PY4E
/py.py
2,071
4.21875
4
#!/usr/bin/python3 def f(x, y = 1): """ Returns x * y :param x: int first integer to be added. :param y: int second integer to be added (Not requared, 1 by default). :return : int multiplication of x and y. """ return x * y x = 5 #print(f(2)) #a = int(input('type a number')) #b = int(input(...
true
0f71e4012a72306a5c67cae91d404a2229d641c4
marat-biriushev/PY4E
/ex_7_1.py
2,122
4.625
5
#!/usr/bin/python3 ''' Exercise 1: Write a program to read through a file and print the contents of the file (line by line) all in upper case.''' fname = input('Enter a filename: ') fhand = open(fname) for line in fhand: line = line.upper() line = line.rstrip() print(line) #################################...
true
63d20821cc349256ae4929da0ef0a2691713a831
gchristofferson/credit.py
/credit.py
2,681
4.15625
4
from cs50 import get_int import math # prompt user for credit card # validate that we have a positive integer between 13 and 16 digits while True: ccNum = get_int('Enter Credit Card Number: ') if ccNum >= 0: break # reset value of ccNum copyCCNum = ccNum count = 0 # count the number of digits in the ...
true
72b76b4fdadfd01b0139c323b6412008fd70e90d
omi-akif/My_Codes
/Python/DataAnalysis/MIS401/Class Resource/1st Class/MIS401-Class 1.py
1,402
4.125
4
#!/usr/bin/env python # coding: utf-8 # In[12]: # In[17]: Name ='Kazi' #Assigning String Variable # In[56]: Age=28 #assigning variable # In[15]: Name #Printing varibale without using Print # In[16]: Age #Printing varibale without using Print # In[18]: Name # In[19]: print(Name) # In[21...
true
954959ab38ebc709a8f81657b636fcf5f6d3ede3
tiago-falves/FPRO-Python
/RE/Outros/min_path.py
1,790
4.15625
4
""" 5. Minimum path Write a function min_path(matrix, a, b, visited=[]) that discovers the minimum path between a and b inside the matrix maze without going through visited twice. Positions a and b are tuples (line, column), matrix is a matrix of booleans with False indicating no obstacle and True indicating an obstacl...
true
c0896304188088cb6bfa4644741f6ac469b07a28
absupriya/Applied-Algorithms
/1. Bubble sort/bubble_sort.py
2,273
4.375
4
#Reading the entire input file orig_file=open('input.txt','r').readlines() #Convert the input data from strings to integer data type orig_file = list(map(int, orig_file)) #Create an empty list to hold the average elapsed time and the number of inputs avg_elap_time_list=[] num_of_inputs_to_sort=[] #Setting up the arr...
true
77eeda8905113f1cbd1d2fe1e13685c814ebe662
denisefavila/python-playground
/src/linked_list/swap_nodes_in_pair.py
720
4.125
4
from typing import Optional from src.linked_list.node import Node def swap_pairs(head: Optional[Node]) -> Optional[Node]: """ Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselv...
true
45c1771c5a496bf65e92c07f5fcb8a6d5891f5f4
chuanski/py104
/LPTHW/2017-04-26-10-31-18.py
1,422
4.53125
5
# -*- coding: utf-8 -*- # [Learn Python the Hard Way](https://learnpythonthehardway.org/book) # [douban link](https://book.douban.com/subject/11941213/) # ex6.py Strings and Text x = "There are %d types of people." % 10 binary = "binary" do_not = "don't" y = "Those who know %s and those who %s." % (binary, do_not) yy ...
true
4504fdabb7ca47f4c3e20e13050b12971cadb240
BhagyeshDudhediya/PythonPrograms
/5-list.py
2,285
4.5625
5
#!/usr/bin/python3 import sys; # Lists are the most versatile of Python's compound data types. # A list contains items separated by commas and enclosed within square brackets ([]). # To some extent, lists are similar to arrays in C. # One of the differences between them is that all the items belonging to a list can b...
true
ed871e8bf632e9db119245d7b68af57af885343a
BhagyeshDudhediya/PythonPrograms
/2-quoted-strings.py
994
4.3125
4
#!/usr/bin/python # A program to demonstrate use of multiline statements, quoted string in python import sys; item_1 = 10; item_2 = 20; item_3 = 30; total_1 = item_1 + item_2 + item_3; # Following is valid as well: total_2 = item_1 + \ item_2 + \ item_3 + \ 10; print("total_1 is:", tot...
true
4df0cac6d76dda3a1af63e399d508cec7159e781
BhagyeshDudhediya/PythonPrograms
/18-loop-cntl-statements.py
2,145
4.53125
5
#!/usr/bin/python3 # The Loop control statements change the execution from its normal sequence. When the execution leaves a scope, # all automatic objects that were created in that scope are destroyed. # There are 3 loop control statements: # 1. break, 2. continue, 3. pass # BREAK STATEMENT # The break statement is ...
true
49da84798e3df53e56671287c625dc5d725e42f3
Niloy28/Python-programming-exercises
/Solutions/Q14.py
578
4.1875
4
# Write a program that accepts a sentence and calculate the number of upper case letters and lower case letters. # Suppose the following input is supplied to the program: # Hello world! # Then, the output should be: # UPPER CASE 1 # LOWER CASE 9 in_str = input() words = in_str.split() upper_letters = lower_...
true
345ce55214f53b15b5c95309c21ad414da483d78
Niloy28/Python-programming-exercises
/Solutions/Q24.py
528
4.125
4
# Python has many built-in functions, and if you do not know how to use it, you can read document online or find some books. But Python has a built-in document function for every built-in functions. # Please write a program to print some Python built-in functions documents, such as abs(), int(), raw_input() # And add...
true
da81d7c444c0465736cf3fc0e085db8fa8c607e1
Niloy28/Python-programming-exercises
/Solutions/Q22.py
692
4.40625
4
# Write a program to compute the frequency of the words from the input. The output should output after sorting the key alphanumerically. # Suppose the following input is supplied to the program: # New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python 3. # Then, the output should be: # 2:2...
true
b2ba0782b339b8a9d555378872260f0bae6852e6
Niloy28/Python-programming-exercises
/Solutions/Q53.py
603
4.3125
4
# Define a class named Shape and its subclass Square. The Square class has an init function which takes a length as argument. # Both classes have a area function which can print the area of the shape where Shape's area is 0 by default. class Shape(object): def __init__(self, length=0): pass d...
true
0870d3f73baba9157e9efc8e59cdf6bf630af41a
Niloy28/Python-programming-exercises
/Solutions/Q57.py
365
4.40625
4
# Assuming that we have some email addresses in the "username@companyname.com" format, please write program to print the user name of a given email address. # Both user names and company names are composed of letters only. import re email_id = input() pattern = r"([\w._]+)@([\w._]+)[.](com)" match = re.searc...
true
0b69e07cf5ee6963767afa0539a63c54292fda1d
olayinka91/PythonAssignments
/RunLenghtEncoding.py
848
4.34375
4
"""Given a string containing uppercase characters (A-Z), compress the string using Run Length encoding. Repetition of character has to be replaced by storing the length of that run. Write a python function which performs the run length encoding for a given String and returns the run length encoded String. Provide dif...
true
4f701b58fcf157bd5f96991e082a8b00a6bb220c
scottshepard/advent-of-code
/2015/day17/day17.py
1,869
4.125
4
# --- Day 17: No Such Thing as Too Much --- # # The elves bought too much eggnog again - 150 liters this time. To fit it all # into your refrigerator, you'll need to move it into smaller containers. # You take an inventory of the capacities of the available containers. # # For example, suppose you have containers of ...
true
e67363c2be2fc782679324cffb7afa0900c3b493
NovaStrikeexe/FtermLabs
/Massive.py
697
4.1875
4
import random n = 0 n = int(input("Enter the number of columns from 2 and more:")) if n < 2: print("The array must consist of at least two columns !") n = int(input("Enter the number of columns from 2 and more:")) else: m = [][] for i in range(0, n): for j in range(0, n): m...
true
b51ea3673b3366bc2bc8646a49888b13c2dca444
sanneabhilash/python_learning
/Concepts_with_examples/inbuild_methods_on_lists.py
350
4.25
4
my_list = [2, 1, 3, 6, 5, 4] print(my_list) my_list.append(7) my_list.append(8) my_list.append("HelloWorld") print(my_list) my_list.remove("HelloWorld") # sorting of mixed list throws error, so removing string my_list.sort() # The original object is modified print(my_list) # sort by default ascending my_list.sort...
true
db7b4af913e90310e154910ef8e11eb52269890b
sanneabhilash/python_learning
/Concepts_with_examples/listOperations.py
2,139
4.40625
4
# List is an ordered sequence of items. List is mutable # List once created can be modified. my_list = ["apples", "bananas", "oranges", "kiwis"] print("--------------") print(my_list) print("--------------") # accessing list using index print(my_list[0]) print(my_list[3]) # slicing list print(my_list[1:4]) print(my_...
true
01677a7c933fa163221e27a8bea963a35b8888be
oddsorevans/eveCalc
/main.py
2,991
4.34375
4
# get current day and find distance from give holiday (christmas) in this case from datetime import date import json #made a global to be used in functions holidayList = [] #finds the distance between 2 dates. Prints distance for testing def dateDistance(date, holiday): distance = abs(date - holiday).days pr...
true
70fec296d60c640fc3f7886ee624a2ca90a16799
pdeitel/PythonFundamentalsLiveLessons
/examples/ch02/snippets_py/02_06.py
1,577
4.15625
4
# Section 2.6 snippets name = input("What's your name? ") name print(name) name = input("What's your name? ") name print(name) # Function input Always Returns a String value1 = input('Enter first number: ') value2 = input('Enter second number: ') value1 + value2 # Getting an Integer from the User value = input...
true
4a9dddf948d68d000c1da8065c0d4762eba63a8c
lokesh-pathak/Python-Programs
/ex21.py
516
4.21875
4
# Write a function char_freq() that takes a string and builds a frequency listing of the characters contained in it. # Represent the frequency listing as a Python dictionary. # Try it with something like char_freq("abbabcbdbabdbdbabababcbcbab"). def char_freq(str): frequency = {} for n in str: key = frequency.ke...
true
0bdc8ceb19ab6e4f6f305bc33ca8682917661dff
lokesh-pathak/Python-Programs
/ex41.py
1,135
4.21875
4
# In a game of Lingo, there is a hidden word, five characters long. # The object of the game is to find this word by guessing, # and in return receive two kinds of clues: # 1) the characters that are fully correct, with respect to identity as well as to position, and # 2) the characters that are indeed present in the w...
true
8eafb237ab16ac14decc606b7ee80e4e82119196
lokesh-pathak/Python-Programs
/ex33.py
918
4.84375
5
# According to Wikipedia, a semordnilap is a word or phrase that spells a different word or phrase backwards. # ("Semordnilap" is itself "palindromes" spelled backwards.) # Write a semordnilap recogniser that accepts a file name # (pointing to a list of words) from the user and finds and prints # all pairs of words tha...
true
97d90fb94f6427ae1c13eba623ea4e9ce7665670
lokesh-pathak/Python-Programs
/ex1.py
269
4.28125
4
# Define a function max() that takes two numbers as arguments and returns the largest of them. # Use the if-then-else construct available in Python. def max(num1, num2): if num1 > num2: return num1 else: return num2 #test print max(3, 5) print max(10, 6)
true
d242694b3d8ac4b4a5ed9c01c00269ee4c6dca2d
GanLay20/The-Python-Workbook-1
/pyworkbookex003.py
226
4.125
4
print("The area calculator") lenth = float(input("Enter The Lenth In Feet >>> ")) width = float(input("Enter The Width In Feet >>> ")) print(lenth) print(width) area = lenth * width print("The Area Is: ", area, " Square Feet")
true
87e9c3980f14dde7910ba0314d7dd24427849ba2
GanLay20/The-Python-Workbook-1
/pyworkbookex014.py
381
4.3125
4
print("Enter you height in FEET followed by INCHES") feet_height = int(input("Feet:\n>>> ")) inch_height = int(input("Inches:\n>>> ")) print("Your height is", feet_height, "feet", inch_height, "inches\n") # 1 inch = 2.54cm // 1 foot = 30.48 feet_cm = feet_height * 30.48 inch_cm = inch_height * 2.54 total_height = f...
true
276158e1754954c9cb1017c535d83bdaaff28867
Iboatwright/mod9homework
/sum_of_numbers.py
1,750
4.53125
5
# sum_of_numbers.py # Exercise selected: Chapter 10 program 3 # Name of program: Sum of Numbers # Description of program: This program opens a file named numbers.dat # that contains a list of integers and calculates the sum of all the # integers. The numbers.dat file is assumed to be a string of positive # integ...
true
c292b92e7d84623749c1c4c704cbfa33f0b01017
Roman-Rogers/Wanclouds
/Task - 2.py
522
4.34375
4
names = ['ali Siddiqui', 'hamza Siddiqui', 'hammad ali siDDiqui','ghaffar', 'siddiqui ali', 'Muhammad Siddique ahmed', 'Ahmed Siddiqui'] count = 0 for name in names: # Go through the List lowercase=name.lower() # Lower Case the string so that it can be used easily splitname=lowercase.split() # Split the nam...
true
ff2ae3318ec47aefe5035cf1ee4f7ea92bcc3291
Jay168/ECS-project
/swap.py
306
4.125
4
#swapping variables without using temporary variables def swapping(x,y): x=x+y y=x-y x=x-y return x,y a=input("input the first number A:\n") b=input("input the second number B:\n") a,b=swapping(a,b) print "The value of A after swapping is:",a print "The value of B after swapping is:",b
true
1a233003afdf53e979e155a2c8122012183de4c5
anurag3753/courses
/david_course/Lesson-03/file_processing_v2.py
850
4.3125
4
"""In this new version, we have used the with statement, as with stmt automatically takes care of closing the file once we are done with the file. """ filename = "StudentsPerformance.csv" def read_file_at_once(filename): """This function reads the complete file in a single go and put it into a text string ...
true
ca9f27843c8dd606097931adad722688d36d060a
pankajiitg/EE524
/Assignment1/KManivas_204102304/Q09.py
676
4.40625
4
## Program to multiply two matrices import numpy as np print("Enter the values of m, n & p for the matrices M1(mxn) and M2(nxp) and click enter after entering each element:") m = int(input()) n = int(input()) p = int(input()) M1 = np.random.randint(1,5,(m,n)) M2 = np.random.randint(1,5,(n,p)) M = np.zeros((m,p),dtyp...
true
50e26426d5913ff0252d1e05fd3d4a26afd04ed1
pankajiitg/EE524
/Assignment1/KManivas_204102304/Q03.py
294
4.46875
4
##Program to print factorial of a given Number def factorial(num): fact = 1 for i in range(1,num+1): fact = fact * i return fact print("Enter a number to calculate factorial:") num1 = int(input()) print("The factorial of ", num1, "is ", factorial(num1))
true
a1e0a66a58a5e0d96ddbd2a07424b9b313912a23
nova-script/Py-Check-IO
/01_Elementary/08.py
1,247
4.46875
4
""" # Remove All Before ## Not all of the elements are important. ## What you need to do here is to remove from the list all of the elements before the given one. ## For the illustration we have a list [1, 2, 3, 4, 5] and we need to remove all elements ## that go before 3 - which is 1 and 2. #...
true
0f882f1f2a162f6fac61d29a40ae0a44b7c6b771
Tarunmadhav/Python1
/GuessingGame.py
419
4.25
4
import random number=random.randint(1,9) chances=0 print("Guess A Number Between 1-9") while chances<5: guess=int(input("Guess A Number 1-9")) if(guess==number): print("Congratulations") break elif(guess<number): print("Guess Higher Number") else: print("Gue...
true
3c3182c02d122f69bc1aecb800ceb778ccaa6968
sr-murthy/inttools
/arithmetic/combinatorics.py
1,277
4.15625
4
from .digits import generalised_product def factorial(n): return generalised_product(range(1, n + 1)) def multinomial(n, *ks): """ Returns the multinomial coefficient ``(n; k_1, k_2, ... k_m)``, where ``k_1, k_2, ..., k_m`` are non-negative integers such that :: k_1 + k_2 + ... + k_m = ...
true
4e39eb65f44e423d9695653291c6c15b95920df2
rocket7/python
/S8_udemy_Sets.py
695
4.1875
4
############### # SETS - UNORDERED AND CONTAINS NO DUPLICATES ############### # MUST BE IMMUTABLE # CAN USE UNION AND INTERSECTION OPERATIONS # CAN BE USED TO CLEAN UP DATA animals = {"dog", "cat", "lion", "elephant", "tiger", "kangaroo"} print(animals) birds = set(["eagle", "falcon", "pigeon", "bluejay", "flaming...
true
dcd02ef61c6b2003024857d5132f8f4d8cf72e01
venkat284eee/DS-with-ML-Ineuron-Assignments
/Python_Assignment2.py
605
4.46875
4
#!/usr/bin/env python # coding: utf-8 # # Question 1: # Create the below pattern using nested for loop in Python. # * # * * # * * * # * * * * # * * * * * # * * * * # * * * # * * # * # In[1]: n=5; for i in range(n): for j in range(i): print ('* ', end="") print('') for i in range(n,0,-1): for j ...
true
faffa16c4ee560cb5fdb32013893bbf83e947ba1
mrparkonline/py_basics
/solutions/basics1/circle.py
300
4.46875
4
# Area of a Circle import math # input radius = float(input('Enter the radius of your circle: ')) # processing area = math.pi * (radius ** 2) circumference = 2 * math.pi * radius # output print('The circle area is:', area, 'units squared.') print('The circumference is:', circumference, 'units.')
true