Each student needs a notebook and a pen.
Write a function that takes number of students, students, price of notebook, notebook_price,
and price of pen, pen_price, and returns total cost for the entire class. Example:
>>> total_cost(10, 1, 0.5)
15.0
>>> total_cost(20, 1, 2)
60
Write a function that takes three numbers as arguments and return their average.
Example:
>>> average(10, 20, 30)
20.0
>>> calculate(5, 5, 20)
15.0
Write a function that takes two numbers: the total bill, total,
and the number of people, people.
Calculate and print how much each person should pay. Bill should be split equally
A printer prints 8 pages per minute. You have 3 printers running at the same time.
Write a function that takes one argument, pages, and returns number of minutes
it takes to print pages. Example:
>>> time_to_print(240)
10.0
>>> time_to_print(300)
12.5
At the art store, you buy 3 sketchbooks at $7.40 each. If there's a "Buy 2, get 1 half off" deal, how much do you pay in total?
At The Shebang Shop, there's a special discount. You can get it if you're a farmer and have spent at
least 25$, or if you've spent over $100.
Write a function that takes occupation and total_spent and prints True if the person qualifies for the discount,
and False otherwise. Examples:
>>> check_discount("farmer", 25)
True
>>> check_discount("prime minister", 100)
False
>>> check_discount("developer", 30)
False
>>> check_discount("developer", 101)
True
>>> check_discount("farmer", 10)
False
In Babrruja, there's a rule for who gets invited to the annual birthday party.
The guest must either be a teenager, between 13 and 19 years old (inclusive),
and enjoy video games, or be someone who loves outdoor activities but is 25 years old or younger.
Write a function that checks if a person gets an invite by taking their age and interest.
Print True if they qualify for an invitation, and False otherwise. Examples:
>>> check_invite(14, "video games") True >>> check_invite(21, "outdoor activities") True >>> check_invite(5, "outdoor activities") True >>> check_invite(15, "hiking") False >>> check_invite(21, "video games") False
You're building a wall. Each brick is 20cm tall.
You want to build a wall of a certain height in meters.
Write a function that takes one argument, the height in meters,
and returns how many bricks you need.
Example:
>>> bricks_needed(1)
5.0
>>> time_to_print(3)
15.0
Suppose the cover price of a book is $24.95, but bookstores get a 40% discount. Shipping costs $3 for the first copy and 75 cents for each additional copy. What is the total whole sale cost for 60 copies?
def evaluate(a, b, c):
print(a != b and c > b)
Given the above script, what is printed after the execution of the following expressions?
| evaluate(1, 2, 3): | ||
| evaluate(1, 1, 2): |
Write a function that takes one integer as argument and prints True if it is greater than 100 but not 500, and False otherwise.
Write a function that takes a list of strings and returns sum of length of each string.
Example:
>>> get_length(["You", "talking", "to", "me", "?"])
15
Write a function that takes a dictionary, d, whose keys are numbers and values are strings
and returns a new dictionary by adding 2 to each key and '!' to each value. Example:
>>> add_to_dict({1: 'a', 4: 'jo be'})
{3: 'a!', 6: 'jo be!'}
Write a function that takes two arguments, x and y, and prints True if at least one of them is negative. It prints False otherwise.
def print_name(name):
print(name)
print(name)
def print_number(d):
res = d + d
res
def print_surname(surname):
print_name(surname)
print_name(surname)
print_number(3)
print_surname(5)
In the above script:
| What is the printed value: | ||
| How many times is that value printed: |
def is_less_than_or_equal(a, b):
print(a <= 3)
value1 = 4
value2 = 4
is_less_than_or_equal(value1, value2)
What is printed when we execute the above program?
def print_result(d):
print(d != True)
def evaluate(x, y):
print_result(x >= y or x < 0)
x = -10
y = -1
res = x < 0 or x > 0
evaluate(x, y)
Given the above script:
| What is printed: | ||
| What is the final value of res: |
def evaluate(a, b):
print(not a <= b)
Given the above script, what is the return value of the following expressions?
| evaluate(1, 1): | ||
| evaluate(1, 2): | ||
| evaluate(2, 1): |
def not_equal(s1, s2):
res = s1 != s2
res = 'ani'
not_equal('ani', 'ani')
res = res != 'pse'
What is value of res at the end of the program?
>>> age = 6 >>> school = 13 >>> years = age + school >>> d = years + age >>>
What is value of d at the end of execution of the above program?
flour_per_cake = 200 eggs_per_cake = 3 cakes = 5 total_flour = flour_per_cake * cakes total_eggs = eggs_per_cake * cakes flour_left = 1200 - total_flour eggs_left = 20 - total_eggs print(flour_left) print(eggs_left)
>>>
What is printed after we execute the above program?
def do_smth_twice(a, b):
do_smth(a, a)
do_smth(a, b)
def do_smth(a, b):
print(a + b)
do_smth('ani', 'pse')
What is printed if we execute the above program?
def is_less_than_10(a, b):
print(a <= 10)
a = 10
is_less_than_10(5, a)
What is printed after we execute the above program?