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 miles are there in 10 kilometers?
Hint: there are 1.61 kilometers in a mile.
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
At Traukni School, students can join the school's sports team if they meet the criteria.
To join, a student must have a GPA greater than 3.5 and be part of the track team,
or they must be in the top 10% of their class academically.
Write a function that takes student's gpa: float, track_team: bool and top_10_percent: bool and prints True
if they qualify, and False otherwise.. Examples:
>>> check_sports_team(gpa=3.6, track_team=True, top_10_percent=False) True >>> check_sports_team(gpa=3.5, track_team=True, top_10_percent=True) True >>> check_sports_team(gpa=3.5, track_team=False, top_10_percent=False) False >>> check_sports_team(gpa=2.6, track_team=True, top_10_percent=False) False
A company is building highways.
One worker can complete 0.5 kilometers per day.
Write a function that takes the total distance in kilometers, km,
and the number of days until the deadline, days,
and prints how many workers are needed to complete the highway on time.
In the city of Babrruja, people who apply for housing loans need to meet specific criteria.
If they have an income greater than $50,000 per year and are between 25 and 40 years old (inclusive),
they qualify for the loan.
Alternatively, if they are over 40 but have a savings account with at least $100,000, they may also be eligible.
Write a function that takes income, age, and savings and prints True if the person qualifies for a loan,
and False otherwise.
>>> check_loan_approval(income=50000, age=30, savings=110000) False >>> check_loan_approval(income=50001, age=30, savings=110000) True >>> check_loan_approval(income=3000, age=40, savings=110000) False >>> check_loan_approval(income=3000, age=41, savings=110000) True
In Shawshank Library, there's a rule for borrowing books: members can borrow up to 5 books
if they are between 18 and 65 years old (inclusive), or if they're under 18 and have at least one book about
history in their collection.
Write a function that takes age and history_books_count and prints True if the person can borrow books,
and False otherwise. Examples:
>>> can_borrow_books(age=18, history_books_count=0) True >>> can_borrow_books(age=17, history_books_count=1) True >>> can_borrow_books(age=16, history_books_count=0) False >>> can_borrow_books(age=67, history_books_count=3) False
How many centimeters are there in 13 meters and 45 centimeters?
You buy 3 pencils for $0.50 each, 2 notebooks for $2.25 each, and a backpack for $35. If you pay with a $50 bill, how much change will you get?
>>> value = 4.5 >>> n = 2 >>> d = value * n >>> res = d / (n + 1) >>>
What is value of res in the end of execution of the above program?
Write a function that takes a list of integers and adds 34 to each element of it.
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)
Given the above script:
| What is printed: | ||
| What is the final value of d: |
Write a function that takes one integer as argument and prints False if it is 10 or 100, and True otherwise.
Write a function that takes three arguments, x, y and z, and prints True if x is negative, y is 0 and z is positive, or False otherwise.
def print_bool(x, y, z):
x = x == y == z
print(x)
x = 10
y = 20
z = 30
x = x < y < z
print_bool(y, y, y)
At the end of the above program execution, what is printed and what is final result of x?
| Printed value: | ||
| x: |
def print_value():
print('value')
def do_smth():
print("do smth")
print("do smth")
def repeat_value():
print('key')
repeat_value()
Write the printed value after the execution of the above 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?
def print_result(a, b):
print(not a < b)
a = 2
b = 10
res = a ** 3
print_result(res, a)
What is printed if we execute the above program?
| What is printed: | ||
| What is the final value of res: |
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 is_greater(s1, s2):
res = s1 >= s2
print(res)
res = 10
is_greater(res, res)
What is printed when we execute the above program?
def less_than(x, y):
true = not x < y
print(true)
def check(x, y, z):
x = x + y
less_than(x, z)
check(1, 2, 4)
What is printed if we execute the above program?
def is_less_than(a, b):
print(a < 4)
value1 = 6
value2 = 7
is_less_than(value1, value2)
What is printed when we execute the above program?
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?