There was no class on Sunday last week so there is no recording for that day.
Homework:
Use recursion to determine the nth term of an arithmetic series. Parameters: starting term, common difference, n. The formula for the nth term is a_n=a_(n-1)+d.
Write a lambda that checks if a tuple of integers is a square. Then apply map() and print out the list result. (Hint: one approach is to use math.sqrt()).
Resources:
Slides: https://docs.google.com/presentation/d/1geOoU09YAzWQuYqReMEQ-y8erSqyeew6ESyH28_RRD0/edit?usp=sharing
Class code: https://replit.com/join/lqjxuqxbqy-shravyas
You can always email us at shravyassathish@gmail.com (mentor) or kingericwu@gmail.com (TA) or message us on Discord if you have any questions about the homework or what we covered in class.
# homework 1
def arithmetic(start, d, n):
if n==1:
return start
else:
return arithmetic(start, d, n-1)+d
print(arithmetic(1,3,3))
# homework 2
import math
tuple1 =(1,2,4,5,9,100,24,49,50)
l1 =list(map(lambda x: math.sqrt(x).is_integer(), tuple1))
print(tuple1)
print(l1)