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, that takes one numbers as argument, and returns True if it is divisible by 3 or 4, False otherwise.
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.
Write a function that takes a string and using a for loop
it returns 3 times length of the string.
Example:
>>> multiply('a')
3
>>> multiply('aa')
6
>>> multiply('aaa')
9
Restriction: You CANNOT use * or len.
Write a function, countup, that takes one positive integer, n,
and prints numbers from 1 up to and including n, one per line.
End with printing "Done!".
Example:
>>> countup(3)
1
2
3
Done!
Restriction: You cannot use for or if.
Write a function named prod that takes three integers as arguments, and returns their product.
Write a function named sum that takes three integers as arguments, and returns their sum.
Call prod and assign its return value to p
Call sum and assign its return value to s
Raise p to the power of s and print the result
def calculate(a, b): p = prod(a, b) d = diff(a, b) res = p + d return res def prod(x, y): res = x * y return res def diff(x, y): d = x - y return d c = calculate(5, 3)
In the above script what is value of c:
def power(a): while True: a = a ** 2 if a > 100: break return a res = power(2)
Given the above script:
What is the value of res: |
Complete execution flow of the following program
def print_sum_and_diff(x, y): print(x + y) print(x - y) print(print_sum_and_diff(5, 2))
Complete execution flow of the following program
def dosmth(num, string): for s in string: num = num + 1 return num def dosmth2(string): v = 2 for char in string: v = v * 2 return v d = dosmth2('ab') - dosmth(3, 'ab')