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 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
(<, >, !=, ...).
Define a function named shtyp_tekstin, which prints Shndet prej mejet te m'i falesh.
Call shtyp_tekstin.
Define a function named perserit_tekstin, which calls shtyp_tekstin three times.
Call perserit_tekstin.
Write a function that takes no arguments and prints numbers from 0 to 100 (including both), each in a new line.
At Pupci Academy, employees get a bonus if they meet certain conditions.
If an employee has been at the company for more than 3 years and completed more than 5 projects,
or if they've completed at least 2 projects and their performance rating is higher than 4.0, they receive a bonus.
Write a function that has checks eligibility based on years at company (years), projects completed (projects),
and performance rating (rating). Print True if they qualify for the bonus, and False otherwise. Examples:
>>> check_bonus(years=4, projects=6, rating=1.0) True >>> check_bonus(years=1, projects=2, rating=4.1) True >>> check_bonus(years=3, projects=5, rating=4.0) False
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.
def while_sum(a, b):
i = 0
while i < a + b:
i = i + b
return i
Given the above script, what is the printed value of the following expressions:
| print(while_sum(1, 1)): |
def divide(n):
while True:
break
n = n / 2
print('done')
print('DONE')
return n
res = divide(4)
Given the above script:
| What is the value of res: | ||
| What is the printed value: |
Complete execution flow of the following program
def calculate(a, b): if a == 'first' and b < 0: return b + b elif a != 'first' and b > 0: return b * 2 return b
>>> calculate("third", 3) 6 >>> calculate('first', 4) 4 >>>
Complete execution flow of the following program
def print_name(name): print(name) print(name) def print_number(d): res = d + d res def print_surname(surname): print_name(surname) print_name(surname) print_number(3) print_surname(5)
5 5 5 5 >>>