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
ⓘ
Write a function, that takes one integer, minutes, and prints full hours and remaining minutes.
Example:
>>> divtime(105)
1 40
ⓘ
def print_sum(a, b): print(a + b) result = print_sum(30, 400) print(result)
In the above script:
What is value of result: | |
What is the first printed value: | |
What is the second printed value: |
Write a function that takes one integer as argument, n and prints numbers from 0 to n (including 0 but not n), each in a new line.
ⓘ
def calculate(attendance, grade): total = grade * 0.8 + attendance * 0.2 passes(total) def passes(total): print(total > 6.0)
What is printed if we execute calculate(10, 10)
What is printed if we execute calculate(10, 5)
What is printed if we execute passes(6.01)
Write a function named my_prod that takes two integers, n and m,
and returns (n-m) * (n+m).
Restrictions:
- You cannot use - and + inside my_prod body
- You should use add and sub inside my_prod for calculating difference and sum of n and m respectively.
ⓘ
def calculate(x, y, z): print(x + y - z) def call_function(a, b): calculate(a, b, a) print(a - b) call_function(3 - 1, 2 + 2)
What is printed after we execute the above script? Write the values in the order that they are printed.
Define a function, concatenate, which takes two strings, s1 and s2,
and returns their concatenation. Example:
>>> concatenate('ani', 'pse')
'anipse'
Define a function, print_chars, which takes two strings, s1 and s2,
and using only one for loop it prints all the characters of s1 and s2,
each in a new line, in the order that they appear. Example:
>>> print_chars('ab', 'cd')
a
b
c
d
>>>
Restrictions:
- You should use exactly one for
- You cannot use +
ⓘ
Write a function that takes a driver's speed speed and a boolean is_birthday.
Return:
- 0 for no ticket if speed <= 60 (or 65 on birthday)
- 1 for small ticket if speed <= 80 (or 85 on birthday)
- 2 for big ticket otherwise
Example:
>>> ticket(64, True)
0
>>> ticket(64, False)
1
ⓘ
Write a function is_adult, that takes an integer, age, and returns True if it is greater than or equal to 18, or False otherwise.
Write a function is_registered, that takes a string, code, and returns True if code is "ADMIN" or "USER", and False otherwise.
Write a function access, that takes an integer and a string, age and code,
and:
- It returns "No access" if age is less than 18 and code is not "ADMIN" or "USER"
- It returns "Partial" if age is greater than or equal to 18 or code is "ADMIN" or "USER"
- It returns "Full" if age is greater than or equal to 18 and code is "ADMIN" or "USER"
Restriction: You CANNOT use any relational operator inside this function's body
(<, >, !=, ...).
ⓘ