Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4. Tuples resemble lists in many ways. However, as an immutable type, the ways i

ID: 3775507 • Letter: 4

Question

4. Tuples resemble lists in many ways. However, as an immutable type, the ways in which they can be interacted with are limited. Take the following statements. What will happen if you try to add to the tuple in the manner shown? How can you rewrite the code to achieve the intended result?

tuple_var = ()

for i in range (10) :

tuple_var += i

9. Write a function power that takes in a base and an exp and recursively computes base*exp. You are not allowed to use the ** operator.

10. Provide two small numbers for base and exp in function power, and draw the figure to trace the recursive function calls.

Explanation / Answer

4. It will show type error

Code :

tuple_var = ()

for i in range (10) :
   tuple_var += (i,)
print tuple_var

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote