Question: What is the difference between lists and tuples? What are some similarities? Consider the following program segment: a = 5 b = 10 temp =

What is the difference between lists and tuples? What are some similarities?

Consider the following program segment:

a = 5

b = 10

temp = a

a = b

b = temp

print(a,b)

What is printed at line 6? How could you use tuples to do this without the temp variable?

Write a function split_name() which accepts a string full_name as a parameter and returns a tuple containing the first and last name as two separate strings. Demonstrate your function by calling it with a suitable argument.

Write a function sum_all() which accepts any number of integer and/or float parameters and returns their sum. Demonstrate your function.

Consider a list of tuples which represents a students grades on a sequence of homework assignments:

grades = [('Homework 1', 95), ('Homework 2', 100), ('Homework 3', 90)]

Write a for-loop which traverses and prints the contents of each tuple in the list grades.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!