HW 1
Homework 1 - aimed at getting familiar with Python language. Not too difficult, for someone with programming experience.
Q1: A Plus Abs B
from operator import add, sub
def a_plus_abs_b(a, b):
"""Return a+abs(b), but without calling abs.
>>> a_plus_abs_b(2, 3)
5
>>> a_plus_abs_b(2, -3)
5
"""
if b < 0:
f = _____
else:
f = _____
return f(a, b)Q1 - Solution
Q2: Two of Three
Q2 - Solution
Q3: Largest Factor
Q3 - Solution
Q4: If Function vs Statement
Q4 - Solution
Q5: Hailstone
Q5 - Solution
Last updated