blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
0f12c136eb165f73e16dbc9d3c73d647ac6aa708 | hamzai7/pythonReview | /nameLetterCount.py | 302 | 4.25 | 4 | # This program asks for your name and returns the length
print("Hello! Please enter your name: ")
userName = input()
print("Hi " + userName + ", it is nice to meet you!")
def count_name():
count = str(len(userName))
return count
print("Your name has " + count_name() + " letters in it!")
| true |
3a55237ee2f95f66677b00a341d0b5f3585bb3d3 | rayramsay/hackbright-2016 | /01 calc1/arithmetic.py | 922 | 4.28125 | 4 | def add(num1, num2):
""" Return the sum """
answer = num1 + num2
return answer
def subtract(num1, num2):
""" Return the difference """
answer = num1 - num2
return answer
def multiply(num1, num2):
""" Return the result of multiplication """
answer = num1 * num2
return answer
def... | true |
43ff1d9bd4e3b0236126c9f138da52c3edd87064 | Jordonguy/PythonTests | /Warhammer40k8th/Concept/DiceRollingAppv2.py | 1,716 | 4.59375 | 5 | # An small application that allows the user to select a number of 6 sided dice and roll them
import random
quit = False
dice_rolled = 0
results = []
while(quit == False):
# Taking User Input
dice_rolled = dice_rolled
dice_size = int(input("Enter the size of the dice you : "))
dice_num = int(input("Ente... | true |
90ff8bcc34a2e380db6f0b71dd113e83dd764c46 | EricksonGC2058/all-projects | /todolist.py | 704 | 4.15625 | 4 | print("Welcome to the To Do List! (:")
todolist = []
while True:
print("Enter 'a' to add an item")
print("Enter 'r' to remove an item")
print("Enter 'p' to print the list")
print("Enter 'q' to quit")
choice = input("Make your choice: ")
if choice == "q":
break
elif choice == "a":
todoitems = inp... | true |
9dd4a8bea6d079f6bd3883fe53949bfbb1d58f1b | AndreasWJ/Plot-2d | /curve.py | 2,638 | 4.3125 | 4 | class Curve:
def __init__(self, curve_function, color, width):
self.curve_function = curve_function
self.color = color
self.width = width
def get_pointlist(self, x_interval, precision=1):
'''
The point precision works by multiplying the start and end of the interval. By ... | true |
4c1922842c2bb7027d6c1f77f5d11bb4d1250a1a | keeyong/state_capital | /learn_dict.py | 906 | 4.4375 | 4 | # two different types of dictionary usage
#
# Let's use first name and last name as an example
# 1st approach is to use "first name" and "last name" as separate keys. this approach is preferred
# 2nd approach is to use first name value as key and last name as value
# ---- 1st apprach
name_1 = { 'firstname': 'keeyong'... | true |
877fe8b28feadb49c4b071d9d1e26a3796f466cc | scresante/codeeval | /crackFreq.py2 | 1,676 | 4.21875 | 4 | #!/usr/bin/python
from sys import argv
try:
FILE = argv[1]
except NameError:
FILE = 'tests/121'
DATA = open(FILE, 'r').read().splitlines()
for line in DATA:
if not line:
continue
print line
inputText = line
#inputText = str(raw_input("Please enter the cipher text to be analysed:")).replace(" ", "... | true |
f0b5f940a37acd4ac16a5ab76b9331b57dec7c57 | kxhsing/dicts-word-count | /wordcount.py | 1,258 | 4.28125 | 4 | # put your code here.
#putting it all in one function
#will figure out if they can be broken later
def get_word_list(file_name):
"""Separates words and creates master list of all the words
Given a file of text, iterates through that file and puts all
the words into a list.
"""
#empty list to ho... | true |
93df2764f6fdcfb101521820aa3be80562e1bc47 | ottoguz/My-studies-in-Python | /aula005s.py | 816 | 4.125 | 4 | #Function that receives an integer via keyboard and determines the range(which should comprehend positive numbers)
def valid_int(question, min, max):
x = int(input(question))
if ((x < min) or (x > max)):
x = int(input(question))
return x
#Function to calculate the factorial of a given number... | true |
5b928f4d9cfdd6bb4bcbca0500ffbdd6ac40c2c5 | NinjaCodes119/PythonBasics | /basics.py | 915 | 4.125 | 4 | student_grades = [9, 8, 7 ] #List Example
mySum = sum(student_grades)
length = len(student_grades)
mean = mySum / length
print("Average=",mean)
max_value = max(student_grades)
print("Max Value=",max_value)
print(student_grades.count(8))
#capitalize letter
text1 = "This Text should be in capital"
print(text1.upper())... | true |
0b1281fa76e4379219ec2637d53c94412547b52b | jemcghee3/ThinkPython | /05_14_exercise_2.py | 970 | 4.375 | 4 | """Exercise 2
Fermat’s Last Theorem says that there are no positive integers a, b, and c such that
an + bn = cn
for any values of n greater than 2.
Write a function named check_fermat that takes four parameters—a, b, c and n—and checks to see if Fermat’s theorem holds. If n is greater than 2 and
an + bn = cn... | true |
32ebb0dcbf831f71f2e24e72f38fdb3cb7af8fc1 | jemcghee3/ThinkPython | /05_14_exercise_1.py | 792 | 4.25 | 4 | """Exercise 1
The time module provides a function, also named time, that returns the current Greenwich Mean Time in “the epoch”, which is an arbitrary time used as a reference point. On UNIX systems, the epoch is 1 January 1970.
Write a script that reads the current time and converts it to a time of day in hours, mi... | true |
4beaf5482d4fe8a76d30bb5548ae33192d33f19b | jemcghee3/ThinkPython | /09_02_exercise_4.py | 672 | 4.125 | 4 | """Exercise 4
Write a function named uses_only that takes a word and a string of letters,
and that returns True if the word contains only letters in the list.
Can you make a sentence using only the letters acefhlo? Other than “Hoe alfalfa”?"""
def letter_checker(c, letters):
for l in letters:
if c == l:
... | true |
fa53edb7fa96c64310f584cd9d7af86b0cc9ec24 | jemcghee3/ThinkPython | /08_03_exercise_1.py | 255 | 4.25 | 4 | """As an exercise, write a function that takes a string as an argument and displays the letters backward,
one per line."""
def reverse(string):
l = len(string)
i = -1
while abs(i) <= l:
print(string[i])
i -= 1
reverse('test') | true |
2e55f9920fcf976b3027a7abf4bc175752fe2ec1 | jemcghee3/ThinkPython | /10_15_exercise_02.py | 682 | 4.28125 | 4 | """Exercise 2
Write a function called cumsum that takes a list of numbers and returns the cumulative sum;
that is, a new list where the ith element is the sum of the first i+1 elements from the original list. For example:
>>t = [1, 2, 3]
>>cumsum(t)
[1, 3, 6]
"""
def sum_so_far(input_list, n): # n is the number of i... | true |
7d832e6a251f1d4a1abd229eb3ea409f76f2f164 | jemcghee3/ThinkPython | /08_13_exercise_5.py | 2,356 | 4.1875 | 4 | """Exercise 5
A Caesar cypher is a weak form of encryption that involves “rotating” each letter by a fixed number of places.
To rotate a letter means to shift it through the alphabet, wrapping around to the beginning if necessary,
so ’A’ rotated by 3 is ’D’ and ’Z’ rotated by 1 is ’A’.
To rotate a word, rotate each l... | true |
17df7ec92955ee72078b556e124938f1531f298a | jemcghee3/ThinkPython | /11_10_exercise_03.py | 1,535 | 4.5 | 4 | """Exercise 3 Memoize the Ackermann function from Exercise 2
and see if memoization makes it possible to evaluate the function with bigger arguments.
Hint: no. Solution: http://thinkpython2.com/code/ackermann_memo.py.
The Ackermann function, A(m, n), is defined:
A(m, n) =
n+1 if m = 0
A(m−1,... | true |
7e90113bc6bd97d3d3728d2527698e0e26b159a2 | shiva111993/python_exercises | /set_code.py | 2,213 | 4.1875 | 4 | # Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
# myset = {"apple", "ball", "cat", "dag", "elephate"}
# print(myset)
# myset.add("fan")
# print(myset)
# myset.add("apple")
# print(myset)
# ---------removing
# myset.remove("ball")
# print(mys... | true |
6c463adbd86c53f3a17f58f960d6932134f29783 | emaustin/Change-Calculator | /Change-Calculator.py | 2,259 | 4.125 | 4 | def totalpaid(cost,paid):
#Checking to ensure that the values entered are numerical. Converts them to float numbers if so.
try:
cost = float(cost)
paid = float(paid)
#check to ensure the amount paid is greater than the cost
except:
print("Please enter in a number value... | true |
cd736e4f096527ed9a012f7cb8e44b0c93f9d4df | eNobreg/holbertonschool-interview | /0x19-making_change/0-making_change.py | 523 | 4.40625 | 4 | #!/usr/bin/python3
"""
Module for making change function
"""
def makeChange(coins, total):
"""
Making change function
coins: List of coin values
total: Total coins to meet
Return: The lowest amount of coins to make total
or -1
"""
count = 0
if total <= 0:
return 0
coi... | true |
b9b329934dc1865548940c95d89b3d6a1052f4a5 | nikithapk/coding-tasks-masec | /fear-of-luck.py | 423 | 4.34375 | 4 | import datetime
def has_saturday_eight(month, year):
"""Function to check if 8th day of a given month and year is Friday
Args:
month: int, month number
year: int, year
Returns: Boolean
"""
return True if datetime.date(year, month, 8).weekday() == 5 else False
# Test cases
prin... | true |
58cdadc4d72f1a81b55e16f0a4067b44ae937f37 | rcolistete/Plots_MicroPython_Microbit | /plot_bars.py | 609 | 4.125 | 4 | # Show up to 5 vertical bars from left to right using the components of a vector (list or tuple)
# Each vertical bar starts from bottom of display
# Each component of the vector should be >= 0, pixelscale is the value of each pixel with 1 as default value.
# E. g., vector = (1,2,3,4,5) will show 5 verticals bars, with ... | true |
d8301e71e2d210a4303273f2f875514bd4a6aff0 | mansi05041/Computer_system_architecture | /decimal_to_any_radix.py | 910 | 4.15625 | 4 | #function of converting 10 to any radix
def decimal_convert_radix(num,b):
temp=[]
while (num!=0):
rem=num%b
num=num//b
temp.append(rem)
result=temp[::-1]
return result
def main():
num=int(input("Enter the decimal number:"))
radix=int(input("enter the base to be... | true |
0a6ce06157bd0fb4e30e2c98a8327f5b98f14682 | zija1504/100daysofCode | /5.0 rock paper scissors/game.py | 2,843 | 4.3125 | 4 | #!/usr/bin/python3
# Text Game rock, paper, scissors to understand classes
import random
class Player:
"""name of player"""
def __init__(self, name):
self.name = name
self.pkts = 0
def player_battle(self, pkt):
self.pkts += pkt
class Roll:
"""rolls in game"""
def __ini... | true |
f524472f1125b5d55bd1af74de6c5e0ba81c9f54 | hiteshkrypton/Python-Programs | /sakshi1.py | 310 | 4.25 | 4 |
def factorial(n):
if n == 1:
return n
else:
return n * factorial(n - 1)
n = int(input("Enter a Number: "))
if n < 0:
print("Factorial cannot be found for negative numbers")
elif n == 0:
print("Factorial of 0 is 1")
else:
print("Factorial of", n, "is: ", factorial(n))
| true |
dfb693bb8093a5f86513a6cd0b565d5c1d0c2809 | sachinsaurabh04/pythonpract | /Function/function1.py | 544 | 4.15625 | 4 | #!/usr/bin/python3
# Function definition is here
def printme( str ):
#"This prints a passed string into this function"
print (str)
return
# Now you can call printme function
printme("This is first call to the user defined function!")
printme("Again second call to the same function")
printme("hello sachin, t... | true |
70b59046590e09cf64be5d6c6d210893ab3d7bfc | sachinsaurabh04/pythonpract | /Function/funtion7.py | 1,115 | 4.3125 | 4 | #keyword Argument
#This allows you to skip arguments or place them out of order because the Python
#interpreter is able to use the keywords provided to match the values with parameters. You
#can also make keyword calls to the printme() function in the following ways-
#Order of the parameters does not matter
#!/usr/bin... | true |
1ced156b8bad36c94f49d1c51483611eba47754d | Deepomatic/challenge | /ai.py | 2,709 | 4.125 | 4 | import random
def allowed_moves(board, color):
"""
This is the first function you need to implement.
Arguments:
- board: The content of the board, represented as a list of strings.
The length of strings are the same as the length of the list,
which represe... | true |
5e1e2e536787176e984cd8c7ad63169371361fb9 | anokhramesh/Calculate-Area-Diameter-and-Circumference | /calculate_area_diametre_Circumference_of_a_circle.py | 466 | 4.5625 | 5 | print("A program for calculate the Area,Diameter and Circumference of a circle if Radius is known")
print("******************************************************************************************")
while True:
pi = 3.14
r = float(input("\nEnter the Radius\n"))
a = float(pi*r)*r
d = (2*r)
c ... | true |
b0f171588a69286bc1aaba953e45b712a23ffb66 | ggrossvi/core-problem-set-recursion | /part-1.py | 1,130 | 4.3125 | 4 | # There are comments with the names of
# the required functions to build.
# Please paste your solution underneath
# the appropriate comment.
# factorial
def factorial(num):
# base case
if num < 0:
raise ValueError("num is less than 0")
elif num == 0:
# print("num is 0")
return 1
... | true |
1be9a89c5edc52c684a62dcefcdd417a418ef797 | aayishaa/aayisha | /factorialss.py | 213 | 4.1875 | 4 |
no=int(input())
factorial = 1
if no < 0:
print("Factorrial does not exist for negative numbers")
elif no== 0:
print("1")
else:
for i in range(1,no+ 1):
factorial = factorial*i
print(factorial)
| true |
557db6014ade0a2fc318b675bdc3fbf6aa9b3d30 | JonasJR/zacco | /task-1.py | 311 | 4.15625 | 4 | str = "Hello, My name is Jonas"
def reverseString(word):
#Lets try this without using the easy methods like
#word[::-1]
#"".join(reversed(word))
reversed = []
i = len(word)
while i:
i -= 1
reversed.append(word[i])
return "".join(reversed)
print reverseString(str)
| true |
e1cdeb27240a29c721298c5e69193576da556861 | brunacorreia/100-days-of-python | /Day 1/finalproject-band-generator.py | 565 | 4.5 | 4 | # Concatenating variables and strings to create a Band Name
#1. Create a greeting for your program.
name = input("Hello, welcome to the Band Generator! Please, inform us your name.\n")
#2. Ask the user for the city that they grew up in.
city = input("Nice to meet you, " + name + "! Now please, tell us the city you gr... | true |
557e4d43a305b7ddcfe16e6151d7523468417278 | axxypatel/Project_Euler | /stack_implementation_using_python_list.py | 1,550 | 4.4375 | 4 | # Implement stack data structure using list collection of python language
class Stack:
def __init__(self):
self.item_list = []
def push(self, item):
self.item_list.append(item)
def pop(self):
self.item_list.pop()
def isempty(self):
return self.item_list == []
de... | true |
20bdc091aa5936ed6cfbcec4f285e9337f6040c2 | arkharman12/oop_rectangle | /ooprectangle.py | 2,518 | 4.34375 | 4 | class Size(object): #creating a class name Size and extending it from object
def __init__(self, width=0, height=0): #basically it inherts whatever is defined in object
self.__width = width #object is more than an simple argument
self.__... | true |
6ba40eec4a91f64bb1675e456566f2018de3c835 | f73162818/270201070 | /lab7/ex2.py | 322 | 4.125 | 4 | def is_prime(a):
if a <= 1:
return False
for i in range(2,a):
if a%i == 0:
return False
return True
def print_primes_between(a,b):
for i in range(a,b):
if is_prime(i):
print(i)
a = int(input("Enter a number:"))
b = int(input("Enter another number:"))
print_primes_between(a,b)
... | true |
b68fa443c48907700332320459f7583e1d288f8a | Ealtunlu/GlobalAIHubPythonCourse | /Homeworks/day_5.py | 1,358 | 4.3125 | 4 | # Create three classes named Animals, Dogs and Cats Add some features to these
# classes Create some functions with these attributes. Don't forget! You have to do it using inheritance.
class Animal:
def __init__(self,name,age):
self.name = name
self.age = age
def is_mammel(self):
... | true |
b5fd6cb27a327d0cede09f3eb7dbf5d6569cc63d | roselandroche/cs-module-project-recursive-sorting | /src/sorting/sorting.py | 1,182 | 4.28125 | 4 | # TO-DO: complete the helper function below to merge 2 sorted arrays
def merge(arrA, arrB):
# Your code here
merged_arr = []
x = y = 0
while x < len(arrA) and y < len(arrB):
if arrA[x] < arrB[y]:
merged_arr.append(arrA[x])
x += 1
else:
merged_arr.appe... | true |
4a8c2ad2eafe2cefe78c0ccd5750f097671c7075 | GermanSumus/Algorithms | /unique_lists.py | 651 | 4.3125 | 4 | """
Write a function that takes two or more arrays and returns a new array of
unique values in the order of the original provided arrays.
In other words, all values present from all arrays should be included in their
original order, but with no duplicates in the final array.
The unique numbers should be sorted by the... | true |
b7ac1cfbb9087510ade29a2d2605b8cc01345d1f | GermanSumus/Algorithms | /factorialize.py | 268 | 4.21875 | 4 | # Return the factorial of the provided integer
# Example: 5 returns 1 * 2 * 3 * 4 * 5 = 120
def factorialize(num):
factor = 1
for x in range(1, num + 1):
factor = factor * x
print(factor)
factorialize(5)
factorialize(10)
factorialize(25)
| true |
8f076f012de7d9e71daff7736fc562eff99078aa | kartikay89/Python-Coding_challenges | /countLetter.py | 1,042 | 4.5 | 4 | """
Write a function called count_letters(text, letter), which receives as arguments a text (string) and
a letter (string), and returns the number of occurrences of the given letter (count both capital and
small letters!) in the given string. For example, count_letters('trAvelingprogrammer', 'a') should return 2
an... | true |
7c54349a4f78cefb44bff8616fc370b865849d48 | kartikay89/Python-Coding_challenges | /phoneNum.py | 1,223 | 4.53125 | 5 | """
Imagine you met a very good looking guy/girl and managed to get his/her phone number. The phone number has 9 digits but, unfortunately, one of the digits is missing since you were very nervous while writing it down.
The only thing you remember is that the SUM of all 9 digits was divisible by 10 - your crush was ne... | true |
c3bd11215bb589aa0940cf92e249d2dd8815b8e8 | ravenawk/pcc_exercises | /chapter_07/deli.py | 413 | 4.28125 | 4 | #!/usr/bin/env python3
'''
Making sandwiches with while loops and for loops
'''
sandwich_orders = ['turkey', 'tuna', 'ham']
finished_sandwiches = []
while sandwich_orders:
current_sandwich = sandwich_orders.pop()
finished_sandwiches.append(current_sandwich)
print(f"I made your {current_sandwich} sandwich.... | true |
b0ee2dc3c3865353f42b2b18c45e0a8b77c7c7bc | ravenawk/pcc_exercises | /chapter_04/slices.py | 326 | 4.25 | 4 | #!/usr/bin/env python3
list_of_cubes = [ value**3 for value in range(1,11)]
for cube in list_of_cubes:
print(cube)
print(f"The first 3 items in the list are {list_of_cubes[:3]}.")
print(f"Three items in the middle of the list are {list_of_cubes[3:6]}.")
print(f"The last 3 items in the list are {list_of_cubes[-3:... | true |
f87fbc9f1ad08e89dd1fd5e561bf0956f01b2a6e | ravenawk/pcc_exercises | /chapter_07/dream_vacation.py | 381 | 4.21875 | 4 | #!/usr/bin/env python3
'''
Polling for a dream vacation
'''
places_to_visit = []
poll = input("Where would you like to visit some day? ")
while poll != 'quit':
places_to_visit.append(poll)
poll = input("Where would you like to visit one day? (Enter quit to end) ")
for place in places_to_visit:
print(f"{p... | true |
b102953b0aaef366c4056dfb9b94210c416b7512 | ravenawk/pcc_exercises | /chapter_08/user_albums.py | 514 | 4.34375 | 4 | #!/usr/bin/env python3
'''
Function example of record album
'''
def make_album(artist_name, album_title, song_count=None):
''' Create album information '''
album = {'artist': artist_name, 'album name': album_title,}
if song_count:
album['number of songs'] = song_count
return album
while True:
... | true |
12c1a2d3672a7f0c7d391e958e8a047ff3893106 | joesprogramming/School-and-Practice | /Calculate Factorial of a Number CH 4 pgm 10.py | 281 | 4.25 | 4 | # Joe Joseph
# intro to programming
# Ask user for a number
fact = int(input('Enter a number and this program will calculates its Factorial: ',))
# define formula
num = 1
t = 1
#run loop
while t <= fact:
num = num * t
t = t + 1
print(num)
| true |
6a159a65ea848c61eb4b35980b2bd524a5487b56 | BzhangURU/LeetCode-Python-Solutions | /T522_Longest_Uncommon_Subsequence_II.py | 2,209 | 4.125 | 4 | ##Given a list of strings, you need to find the longest uncommon subsequence among them. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other strings.
##
##A subsequence is a sequence that can be derived from one s... | true |
79d8085cb879c116c4092396ecc83fa1b7f2b5d2 | SanaaShah/Python-Mini-Assignments | /6__VolumeOfSphere.py | 290 | 4.5625 | 5 | # 6. Write a Python program to get the volume of a sphere, please take the radius as input from user. V=4 / 3 πr3
from math import pi
radius = input('Please enter the radius: ')
volume = 4 / (4 * pi * 3 * radius**3)
print('Volume of the sphere is found to be: '+str(round(volume, 2)))
| true |
4ac590cb424a5d27fc41ccfe671b7c42db027139 | SanaaShah/Python-Mini-Assignments | /30__OccurenceOfLetter.py | 331 | 4.21875 | 4 | # 30. Write a Python program to count the number occurrence of a specific character in a string
string = input('Enter any word: ')
word = input('Enter the character that you want to count in that word: ')
lenght = len(string)
count = 0
for i in range(lenght):
if string[i] == word:
count = count + 1
p... | true |
53577eb885ed53f2ba4c0d09fa7a0262ff6fdb2f | SanaaShah/Python-Mini-Assignments | /2__checkPositive_negative.py | 350 | 4.4375 | 4 | # 2. Write a Python program to check if a number is positive, negative or zero
user_input = float(input('Please enter any number: '))
if user_input < 0:
print('Entered number is negative.')
elif user_input > 0:
print('Entered number is positive')
elif user_input == 0:
print('You have entered zero, its ne... | true |
f81383ec7b0b8be08c8c40ec057866c6b4383879 | SanaaShah/Python-Mini-Assignments | /1__RadiusOfCircle.py | 299 | 4.53125 | 5 | # 1. Write a Python program which accepts the radius of a circle from the user and compute the area
from math import pi
radius = float((input('Please enter the radius of the cricle: ')))
print('Area of the circle of radius: '+str(radius) + ' is found to be: '+str(round((pi * radius**2), 2)))
| true |
06827bf14302ec76a9b9d64a66273db96e3746fa | duplys/duplys.github.io | /_src/recursion/is_even.py | 557 | 4.59375 | 5 | """Example for recursion."""
def is_even(n, even):
"""Uses recursion to compute whether the given number n is even.
To determine whether a positive whole number is even or odd,
the following can be used:
* Zero is even
* One is odd
* For any other number n, its evenness is the same as n-2
... | true |
c3a181aea806b68ce09197560eeb485ca6d8419d | jamesb97/CS4720FinalProject | /FinalProject/open_weather.py | 1,535 | 4.25 | 4 | '''
Python script which gets the current weather data for a particular zip code
and prints out some data in the table.
REST API get weather data which returns the Name, Current Temperature,
Atmospheric Pressure, Wind Speed, Wind Direction, Time of Report.
'''
import requests
#Enter the corresponding api key from... | true |
18200cb8e9e584fe454d57f3436a9184159388b8 | ayoubabounakif/edX-Python | /ifelifelse_test1_celsius_to_fahrenheit.py | 811 | 4.40625 | 4 | #Write a program to:
#Get an input temperature in Celsius
#Convert it to Fahrenheit
#Print the temperature in Fahrenheit
#If it is below 32 degrees print "It is freezing"
#If it is between 32 and 50 degrees print "It is chilly"
#If it is between 50 and 90 degrees print " It is OK"
#If it is above 90 degrees prin... | true |
b9804e7911242e9c4eae1074e8ef2949155d60e0 | ayoubabounakif/edX-Python | /sorting.py | 515 | 4.125 | 4 | # Lets sort the following list by the first item in each sub-list.
my_list = [[2, 4], [0, 13], [11, 14], [-14, 12], [100, 3]]
# First, we need to define a function that specifies what we would like our items sorted by
def my_key(item):
return item[0] # Make the first item... | true |
f3019b4227dfd2a758d0585fb1c2f9e27df1b8e9 | ayoubabounakif/edX-Python | /quizz_1.py | 275 | 4.28125 | 4 | #a program that asks the user for an integer 'x'
#and prints the value of y after evaluating the following expression:
#y = x^2 - 12x + 11
import math
ask_user = input("Please enter an integer x:")
x = int(ask_user)
y = math.pow(x,2) - 12*x + 11
print(int(y))
| true |
7013c99a792f116a7b79f4ad1a60bfb3f4b1a8a2 | ayoubabounakif/edX-Python | /quizz_2_program4.py | 1,141 | 4.34375 | 4 | #Write a program that asks the user to enter a positive integer n.
#Assuming that this integer is in seconds,
#your program should convert the number of seconds into days, hours, minutes, and seconds
#and prints them exactly in the format specified below.
#Here are a few sample runs of what your program is suppos... | true |
940e284ec16e99a3349d00e0611e487cdce976f1 | ayoubabounakif/edX-Python | /quizz_3_part3.py | 397 | 4.1875 | 4 | # Function that returns the sum of all the odd numbers in a list given.
# If there are no odd numbers in the list, your function should return 0 as the sum.
# CODE
def sumOfOddNumbers(numbers_list):
total = 0
count = 0
for number in numbers_list:
if (number % 2 == 1):
total += ... | true |
9774dac844cb3985d733af0c87e697b85f93be88 | ayoubabounakif/edX-Python | /for_loop_ex2.py | 296 | 4.3125 | 4 | #program which asks the user to type an integer n
#and then prints the sum of all numbers from 1 to n (including both 1 and n).
# CODE
ask_user = input("Type an integer n:")
n = int(ask_user)
i = 1
sum = 0
for i in range(1, n+1):
sum = sum + i
print (sum)
| true |
69b29ccaa611a0e92df5f8cd9b3c59c231847b72 | fingerman/python_fundamentals | /python-fundamentals/4.1_dict_key_value.py | 1,032 | 4.25 | 4 | '''
01. Key-Key Value-Value
Write a program, which searches for a key and value inside of several key-value pairs.
Input
• On the first line, you will receive a key.
• On the second line, you will receive a value.
• On the third line, you will receive N.
• On the next N lines, you will receive strings in the following ... | true |
b0936ba1bc7bc61bec45b91ebb9467b0da6cd47e | fingerman/python_fundamentals | /python_bbq/OOP/008 settergetter.py | 1,220 | 4.46875 | 4 | class SampleClass:
def __init__(self, a):
## private varibale or property in Python
self.__a = a
## getter method to get the properties using an object
def get_a(self):
return self.__a
## setter method to change the value 'a' using an object
def set_a(self, a):
sel... | true |
45b01f271a65e346353cc5fcd18383ff480b8c9d | fingerman/python_fundamentals | /python-fundamentals/exam_Python_09.2018/1.DateEstimation.py | 1,251 | 4.4375 | 4 | '''
Problem 1. Date estimation
Input / Constraints
Today is your exam. It’s 26th of August 2018. you will be given a single date in format year-month-day. You should estimate if the date has passed regarding to the date mention above (2018-08-26), if it is not or if it is today. If it is not you should print how many ... | true |
ec67e60dc31824809ecf5024ce76c1708a46b295 | rmalarc/is602 | /hw1_alarcon.py | 1,967 | 4.28125 | 4 | #!/usr/bin/python
# Author: Mauricio Alarcon <rmalarc@msn.com>
#1. fill in this function
# it takes a list for input and return a sorted version
# do this with a loop, don't use the built in list functions
def sortwithloops(input):
sorted_input = input[:]
is_sorted = False
while not is_sorte... | true |
1ead53f839aedb80b3d3360ad1d1c972710a2d69 | Austinkrobison/CLASSPROJECTS | /CIS210PROJECTS/PROJECT3/DRAW_BARCODE/draw_barcode.py | 2,588 | 4.15625 | 4 |
"""
draw_barcode.py: Draw barcode representing a ZIP code using Turtle graphics
Authors: Austin Robison
CIS 210 assignment 3, part 2, Fall 2016.
"""
import argparse # Used in main program to obtain 5-digit ZIP code from command
# line
import time # Used in main program to pause program before exit
impo... | true |
8dd8056d42f4b32c463bc559c4ee173c2339e067 | tlarson07/dataStructures | /tuples.py | 1,378 | 4.3125 | 4 | #NOTES 12/31/2016
#Python Data Structures: Tuples
#Similar to lists BUT
#Can't be changed after creation (NO: appending, sorting, reversing, etc.
#Therefore they are more efficient
friends = ("Annalise", "Gigi", "Kepler") #
numbers = (13,6,1,23,7)
print friends[1]
print max(numbers)
(age,name) = (15,"Lauren") #assi... | true |
211273d69389aee16e11ffc9cf9275c0f509029e | sudhapotla/untitled | /Enthusiastic python group Day-2.py | 2,426 | 4.28125 | 4 | # Output Variables
# python uses + character to combine both text and Variable
x = ("hard ")
print("we need to work " + x)
x = ("hardwork is the ")
y = (" key to success")
z = (x + y)
print(z)
#Create a variable outside of a function, and use it inside the function
x = "not stressfull"
def myfunc():
print("Python ... | true |
deaa241ca580c969b2704ae2eb830487b247c766 | sudhapotla/untitled | /Python variables,Datatypes,Numbers,Casting.py | 1,192 | 4.25 | 4 | #Python Variables
#Variables are containers for storing data values.
#Rules for Variable names
#A variable name must start with a letter or the underscore character
#A variable name cannot start with a number
#A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
#Variable names a... | true |
a070d7391d0b798ed5d4b143c113b58d2134b6c4 | Allegheny-Computer-Science-102-F2018/classDocs | /labs/04_lab/sandbox/myTruthCalculatorDemo.py | 1,176 | 4.3125 | 4 | #!/usr/bin/env python3
# Note: In terminal, type in "chmod +x program.py" to make file executable
"""calcTruth.py A demo to show how lists can be used with functions to make boolean calculations"""
__author__ = "Oliver Bonham-Carter"
__date__ = "3 October 2018"
def myAND(in1_bool, in2_bool):
# functio... | true |
d80dcff9be08846685f9f553817a16daf91a2d77 | JeanneBM/PyCalculator | /src/classy_calc.py | 1,271 | 4.15625 | 4 | class PyCalculator():
def __init__(self,x,y):
self.x=x
self.y=y
def addition(self):
return self.x+self.y
def subtraction(self):
return self.x - self.y
def multiplication(self):
return self.x*self.y
def division(self):
if self.y == 0:
... | true |
ff7dbb03f9a296067fbd7e9cfff1ff58d2a00a63 | jocogum10/learning_python_crash_course | /numbers.py | 1,487 | 4.40625 | 4 | for value in range(1,5):
print(value)
for value in range(1,6):
print(value)
numbers = list(range(1,6))
print(numbers)
even_numbers = list(range(2,11,2))
print(even_numbers)
#square values
squares = [] #create empty list
for value in range(1,11): #loop from 1 to 10 using range function
square = value**2 #st... | true |
17d50543233400d554d9c838e64ec0c6f5506ce6 | ArashDai/SchoolProjects | /Python/Transpose_Matrix.py | 1,452 | 4.3125 | 4 | # Write a function called diagonal that accepts one argument, a 2D matrix, and returns the diagonal of
# the matrix.
def diagonal(m):
# this function takes a matrix m ad returns an array containing the diagonal values
final = []
start = 0
for row in m:
final.append(row[start])
start += 1
... | true |
3f2328a01dd09470f4421e4958f607c3b97a5e1f | Remyaaadwik171017/mypythonprograms | /flow controls/flowcontrol.py | 244 | 4.15625 | 4 | #flow controls
#decision making(if, if.... else, if... elif... if)
#if
#syntax
#if(condition):
# statement
#else:
#statement
age= int(input("Enter your age:"))
if age>=18:
print("you can vote")
else:
print("you can't vote") | true |
8fd6028336cac45579980611e661c84e892bbf12 | danksalot/AdventOfCode | /2016/Day03/Part2.py | 601 | 4.125 | 4 | def IsValidTriangle(sides):
sides.sort()
return sides[0] + sides[1] > sides [2]
count = 0
with open("Input") as inputFile:
lines = inputFile.readlines()
for step in range(0, len(lines), 3):
group = lines[step:step+3]
group[0] = map(int, group[0].split())
group[1] = map(int, group[1].split())
group[2] = map(i... | true |
f78c5a609bc06e6f4e623960f93838db21432089 | valerienierenberg/holbertonschool-higher_level_programming | /0x05-python-exceptions/0-safe_print_list.py | 744 | 4.125 | 4 | #!/usr/bin/python3
def safe_print_list(my_list=[], x=0):
a = 0
for y in range(x):
try:
print("{}".format(my_list[y]), end="")
a += 1
except IndexError:
break
print("")
return(a)
# --gives correct output--
# def safe_print_list(my_list=[], x=0):
# ... | true |
bc9d2fe1398ef572e5f23841976978c19a6e21a6 | YusefQuinlan/PythonTutorial | /Intermediate/2.5 pandas/2.5.5 pandas_Column_Edit_Make_DataFrame.py | 2,440 | 4.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Mar 19 17:11:39 2021
@author: Yusef Quinlan
"""
import pandas as pd
"""
Making a dictionary to be used to make a pandas DataFrame with.
The keys are the columns, and the values for the keys (which must be lists)
are what are used to make the DataFrame.
"""
dicti... | true |
881419c45d178dec904578bbe59fac4ce828b4b7 | YusefQuinlan/PythonTutorial | /Basics/1.16.3_Basic_NestedLoops_Practice.py | 2,147 | 4.40625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 20 15:10:45 2019
@author: Yusef Quinlan
"""
# A nested loop is a loop within a loop
# there may be more than one loop within a loop, and there may be loops within loops
# within loops etc etc
# Any type of loop can be put into any other type of loop
#as in the example ... | true |
05111398ed789569ad5d10cfbf537cb53a069ed5 | YusefQuinlan/PythonTutorial | /Intermediate/2.1 Some Useful-Inbuilt/2.1.8_Intermediate_Generators.py | 1,879 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 29 15:38:07 2020
@author: Yusef Quinlan
"""
# What is a generator?
# A generator is an iterable object, that can be iterated over
# but it is not an object that contains all the iterable instances of whatever
# it iterates, at once.
# return will return the first valid v... | true |
b51c8430b39bdf7dce428ccaaed9ddf5ef1c9505 | mahfoos/Learning-Python | /Variable/variableName.py | 1,180 | 4.28125 | 4 | # Variable Names
# A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume).
# Rules for Python variables:
# A variable name must start with a letter or the underscore character
# A variable name cannot start with a number
# A variable name can only contain alpha-numeric ... | true |
ae3689da43f974bd1948f7336e10162aea14cae6 | CharlesBasham132/com404 | /second-attempt-at-tasks/1-basics/2-input/2-ascii-robot/bot.py | 523 | 4.125 | 4 | #ask the user what text character they would wish to be the robots eyes
print("enter character symbol for eyes")
eyes = input()
print("#########")
print("# #")
print("# ",eyes,eyes, " #")
print("# ----- #")
print("#########")
#bellow is another way of formatting a face with the use of + instead of ,
#plusses + d... | true |
e2e0488734dab283f61b4114adf692f8d041209e | abhisheklomsh/Sabudh | /prime_checker.py | 700 | 4.25 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 9 10:51:47 2019
@author: abhisheklomsh
Here we ask user to enter a number and we return whether the number is prime or not
"""
def prime_check(input_num):
flag=1
if input_num ==1: print(str(input_num)+" is not a prime number")
else:
... | true |
17c67730fe1f49ff945cdd21cf9b814073341e32 | ThienBNguyen/simple-python-game | /main.py | 1,447 | 4.21875 | 4 | import random
def string_combine(aug):
intro_text = 'subscribe to '
return intro_text + aug
# def random_number_game():
# random_number = random.randint(1, 100)
# user_number = int(input('please guess a number that match with the computer'))
# while user_number == random_number:
# if ran... | true |
c8492b2fc31a4301356bdfd95ead7a6a97fcc010 | am93596/IntroToPython | /functions/calculator.py | 1,180 | 4.21875 | 4 |
def add(num1, num2):
print("calculating addition:")
return num1 + num2
def subtract(num1, num2):
print("calculating subtraction:")
return num1 - num2
def multiply(num1, num2):
print("calculating multiplication:")
return num1 * num2
def divide(num1, num2):
print("calculating division:"... | true |
a60f3c97b90c57d099e0aa1ade1650163cf8dd8d | adam-m-mcelhinney/MCS507HW | /MCS 507 Homework 2/09_L7_E2_path_length.py | 1,656 | 4.46875 | 4 | """
MCS H2, L7 E2
Compute the length of a path in the plane given by a list of
coordinates (as tuples), see Exercise 3.4.
Exercise 3.4. Compute the length of a path.
Some object is moving along a path in the plane. At n points of
time we have recorded the corresponding (x, y) positions of the object:
(x0, y0)... | true |
bf8675caa23965c36945c51056f3f34ec76ce1bc | anthonyharrison/Coderdojo | /Python/Virtual Dojo 3/bullsandcows.py | 2,390 | 4.15625 | 4 | # A version of the classic Bulls and Cows game
#
import random
# Key constants
MAX_GUESS = 10
SIZE = 4
MIN_NUM = 0
MAX_NUM = 5
def generate_code():
secret = []
for i in range(SIZE):
# Generate a random digit
code = random.randint(MIN_NUM,MAX_NUM)
secret.append(str(code))
return sec... | true |
6bc2dbc19391e9ef4e37a9ce96a4f5a7cdb93654 | skfreego/Python-Data-Types | /list.py | 1,755 | 4.53125 | 5 | """
Task:-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 th... | true |
80612a7405e7f0609f457a2263715a5077eaa327 | buy/leetcode | /python/94.binary_tree_inorder_traversal.py | 1,313 | 4.21875 | 4 | # Given a binary tree, return the inorder traversal of its nodes' values.
# For example:
# Given binary tree {1,#,2,3},
# 1
# \
# 2
# /
# 3
# return [1,3,2].
# Note: Recursive solution is trivial, could you do it iteratively?
# confused what "{1,#,2,3}" means? > read more on how binary tree is ser... | true |
e8689f10872987e7c74263e68b95788dce732f56 | buy/leetcode | /python/145.binary_tree_postorder_traversal.py | 983 | 4.125 | 4 | # Given a binary tree, return the postorder traversal of its nodes' values.
# For example:
# Given binary tree {1,#,2,3},
# 1
# \
# 2
# /
# 3
# return [3,2,1].
# Note: Recursive solution is trivial, could you do it iteratively?
# Definition for a binary tree node.
# class TreeNode:
# def __ini... | true |
8f5d33183271397e07fd1b45717bc15dc24ba80f | nayanika2304/DataStructuresPractice | /Practise_graphs_trees/random_node.py | 2,420 | 4.21875 | 4 | '''
You are implementing a binary tree class from scratch which, in addition to
insert, find, and delete, has a method getRandomNode() which returns a random node
from the tree. All nodes should be equally likely to be chosen. Design and implement an algorithm
for getRandomNode, and explain how you would implement the ... | true |
4774e23e3a65b54ff0e96736d0d491a965c6a1b4 | nayanika2304/DataStructuresPractice | /Practise_linked_list/remove_a_node_only pointer_ref.py | 1,885 | 4.375 | 4 | '''
Implement an algorithm to delete a node in the middle (i.e., any node but
the first and last node, not necessarily the exact middle) of a singly linked list, given only access to
that node.
iterating through it is a problem as head is unkniwn
faster approach is to copy the data of next node in current node
and de... | true |
c173928913363f978662919341813f5ae867bf95 | fanyichen/assignment6 | /lt911/assignment6.py | 1,816 | 4.28125 | 4 | # This program is to manage the user-input intervals. First have a list of intervals entered,
# then by taking new input interval to merge intervals.
# input of valid intervals must start with [,(, and end with ),] in order for correct output
import re
import sys
from interval import interval
from interval_functions i... | true |
29816333038bf4bf14460d8436d1b75243849537 | kevgleeson78/Emerging-Technonlgies | /2dPlot.py | 867 | 4.15625 | 4 | import matplotlib.pyplot as plt
# numpy is used fo scientific functionality
import numpy as np
# matplotlib plots points in a line by default
# the first list is the y axis add another list for the x axis
# To remove a connecting line from the plot the third arg is
# shorthand for create blue dots
# numpy range
x = n... | true |
f17209f360bf135a9d3a6da02159071828ca0087 | hamishscott1/Number_Guessing | /HScott_DIT_v2.py | 1,120 | 4.3125 | 4 | # Title: Guess My Number v2
# Date: 01/04/2021
# Author: Hamish Scott
# Version: 2
""" The purpose of this code is to get the user to guess a preset number.
The code will tell them if the number is too high or too low and will
tell them if it is correct."""
# Setting up variables
import random
int_guess = 0
... | true |
e995bf856a613b5f1978bee619ad0aaab4be80ed | saibeach/asymptotic-notation- | /v1.py | 1,529 | 4.21875 | 4 | from linkedlist import LinkedList
def find_max(linked_list):
current = linked_list.get_head_node()
maximum = current.get_value()
while current.get_next_node():
current = current.get_next_node()
val = current.get_value()
if val > maximum:
maximum = val
return maximum
#Fill in Func... | true |
02a7ab067157be02467fd544a87a26fb7d792d7b | mayurimhetre/Python-Basics | /calculator.py | 735 | 4.25 | 4 | ###### Python calculator Program ##############################
### taking two numbers as input from user and option
print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
choose = int(input("Enter your option : 1,2,3,4 : "))
a = int(input("Enter First Number :"))
b = int(... | true |
2f563e53a9d4c0bbf719259df06fb0003ac205bc | sweetise/CondaProject | /weight_conversion.py | 433 | 4.28125 | 4 | weight = float(input(("Enter your Weight: ")))
unit = input(("Is this in 'lb' or 'kg'?"))
convert_kg_to_lb = round(weight * 2.2)
convert_lb_to_kg = round(weight / 2.2)
if unit == "kg":
print(f" Your weight in lbs is: {convert_kg_to_lb}")
elif unit == "lb":
print(f" Your weight in kg is: {convert_lb_to_kg}")
... | true |
f6b8082233895e0a78275d13d2ec29c14bc088cf | Ethan2957/p03.1 | /multiple_count.py | 822 | 4.1875 | 4 | """
Problem:
The function mult_count takes an integer n.
It should count the number of multiples of 5, 7 and 11 between 1 and n (including n).
Numbers such as 35 (a multiple of 5 and 7) should only be counted once.
e.g.
mult_count(20) = 7 (5, 10, 15, 20; 7, 14; 11)
Tests:
>>> mult_count(20)... | true |
f7f7a5f023f89594db74f69a1a2c3f5f34dfc881 | gpallavi9790/PythonPrograms | /StringPrograms/5.SymmetricalString.py | 241 | 4.25 | 4 | #Prgram to check for symmetrical string
mystr=input("Enter a string:")
n=len(mystr)
mid=n//2
firsthalf=mystr[0:mid]
secondhalf=mystr[mid:n]
if(firsthalf==secondhalf):
print("Symmetrical String")
else:
print("Not a Symmetrical String")
| true |
57740b0f61740553b9963170e2dddc57c7b9858b | gpallavi9790/PythonPrograms | /StringPrograms/7.RemoveithCharacterFromString.py | 400 | 4.25 | 4 | #Prgram to remove i'th character from a string
mystr="Pallavi Gupta"
# Removing char at pos 3
# using replace, removes all occurences
newstr = mystr.replace('l', '')
print ("The string after removal of i'th character (all occurences): " + newstr)
# Removing 1st occurrence of
# if we wish to remove it.
newstr = myst... | true |
f47f69de9366760f05fda6dd697ce2301ad38e01 | johnhjernestam/John_Hjernestam_TE19C | /introkod_syntax/Annat/exclusiveclub.py | 453 | 4.125 | 4 | age = int(input('How old are you? '))
if age < 18:
print('You are too young.')
if age > 30:
print('You are too old.')
if age >= 18:
answer = input('Have you had anything to drink today or taken something? Yes or no: ')
if answer == "no":
print('You got to be turned up')
else:
prin... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.