Write a function is_positive, that takes a number and returns True if it is positive, or False otherwise.
Write a function describe_number, that takes a number and returns "Positive" if it is positive,
or "Non-positive" otherwise.
Restriction: You CANNOT use any relational operator inside this function's body
(<, >, !=, ...).
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, shout_down, that takes a positive integer, n,
and prints all numbers between n and 1 (inclusive), each in a new line.
Print "BOOM!" after the loop.
Example:
>>> shout_down(3)
3
2
1
BOOM!
Restriction: You cannot use for or if.
Write a function that takes an integer as argument and:
- It returns 'positive' if it is positive
- It returns 'negative' if it is negative
- It returns 'neutral' if it is 0
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.
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
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 add(n, m):
total = 0
while True:
if total == 100:
break
total = total + n + m
return total
res = add(20, 30)
Given the above script:
| What is the value of res: |
Complete execution flow of the following program
v = 'a' n = 10 if v == 'b': n = n + n elif n == 10: n = n + 5 if v == 'a': n = n + 5
>>> n 20 >>>
Complete execution flow of the following program
def compare(a): print_arg(a == 0 or a == 1) print_arg(a < 0 or a > 10) def print_arg(x): print(x) compare(4)
False False >>>