How many centimeters are there in 13 meters and 45 centimeters?
ⓘ
You have to read books, and you want to know for how many days you finish a book.
Write a function that takes two arguments, total_pages and pages_per_day, and returns
number of days you need to finish the book. Example:
>>> calculate(100, 20)
5.0
>>> calculate(150, 20)
7.5
ⓘ
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
ⓘ
How many seconds are in 42 minutes and 42 seconds?
ⓘ
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?
ⓘ
An employer has many employees who work different numbers of hours per day and
receive different payments per hour.
Write a function that takes number of hours, hours, and payment per hour, payment,
and prints the total payment.
ⓘ
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
ⓘ
At Pupci Academy, employees get a bonus if they meet certain conditions.
If an employee has been at the company for more than 3 years and completed more than 5 projects,
or if they've completed at least 2 projects and their performance rating is higher than 4.0, they receive a bonus.
Write a function that has checks eligibility based on years at company (years), projects completed (projects),
and performance rating (rating). Print True if they qualify for the bonus, and False otherwise. Examples:
>>> check_bonus(years=4, projects=6, rating=1.0) True >>> check_bonus(years=1, projects=2, rating=4.1) True >>> check_bonus(years=3, projects=5, rating=4.0) False
ⓘ
Dudije is organizing gift bags for a party. Each gift bag contains:
- 2 pencils (each costs $0.50)
- 1 notebook (costs $2.00)
- 3 candies (each costs $0.25)
She is preparing 60 gift bags.
Calculate the total cost and print it.
ⓘ
How many miles are there in 10 kilometers?
Hint: there are 1.61 kilometers in a mile.
ⓘ
Write a function that takes a dictionary and returns sum of all integers (whether they are
keys or values).
Example:
>>> get_sum({1: 'a', 2: 6, 12: 'po', 'jo': 4})
25
ⓘ
def compare(a, b, c): print(a == b and a < c) x, y, z = 1, 2, 3 d = x == 1 and y == 2 and y < z compare(x, y, -1 * z)
What is printed if we execute the above program?
What is value of d at the end of the execution of the above program?
Write a function that takes three arguments, x, y and z, and prints True if y is greater than x and less than z.
Call it giving three floats.
Call it giving three integers.
ⓘ
Write a function that takes two arguments, a and b, and prints True if both of them are equal to 45.5.
Call it giving two strings.
Call it giving 45.5 and 45.5 as arguments.
ⓘ
def are_equal(a, b): print(a == b) def are_not_equal(a, b): are_equal(a, a) are_not_equal(4, 5)
What is printed if we execute the above program?
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?
def pow(a, b): res = a ** b return res def sum(x, y): res = x + y return res def mp(n, m, p): po = pow(n, m) s = sum(po, p) return s res = mp(1, 2, 3)
In the above script what is value of res:
def print_result(a, b): print(not a > b) a = 10 b = 10 res = a + b print_result(res, a)
What is printed if we execute the above program?
What is value of res at the end of the execution of the above program?
def evaluate(a, b, c, d): print(a > b or c >= d)
What is printed if we execute evaluate(1, 1, 2, 2)
What is printed if we execute evaluate(1, -1, 4, 4.1)
What is printed if we execute evaluate(-10, 10, 8, 9)
def compare(a, b, c): print(a == b or a < c) x, y, z = 1, 2, 3 d = x == 1 or y == 2 or y < z compare(x, y, -1 * z)
What is printed if we execute the above program?
What is value of d at the end of the execution of the above program?
def print_bool(a, b): res = a == b res = a < 10 < b print(res) res = 1 b = 20 print_bool(res, b)
What is printed after we execute the above program?
a = 4 b = 2 c = a ** b print(c)
xx
>>> d = c + 4 * 2
>>>
What is printed and what is value of d at the end of the execution of the above program?
Printed value: | |
d: |
def is_greater(s1, s2): res = s1 > s2 res = 10 is_greater(res, res) print(res)
What is printed when 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?