blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
d88926237a6b9aadabe227420130ae0a8c617524 | Code-Institute-Solutions/directory-based | /03-test_driven_development/asserts.py | 441 | 4.28125 | 4 | def is_even(number):
return number % 2 == 0
def even_numbers_of_evens(numbers):
evens = sum([1 for n in numbers if is_even(n)])
return False if evens == 0 else is_even(evens)
assert even_numbers_of_evens([]) == False, "No numbers"
assert even_numbers_of_evens([2, 4]) == True, "Two even numbers"
assert ev... | false |
559618c6a03eb8547eed2891b4ac7ed038e92b3b | KhadijaAbbasi/python-program-to-take-input-from-user-and-add-into-tuple | /tuple.py | 244 | 4.15625 | 4 | tuple_items = ()
total_items = int(input("Enter the total number of items: "))
for i in range(total_items):
user_input = int(input("Enter a number: "))
tuple_items += (user_input,)
print(f"Items added to tuple are {tuple_items}")
| true |
4472c1ba6c824fb9021d05ef985d4394cc6a61f9 | YuriiKhomych/ITEA-BC | /Sergii_Davydenko/7_collections/practise/pr_3.py | 1,452 | 4.59375 | 5 | #
#
# Buffet: A buffet-style restaurant offers only five basic foods. Think of five simple foods, and store them in a tuple.
#
# Use a for loop to print each food the restaurant offers.
# Try to modify one of the items, and make sure that Python rejects the change.
# The restaurant changes its menu, replaci... | true |
1944dfdcadc11363e212ae18c4703f0fdf0e6e85 | YuriiKhomych/ITEA-BC | /Vlad_Hytun/8_files/HW/HW81_Hytun.py | 1,509 | 4.59375 | 5 | # 1. 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 program arguments and finds
# and prints all ... | true |
0d5c313729151e7a85b242ac9c962fde609e3ddf | YuriiKhomych/ITEA-BC | /Vlad_Hytun/5_functions/practise/P52-Hytun_Vlad.py | 330 | 4.1875 | 4 | # 2. Define a function that computes the length of a
# given list or string. (It is true that Python has
# the len() function built in, but writing it yourself
# is nevertheless a good exercise.)
def my_len(str):
count_symbol = 0
for i in str:
count_symbol += 1
return count_symbol
print(my_len('d... | true |
7182a3fc269c6e81fff77f6a66921c7469c6746b | YuriiKhomych/ITEA-BC | /Sergii_Davydenko/7_collections/HW/hw_6.py | 726 | 4.34375 | 4 | #
#
# Pets: Make several dictionaries, where the name of each dictionary is the name of a pet.
#
# In each dictionary, include the kind of animal and the owner’s name.
# Store these dictionaries in a list called pets.
# Next, loop through your list and as you do print everything you know about each pet.
#
#... | true |
71c997605a5578583cd9de46f7bdbe283dd99ff4 | YuriiKhomych/ITEA-BC | /Sergey_Naumchick/5_functions/05_PR_03.py | 411 | 4.1875 | 4 | '''3. Write a function that takes a character (i.e. a
string of length 1) and returns True if it is a vowel,
False otherwise.'''
VOLVED = 'aeiouy'
my_input = ""
while len(my_input) != 1:
my_input = input("please input only one symbol: ")
def my_func(func):
if func in VOLVED:
return True
else:
... | true |
fdce28c8eb106cdcc1f205ac12a2f813a893aaeb | YuriiKhomych/ITEA-BC | /Patenko_Victoria/3_conditions/homework3.1.py | 2,979 | 4.25 | 4 | my_fav_brand = ["toyota", "audi", "land rover"]
my_fav_model = ["camry", "r8", "range rover"]
my_fav_color = ["blue", "black", "gray"]
price = 3000
brand: "str" = input("Brand of your car is: ")
if brand not in my_fav_brand:
print("Got it!")
else:
print("Good choice!")
price_1 = price + 100
model = input("Mod... | true |
80ef3072710719831cc6968b4d049e964b94faa4 | YuriiKhomych/ITEA-BC | /Sergii_Davydenko/7_collections/HW/hw_2.py | 1,823 | 4.375 | 4 | #
#
# My Pizzas, Your Pizzas: Make a copy of the list of pizzas, and call it friend_pizzas.
# Then, do the following:
#
# Add a new pizza to the original list. ########## Done
# Add a different pizza to the list friend_pizzas. ######### Done
# Prove that you have two separate lists.
#
# Print the messag... | true |
14e5cd2b86f8e1df5ac05d69416b2a2455e3b47b | YuriiKhomych/ITEA-BC | /Sergii_Davydenko/7_collections/practise/pr_1.py | 1,296 | 4.65625 | 5 | #
#
# Pizzas: Think of at least three kinds of your favorite pizza. Store these pizza
# names in a list, and then use a for loop to print the name of each pizza.
#
# Modify your for loop to print a sentence using the name of the pizza
# instead of printing just the name of the pizza. For each pizza you should
#... | true |
2e6fe0e1de69caccd003f1de0d9e2d43562d254b | YuriiKhomych/ITEA-BC | /Oksana_Yeroshenko/6_strings/6_strings_practise_yeroshenko_4.py | 628 | 4.21875 | 4 | my_string = "AV is largest Analytics community of India"
# 4. Return first word from string.
# result: `AV`
my_string.split(' ')[0]
# 5. Return last word from string.
# result: `India`
my_string.split(' ')[-1]
# 6. Get two symbols of each word in string
# result: `['AV', 'is', 'la', 'An', 'co', 'of', 'In']`
my_st... | true |
85f79e9a11264fbecf65e7c7e41e7cf36bfdc7bc | YuriiKhomych/ITEA-BC | /Nemchynov_Artur/5_functions/Practise#5.1.py | 475 | 4.125 | 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. (It is true that Python has the `max()` function
# built in, but writing it yourself is nevertheless a good exercise.)"""
def max_in_list(lst):
max = 0
for n in ... | true |
598d6b24b64826bff334de88948e23abe3e01762 | YuriiKhomych/ITEA-BC | /Sergii_Davydenko/9_functional_programming/HW9/hw_1.py | 1,292 | 4.46875 | 4 | # The third person singular verb form in English is distinguished by the suffix
# -s, which is added to the stem of the infinitive form: run -> runs. A simple
# set of rules can be given as follows:
# If the verb ends in y, remove it and add ies If the verb ends in o, ch, s, sh,
# x or z, add es By default just add s Y... | true |
29b9026eeaf7d582b512ded6d6deb8ee3cf4da6d | YuriiKhomych/ITEA-BC | /Andrii_Bakhmach/4_iterations/4_3_exercise.py | 303 | 4.15625 | 4 | #Write a Python program that accepts a sequence of lines (blank line to terminate) as input
#and prints the lines as output (all characters in lower case).
our_line = input("please, input you text: ")
if our_line is None:
print("input your text once more")
else:
print(our_line.lower())
| true |
a3d0bef46700b4471601bc766aaf75d7e1c64cf7 | YuriiKhomych/ITEA-BC | /Vlad_Hytun/7_collections/practise/P75_Hytun.py | 804 | 4.90625 | 5 | # 5. Rivers:
# Make a dictionary containing three major rivers and the country each river runs through.
# One key-value pair might be `'nile': 'egypt'`.
# * Use a loop to print a sentence about each river, such as The Nile runs through Egypt.
# * Use a loop to print the name of each river included in the dictio... | true |
76cdeb563c3329f18ce11051aa902ca2a18f6bf7 | YuriiKhomych/ITEA-BC | /Oksana_Yeroshenko/6_strings/6_strings_practise_yeroshenko_3.py | 585 | 4.28125 | 4 | # 3. Define a function `overlapping()` that takes two lists and
# returns True if they have at least one member in common,
# False otherwise. You may use your `is_member()` function,
# or the in operator, but for the sake of the exercise,
# you should (also) write it using two nested for-loops.
a = (1, "a", "b", "c", ... | true |
fb85dfcc07245c05844294fc7bd12ff25175d642 | YuriiKhomych/ITEA-BC | /Andrii_Bakhmach/5_functions/HW/5_5_exercise.py | 488 | 4.15625 | 4 | #Write a function `is_member()` that takes a value
#i.e. a number, string, etc) x and a list of values a,
#and returns True if x is a member of a, False otherwise.
#(Note that this is exactly what the `in` operator does, but
#for the sake of the exercise you should pretend Python
#id not have this operator.)
def is_me... | true |
26673a4cb7762f89c06e0bb5dab3387415aabb75 | YuriiKhomych/ITEA-BC | /Sergii_Davydenko/4_iterations/practise2.py | 338 | 4.25 | 4 | # Write a Python program to count the number of even
# and odd numbers from a series of numbers.
number = int(input('Make your choice number: '))
even = 0
odd = 0
for i in range(number):
if i % 2 == 0:
even += 1
elif i % 2 != 0:
odd += 1
print(f'The odd numbers is {odd}')
print(f'The even nu... | true |
94cfe965059c1be0c455f78f4dd83c2b8df387f7 | YuriiKhomych/ITEA-BC | /Vlad_Hytun/7_collections/hw/HW74_Hytun.py | 632 | 4.1875 | 4 | # # Dictionary
# 4. Favorite Numbers:
# * Use a dictionary to store people’s favorite numbers.
# * Think of five names, and use them as keys in your dictionary.
# * Think of a favorite number for each person, and store each as a value in your dictionary.
# * Print each person’s name and their favori... | true |
84c50cc665fa7f67d2bbe261ce6c657a6adf8da1 | YuriiKhomych/ITEA-BC | /Andrii_Ravlyk/7_collections/practise/pr4_person.py | 440 | 4.21875 | 4 | '''4. Person:
* Use a dictionary to store information about a person you know.
* Store their first name, last name, age, and the city in which they live.
* You should have keys such as first_name, last_name, age, and city.
* Print each piece of information stored in your dictionary.'''
my_dict = {"firs... | true |
73bb85c2b0ddb1b71fd7d9495dee92ff2afa1a22 | YuriiKhomych/ITEA-BC | /Sergii_Davydenko/9_functional_programming/HW9/hw_2.py | 1,325 | 4.375 | 4 | # In English, the present participle is formed by adding the suffix -ing
# to the infinite form: go -> going. A simple set of heuristic rules can
# be given as follows: If the verb ends in e, drop the e and add ing
# (if not exception: be, see, flee, knee, etc.)
# If the verb ends in ie, change ie to y and add ing For... | true |
3f2566abf3dc5144058177b9ed8ec52799b9fd87 | YuriiKhomych/ITEA-BC | /Sergii_Davydenko/4_iterations/practise1.py | 224 | 4.1875 | 4 | # Write a Python program that prints all the numbers from 0 to 6 except 3 and 6.
# Note : Use 'continue' statement.
# Expected Output : 0 1 2 4 5
for i in range(0, 6):
if i == 3:
continue
print(i, end=", ")
| true |
2edb0b06caf01ff2ec134e1f8589b12ecc867fe6 | YuriiKhomych/ITEA-BC | /Sergey_Naumchick/7_Collections/PR/PR_07_05.py | 710 | 4.90625 | 5 | '''5. Rivers:
Make a dictionary containing three major rivers and the country each river runs through.
One key-value pair might be `'nile': 'egypt'`.
* Use a loop to print a sentence about each river, such as The Nile runs through Egypt.
* Use a loop to print the name of each river included in the dictionary.
... | true |
e6bc0f5408a6c4bcccf6c5ab27cf8539c595d08a | shailesh/angle_btwn_hrs_min | /angle_btw_hrs_min.py | 713 | 4.15625 | 4 | def calcAngle(hour,minute):
# validating the inputs here
if (hour < 0 or minute < 0 or hour > 12 or minute > 60): print('Wrong input')
if (hour == 12): hour = 0
if (minute == 60): minute = 0
# Calculating the angles moved by hour and minute hands with reference to 12:00
hour_angle, minute_ang... | true |
0021e305037992731bdc891d8d6bf4bd35d227bd | vwang0/causal_inference | /misc/pi_MC_simulation.py | 737 | 4.15625 | 4 | '''
Monte Carlo Simulation: pi
N: total number of darts
random.random() gives you a random floating point number in the range [0.0, 1.0)
(so including 0.0, but not including 1.0 which is also known as a semi-open range).
random.uniform(a, b) gives you a random floating point number in the range [a, b],
(where roun... | true |
f391340953675e637a74ca5ac0473961f4e69b38 | yukikokurashima/Python-Practice | /Python3.2.py | 542 | 4.1875 | 4 | def calc_average(scores):
return sum(scores) / 5
def determine_grade(score):
if 90 <= score <= 100:
result = "A"
elif 80 <= score <= 89:
result = "B"
elif 70 <= score <= 79:
result = "C"
elif 60 <= score <= 69:
result = "D"
else:
result = "F"
return result
scores = []
for _ in range(5):
score = int... | true |
89bbd5a5b7c05eaa471954f562d33d8bf04024ba | EstevamPonte/Python-Basico | /PythonExercicios/mundo2/ex038.py | 332 | 4.125 | 4 | primeiro = int(input('digite um valor: '))
segundo = int(input('digite um valor: '))
if segundo > primeiro:
print('o numero {} é maior que o numero {}'.format(segundo, primeiro))
elif primeiro > segundo:
print('o numero {} é maior que o numero {}'.format(primeiro, segundo))
else:
print('Os dois numeros sao... | false |
435b42c6946277df30947069bdf071ff21c60448 | yaksas443/SimplyPython | /days.py | 415 | 4.34375 | 4 | # Source: Understanding Computer Applications with BlueJ - X
# Accept number of days and display the result after converting it into number of years, number of months and the remaining number of days
days = int(raw_input("Enter number of days : "))
years = days / 365
rem = days % 365
months = rem / 30
rem = rem % ... | true |
b659ec2d05bbcc676a3a9eed647941edddb48601 | yaksas443/SimplyPython | /sumfactorial.py | 443 | 4.21875 | 4 | # Source: https://adriann.github.io/programming_problems.html
# Write a program that asks the user for a number n and prints the sum of the numbers 1 to n
# To convert str to int use int()
# to concatenate int to str, first convert it to str
def sumFactorial(number):
count = 0
sum=0
for count in range(0,number):
... | true |
87fd6a86c8de17dbbcdedc073a6c5c7c4b19d396 | mariavarley/PythonExercises | /pyweek2.py | 428 | 4.15625 | 4 | #!/usr/bin/python
num = int(input("Please Enter a number\n"))
check = int(input("Please Enter a number to divide with\n"))
if num%4 == 0:
print("The number is divisible by 4")
elif num%2 == 0:
print("The number is an even number")
else:
print("The number is an odd number")
if num%check == 0:
print("The nu... | true |
bca3a78b6ee4b68f4efc0ca71186e9299121bd90 | Sav1ors/labs | /Bubble_Sort.py | 384 | 4.15625 | 4 | def bubbleSort(list):
for passnum in range(len(list)-1,0,-1):
for i in range(passnum):
if list[i]>list[i+1]:
temp = list[i]
list[i] = list[i+1]
list[i+1] = temp
list = []
for i in range(int(input('Enter the number of list items\n'))):
list.app... | true |
611c5db0bf4ee59131fc59b83842c7dc433fb444 | mekhrimary/python3 | /factorial.py | 1,417 | 4.25 | 4 | # Вычисление факториала числа 100 различными методами
# Метод 1: рекурсия
def recursive_factorial(n):
if n == 0:
return 1
else:
return n * recursive_factorial(n - 1)
print(f'Метод 1 (рекурсия) для числа 100: {recursive_factorial(100)}')
# Метод 2: итерация + рекурсия
def iterative_and_recur... | false |
bfba95ff46cc7730d8736d352b900c4dd89d00c4 | mekhrimary/python3 | /countdown.py | 1,121 | 4.15625 | 4 | # Recursive function as a countdown
def main():
"""Run main function."""
number = get_number()
while number == 0:
number = get_number()
print('\nStart:')
countdown(number)
def get_number() -> int:
"""Input and check a number from 1 to 100."""
try:
num = int(input... | true |
fadc2a22e5db5f8b2887067699ee05c721328e7c | mekhrimary/python3 | /lettersstatsemma.py | 1,818 | 4.125 | 4 | # Use string.punctuation for other symbols (!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~)
import string
def main() -> None:
'''Run the main function-driver.'''
print('This program analyzes the use of letters in a passage')
print('from "Emma" by Jane Austen:\n')
print('Emma Woodhouse, handsome, clever, and r... | true |
6ee057f17a4b7b82142808545a47ae6b5d0cc2bf | leonlinsx/ABP-code | /Python-projects/crackle_pop.py | 682 | 4.3125 | 4 | '''
recurse application
Write a program that prints out the numbers 1 to 100 (inclusive).
If the number is divisible by 3, print Crackle instead of the number.
If it's divisible by 5, print Pop.
If it's divisible by both 3 and 5, print CracklePop.
You can use any language.
'''
class CracklePop:
def __in... | true |
6982b7b8cf932a3c9e59e5909c3dfd6d1d6716d0 | Ayush-1211/Python | /Advanced OOP/9. Polymorphism.py | 1,130 | 4.46875 | 4 | '''
Polymorphism: Polymorphism lets us define methods in the child class that have the same name as
the methods in the parent class.
In inheritance, the child class inherits the methods from the parent class.
'''
class User:
def sign_in(self):
print('Logged I... | true |
bd25b715de543f5ad54f7adc3fa0da0f237f86dd | dartleader/Learning | /Python/How to Think Like A Computer Scientist/4/exercises/8.py | 373 | 4.4375 | 4 | #Write a function area_of_circle(r) which returns the area of a circle with radius r.
def area_of_circle(r):
"""Calculate area of a circle with radius r and return it.""" #Docstring
#Declare temporary variable to hold the area.
area = 0
#Calculate area.
area = 3.14159 * r
#Return area.
return area
print(input(a... | true |
b4f6d71f352434965960284a54113bc719abb2c6 | Zidan2k9/PythonFundamentals | /loops.py | 733 | 4.15625 | 4 | # A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).
people = ['Zain','Rida','Zaid','Mom','Dad']
for person in people:
print('Current person is ' , person)
#Break out
for person in people:
if person == 'Zaid':
break
print('C... | true |
3e525a576deccda073de297716d21a6a2858e114 | jingruhou/practicalAI | /Basics/PythonTutorialforBeginners/03strings.py | 512 | 4.125 | 4 | course = "Python's Course for Beginners"
print(course)
course = 'Python for "Beginners"'
print(course)
course = '''
Hi houjingur,
The support team
'''
print(course)
course = 'Python for Beginners'
# 012345
print(course[0])
print(course[0:3])
print(course[:-1])
print(course[-1])
print(course[-2])
print(... | false |
51f9a1607482265594555e7496c350ab2f1d82ad | parmar-mohit/Data-Structures-and-Algorithms | /Searching Algorithms/Python/Binary Search.py | 861 | 4.15625 | 4 | def binary_search( arr, len, num ) :
ll = 0
ul = len - 1
mid = int( ll + ul / 2 )
while( ll < ul and mid < len ) :
if arr[mid] > num :
ul = mid - 1
elif arr[mid] < num :
ll = mid + 1
else:
break;
mid = int( ul + ll / 2 )
... | false |
236b634d4754fef2a4a56e828e8ae04be0bcacb5 | parmar-mohit/Data-Structures-and-Algorithms | /Searching Algorithms/Python/Linear Search.py | 519 | 4.125 | 4 | def linearSearch( arr, len , num):
for i in range( len ) :
if arr[i] == num :
return i
else:
return -1
len = int( input( "Enter Length of Array : " ) )
arr = []
for i in range( len ) :
arr.append( int( input( "Enter Value in Array : " ) ) )
num = int( input( "En... | false |
fb7e04ae9c850d0d23b8e69a6d1c29533514f771 | ToddDiFronzo/cs-sprint-challenge-hash-tables | /hashtables/ex3/ex3.py | 575 | 4.125 | 4 | """ INTERSECTION OF MULTIPLE LISTS
1. Understand:
Goal: find intersection of multiple lists of integers
Test case
---------
Input: list of lists
[1,2,3,4,5]
[12,7,2,9,1]
[99,2,7,1]
Output: (1,2)
2. Plan:
NOTE: skipping this one.
"""
if __... | true |
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 |
4c9ae12c70a0170077b60a70a2339afbd85a9e52 | ctwillson/algo | /python/sorting/InsertSort/InsertSort.py | 563 | 4.21875 | 4 | '''
插入排序
动画来源:https://visualgo.net/en/sorting?slide=9
'''
import numpy as np
LENGTH = 10
a = np.random.randint(10,size=LENGTH)
print(a)
# print(list(range(10,0,-1)))
#后面的元素往前插入
def InsertSort_demo(arr):
'''
i 控制从第几个元素开始比较,j控制第几个元素往前比较
'''
for i in range(1,LENGTH):
for j in range(i,0,-1):
... | false |
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 |
a4720d13bb654710000ccfb3a644af6914969c90 | VladTano/code-study | /LABA 5.py | 1,251 | 4.15625 | 4 |
#Програма. Дана послідовність, що містить від 2 до 20 слів,
#в кожному з яких від 2 до 10 латинських букв; між сусідніми словами -
#не менше одного пробілу, за останнім словом - крапка. Вивести на екран
#всі слова, відмінні від останнього слова, попередньо видаливши з таких
#слів першу букву.
x = input()
x = x.split... | false |
172607053de3d302179eeadafe18f4331246fe9d | shusingh/My-Python | /dict.py | 1,952 | 4.34375 | 4 | # in this module we will learn about awesome dictionaries
# defining a dictionary
en_hin = {"good":"accha", "sit":"baithna", "walk":"chalna", "love":"pyar"}
# now let's check our eng-hindi dictionary
print(en_hin["good"])
print(en_hin["sit"])
print(en_hin["love"])
print(en_hin) # there is no ordering in dictionaries
... | false |
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 |
0c1cb03e151ed82f535ad691fb1f28d2539406c3 | antonioleitebr1968/Estudos-e-Projetos-Python | /Exercicios&cursos/Curso_em_video(exercicios)/aula09.py | 2,675 | 4.21875 | 4 | frase = 'Curso em Vídeo Python'
print('='*40, 'Bem vindo aos exemplos da Aula 09', '='*40)
print(' '*50, 'Manipulando texto :)', ' '*50)
print('')
print('='*51, 'Fatiamento', '='*52)
print('')
print('1>>', frase[9])#ele vai indentificar a caractere 9 ou seja a 10 pq para o python começa a contar da caractere 0
print(''... | false |
a82bf9799f8c2376e7f4ac60adb7aa9e45b76eec | antonioleitebr1968/Estudos-e-Projetos-Python | /Exercicios&cursos/Dicionarios/Dicionarios_03.py | 385 | 4.25 | 4 | ## Dicionários parte 3 - Ordenação por chaves; método keys() e função sorted.
# Exemplos:
#Ordenação de dicionarios
d = {'b': 2, 'a': 1, 'd': 4, 'c': 3}
ordenada = list(d.keys())
ordenada.sort()
for key in ordenada:
print(key, '=', d[key])
print('-=' * 20)
#===============================================
#outra ... | false |
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 |
4e9e37db57f014e20bde5806050022a9911a99ed | ottoguz/My-studies-in-Python | /ex018a.py | 343 | 4.34375 | 4 | #Calculate an angle and its Sen/Cos/Tg
import math
ang = float(input('Type an angle:'))
# Used the function math.radians() to turn numbers into radians
print('Sine:{:.2f}' .format(math.sin(math.radians(ang))))
print('Cosene:{:.2f}' .format(math.cos(math.radians(ang))))
print('Tangent:{:.2f}'.format(math.tan(math.... | false |
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 |
c674750f830792e233e5cb6cd0b7202dce23fddd | romulovieira777/Curso_Rapido_de_Python_3 | /Seção 02 - Variáveis/variaveis.py | 501 | 4.1875 | 4 | # Definindo uma variável int e float
a = 3
b = 4.4
print(a + b)
# Definindo uma variável de texto
texto = 'Sua idade é... '
idade = 23
print(texto + str(idade))
print(f'{texto} {idade}!')
# Imprimindo string
print(3 * 'Bom Dia! ')
# Criando uma Interação com o Usuário
pi = 3.14
raio = float(input('Informe o raio... | false |
5c8af61748085a7bf39a1a6dea1a134a8843005e | mattfisc/cs240 | /HW6program3_binary_to_decimal.py | 598 | 4.15625 | 4 | def binary_to_decimal(x):
num = 0
twoPower = 1
for i in range(len(x)-1,-1,-1):
num += x[i] * (2**twoPower)
twoPower += 1
return num
def compare_two_binary(binary1,binary2):
b1 = binary_to_decimal(binary1)
b2 = binary_to_decimal(binary2)
if b1 > b2:
return binary1, "... | false |
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 |
7359fb54f366e1a261f06bf190c92f3ebc72d752 | zvikazm/ProjectEuler | /9.py | 583 | 4.28125 | 4 | """
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
class P9(object):
@staticmethod
def run():
for i in range... | false |
0260224543d1b2f8b51e3cbf22530d176fa1a684 | Zane-ThummBorst/Python-code | /Factorial code.py | 1,117 | 4.21875 | 4 | #
# Zane ThummBorst
#
#9/9/19
#
# demonstrate recursiuon through the factorial
# and list length
def myFactorial(x):
''' return the factorial of x assuming x is > 0'''
# if x == 0:
# return 1
# else:
# return x * myFactorial(x-1)
return 1 if x==0 else x*myFactorial(x-1)
#print(myFactorial(... | false |
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 |
dc5a055097f7162f6204cbcbc66ec96eed827db4 | DangGumball/DangGumball | /Homework/BMI.py | 408 | 4.21875 | 4 | height_cm = int(input('Enter your height here (cm): '))
weight = int(input('Enter your weight here (kg): '))
height_m = height_cm / 100
BMI = weight / (height_m * height_m)
print(BMI)
if BMI < 16:
print('Severely underweight')
elif 16 <= BMI <= 18.5:
print('Underweight')
elif 18.5 <= BMI <= 25:
pr... | false |
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 |
a906a6093594811a719d8113acd7c7ddcb1897fe | hiteshkrypton/Python-Programs | /dice_game.py | 1,665 | 4.1875 | 4 | #Dice game
#Made by satyam
import random
import time
import sys
while True :
def start():
sum = 0
counter = 0
verification = 'y'
while counter < 3 and verification == 'y' :
dice_number = random.randint(1, 6)
print('Computer is rolling a dice ',end ='')
... | false |
a8208d7d0d616979a5b0e40ae918bca80e5ae460 | ZCKaufman/python_programming | /squareRoot.py | 559 | 4.28125 | 4 | import math
class SquareRoot():
def sqrt(self, num) -> float:
x0 = (1/2)*(num + 1.0)
i = 0
while(i <= 5):
x0 = (1/2)*(x0 + (num/x0))
i += 1
return x0
obj = SquareRoot()
obj.sqrt(4)
obj.sqrt(10)
obj.sqrt(8)
obj.sqrt(6)
if __name__ == '__main__':
obj = Squ... | false |
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 |
6449b99534151c641b5856b5bc31874d27eae50c | sachinsaurabh04/pythonpract | /Loop/forloop1.py | 576 | 4.15625 | 4 | #for letter in 'python':
# print("Letter in python is ", letter)
#print()
#fruits=['banana','apple','mango']
#for x in fruits:
# print('current fruit ', x)
#print("Good bye")
#!/usr/bin/python3
#fruits = ['banana','apple', 'mango']
#for x in range(len(fruits)):
# print("My favourite fruits are : ", fruits[x]... | false |
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 |
870584ac512971e7b83b510160036437227417f9 | Apoorva-K-N/Online-courses | /Day 12/coding/prog1(Day 12).py | 280 | 4.125 | 4 | 1.Python Program for Sum of squares of first n natural numbers
def squaresum(n):
return (n * (n + 1) / 2) * (2 * n + 1) / 3
n=int(input("Enter number"))
print("Sum of squares n numbers : ",squaresum(n));
output:
Enter number5
Sum of squares n numbers : 55.0 | false |
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 |
c705cd6c2c07fab452bc83550ca83116952bc2b9 | shnehna/python_study | /string.py | 238 | 4.21875 | 4 | num_str = "Hello world "
# print(num_str.isdecimal())
# print(num_str.isdigit())
# print(num_str.isnumeric())
print(num_str.startswith("H"))
print(num_str.endswith("d"))
print(num_str.find(" "))
print(num_str.replace("world", "python"))
| false |
38a4524825587ad4c8d39ee9398d37ae760d8950 | cceniam/BaiduNetdiskDownload | /python/python系统性学习/2020_04_18/list_learn.py | 2,360 | 4.125 | 4 | """
类似于 int float 这种类型,没有可以访问的内部结构
类似于 字符串 (str) 是结构化非标量类型 有一系列的属性方法
今天学习 list 列表 :
"""
# list 有序 每个值可通过索引标识
import sys
list1 = [1, 2, 3, 4, 5, 6]
print(list1)
# 乘号表示重复的次数
list2 = ['hello'] * 3
print(list2)
list3 = list1 * 3
print(list3)
# len() 计算list长度
print(len(list3))
# 通过enumerate函数处理列表之后再遍历可以同时获得元素索引和值
for w... | false |
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 |
ed16d51907433405f06402bff946b63fc38a78dc | julianhyde/seb | /python_work/factor.py | 1,678 | 4.125 | 4 | #
#
# We want to print:
#
# a c e
# ---- + ---- = ----
# b d f
#
# For example, given (3, 4, 1, 10), we should print
#
# 3 1 17
# ---- + ---- = ----
# 4 10 20
#
def add_fractions(a, b, c, d):
(e, f) = (c * b + a * d, b * d)
# print(f"e={e},f={f}")
g... | false |
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 |
76a39ca0738ac7528aa266fcda8343f5e65ba1e8 | Jerasor01924/NikolasEraso | /ajedrez.py | 2,256 | 4.4375 | 4 | '''Descripción: Reeborg se mueve horizontal o verticalmente en linea recta
en un campo de 8*8 de ajedrez, desde cualquier posición,
según una direccion y el número de pasos a avanzar
Pre:
Reeborg debe mirar al norte y esta en la posicion (2,1)
Reeborg recibe el parametro de direccion siendo
direccion = 1 = --|
dire... | false |
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 |
7b071815a5785d809e38d2a4d64c1199c8c9b250 | xlxmht/DS | /Sorting/bubblesort.py | 450 | 4.3125 | 4 | def bubble_sort(arr):
is_swapped = True
while is_swapped:
is_swapped = False
for i in range(len(arr) - 1):
if arr[i] > arr[i + 1]:
swap(i, i + 1, arr)
is_swapped = True
return arr
def swap(i, j, arr):
arr[i], arr[j] = arr[j], arr[i]
retur... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.