Practice Recursion Questions – In the following function, what is the base case?
def xfunction(n):
if n == 1:
return1
else
return n + xfunction(n – 1)
Practice Recursion Questions – In the following function, what is the base case?
def xfunction(n):
if n == 1:
return1
else
return n + xfunction(n – 1)
Practice Tuples Questions – Suppose t = (1, 2), 2 * t is _________.
Practice Input-output Questions – To format a number x to 3 digits after the decimal point, use _______.
Practice Functions Programming – A variable defined outside a function is referred to as __________.
Practice Functions Programming – __________ is a simple but incomplete version of a function.
Practice Inheritance Questions – Analyze the following code:
class A:
def __init__(self, i = 0):
self.i = i
class B(A):
def __init__(self, j = 0):
self.j = j
def main():
b = B()
print(b.i)
print(b.j)
main()
Practice Python Dictionary Questions – What will be displayed by the following code?
d = {“john”:40, “peter”:45}
print(list(d.keys()))
Practice Web Scraping Questions – _____________ opens a URL for input.
Practice Functions Programming – If a function does not return a value, by default, it returns ___________.
Practice Python Basics Questions – ________ is interpreted.
Practice Relational Operators – What is y after the following statement is executed?
x = 0
y = 10 if x > 0 else –10