Define a function, temp_feel, that takes one number, temp,
and:
- It returns "cold" if temp is lower or equal to 10.
- It returns "cool" if temp is between 10 and 20 (including 20).
- It returns "warm" if temp is between 20 and 30 (including 30).
- It returns "hot" if temp is greater than 30.
Write a function, that takes one numbers as argument, and returns True if it is divisible by 5 but not divisible by 10, False otherwise.
Write a function, that takes one integer, minutes, and prints full hours and remaining minutes.
Example:
>>> divtime(105)
1 40
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
Write a function named sub that takes two numbers as arguments, a abd b, and returns a minus b.
Write a function named multiply that takes two numbers as arguments, and returns their product.
Call sub and assign its return value to s1
Call sub again and assign its return value to s2
Call multiply passing s1 and s2 as arguments
Define a function, can_vote, that takes one integer and one string, age and citizenship,
and returns:
- "eligible" if age is 18 or older and citizenship is "yes"
- "too young" if age is less than 18
- "not a citizen" if citizenship is not "yes"
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)
Given the above script:
| What is printed: | ||
| What is the final value of d: |
def calculate(a, b):
if a == 'first' and b < 0:
return b + b
elif a != 'first' and b > 0:
return b * 2
return b
Given the above script, what are the results of the following calls:
| calculate('second', 1): | ||
| calculate('second', -1): | ||
| calculate('first', 1): |
Complete execution flow of the following program
def rect_area(l, w): return l * w def square_area(s): return rect_area(s, s) a = square_area(5) print(a)
Complete execution flow of the following program
def calculate(): sub() sub() def sub(): a = 50 b = a - 40 print(b) calculate()
10 10 >>>