complete solution 2025
What is a (univariate) function f(x) in mathematics? (Lecture 1) - correct
answers a function of a single variable; distance is a function of time
n!=# of ____ of a list of length n (Lecture 17) - correct answers permutations
What is a variable x in mathematics? (Lecture 1) - correct answers a value
that may change; an abstraction/generalisation
What are the 2 key components of a recursive function? (Lecture 17) - correct
answers base case and recursive call
What is the precedence of the basic arithmetic operators? (Lecture 1) - correct
answers when there is more than one arithmetic operator in an expression:
multiplication, division, and modulo are calculated first, followed by subtraction
and addition. If they have the same level of precedence, it is executed left to
right.
What is the base case for string reversal? (Lecture 17) - correct answers bc:
base case
t='' ###bc
for c in s:
t=c+t
return t
,How do you express 4√3 in Python interpreter? (Lecture 1) - correct answers
import math
4*math.sqrt(3)
answer: 6.928203230275509
What is the base case of sum(n)? (Lecture 17) - correct answers bc: base
case
assert n >= 1
if n == 1: ###bc
return 1
else:
return n + sum (n-1)
How do you express 2/3π? Without parentheses? (Lecture 1) - correct
answers 2*π/3
What is the base case of lint(L)? (Lecture 17) - correct answers bc: base case
rc: recursive call
if L == []: ###bc 1
return True
elif type(L[0]) != int: ###bc 2
, return False
else: ###rc
return lint(L[1:])
What are the acceptable resources for coding? (Lecture 2) - correct answers
official Python documentation
What is the base case and recursive call of argmax(L)? (Lecture 17) - correct
answers bc: base case
rc: recursive call
assert len(L) > 0
if len(L) == 1: ###bc
return 0
else: ###rc
imax = argmax (L[:len(L)-1])
if L[-1] > L[imax]:
imax = len(L) - 1
return imax
What are the standard arithmetic operators (6 of them)? - correct answers
addition (+), subtraction (-), multiplication (*), division (/), exponentiation (**),
modulo (%), floor division (//)
Explain stacking (push and pop). (Lecture 18) - correct answers last-in-first-
out (LIFO)