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)

def recursionSequence(n, d):

x = 0

nthTerm = x + d

for i in range(n):

nthTerm += nthTerm

nthTerm += d

x += nthTerm

return nthTerm

tuple1 = (1, 2, 3, 4, 5)

import math

print(list(map(lambda x : math.sqrt(x) == int(math.sqrt(x)), tuple1)))

import math

Part 1:def term(start, diff, nTerm, nTerm2):

nTerm = start + diff*(nTerm-1)

return f"Term #{nTerm2} of the arithmetic series with first term {start} and common difference {diff}: {nTerm}"

print(term(1, 2, 3, 3))

Part 2:tuple = (1, 9, 4, 16, 15, 13, 54, 16, 257, 322, 64, 987)

print(list(map(lambda i : int(math.sqrt(i)) == math.sqrt(i), tuple)))