Question
1. Write a function plus_student_id(n) that adds your coyote id to n. Hint: Python most likely will reject a number with multiple leading zeros. If
1. Write a function plus_student_id(n) that adds your coyote id to n. Hint: Python most likely will reject a number with multiple leading zeros. If you define a term similar to
my_student_id = int('000012345') then my_student_id will be a proper integer.
2. Write a function cube(n) that finds the n_th cube. Is this a closed formula or recursive?
3. Write a recursive function that finds the sum of the first n squares, 1^2 +2^2 + ... + n^2
4. include the following code, with my_student_id set as above:
import random random.seed(my_student_id) a = random.randint(1,10) b = random.randint(1,10)
then define a recurseive function g(n) that returns:
a if n=1 b if n=2
g(n-1)+g(n-2) if n > 2.
This is in pyhton.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started