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?
An online store charges shipping based on the order total:
- Orders under $20 have a $5 fee.
- Orders between $20 and $50 (including both) have a $3 fee.
- Orders over $50 have free shipping.
Write a function that takes the order total amount and returns the shipping fee for it.
ⓘ
Define a function named print_smth, which prints Shnete e pranvere!.
Call print_smth.
Define a function named repeat_smth, which calls print_smth once.
Call repeat_smth.
ⓘ
Write a function that takes a string and returns number of characters.
Example:
>>> count('a')
1
>>> count('11')
2
>>> count('pse')
3
Restriction: You CANNOT use len.
ⓘ
Write a function that takes no arguments and prints numbers from 0 to 100 (including both), each in a new line.
ⓘ
Define a function, number_type, that takes one number, n, and returns:
- "even and positive" if n is even and positive
- "odd" if n is odd
ⓘ
def sub(m, n): for i in range(n): m = m - 3 return m
Given the above script, what are the results of the following expressions:
sub(10, 1): | |
sub(20, 2): | |
sub(9, 3): |
def accepted(level, evaluation): print((level == "senior" and evaluation > 8.0) or evaluation > 6.5) def evaluate(level, logic, syntax, communication): evaluation = (logic + syntax + communication) / 3 accepted(level, evaluation) print(evaluation) evaluate("senior", 7.0, 10.0, 1.0)
After the execution of the above program two values are printed. Write those values in the order that they are printed.
1: | |
2: |
Complete execution flow of the following program
def countup(n): while n < 0: print(n) n = n + 1 print('Blastoff!') res = countup(-3) print(res)
-3 -2 -1 'Blastoff!' None >>>
Complete execution flow of the following program
x = 0 y = -1 if x > 0: if y > 0: print("first") elif y == 0: print("second") else: print("third") elif x == 0: if y > 0: print("fourth") elif y == 0: print("fifth") else: print("sixth") else: if y > 0: print("seventh") elif y == 0: print("eighth") else: print("ninth") print("Finish")
"sixth" "Finish" >>>