Write a function that takes a value as argument and using a for loop it prints it 3 times, one per line.
ⓘ
Write a function is_even, that takes a number and returns True if it is even, or False otherwise.
Write a function even_or_odd_message, that takes a number and returns "Even" if it is even,
or "Odd" if it is odd.
Restriction: You CANNOT modulus (%) inside this function's body.
ⓘ
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
ⓘ
Define a function, fruit_color, that takes one string, fruit,
and:
- It returns "red" if fruit is "apple".
- It returns "yellow" if fruit is "banana".
- It returns "orange" if fruit is "orange".
- It returns "unknown" otherwise.
ⓘ
def add(a, b): print(a + b ** b) def sub(x, y): print(x - y) add(x + x, x + y) sub(1, 2)
Write the printed values, in order, after the execution of the above script?
Write a function that takes two numbers, a and b, and:
- It prints 'a is lower than b' if a is lower than b.
- It prints 'a is greater than b' if a is greater than b.
- It prints 'a is equal to b' otherwise.
ⓘ
def power(n): total = 0 while True: total = total + n print('pse') break return total print('ani') res = power(10)
Given the above script:
What is the value of res: | |
What is the printed value: |
def add(n): total = 10 for num in range(n): total = total + 2 return total
Given the above script, what are the results of the following expressions:
add(1): | |
add(2): | |
add(5): |
Complete execution flow of the following program
def pow(a, b): print(a ** b - b) def calculate(x, y): pow(x + y, x - y) a = 3 calculate(a, 2)
4 >>>
Complete execution flow of the following program
def do_smth(): return 3 def add(a): return a + a res = add(do_smth() * do_smth())
>>>