Worksheet 2 - Tuples

 -- Worksheet 2 --

[ Tuples]

(Fill-in-the-blanks and short questions)


Fill-in-the-blanks


1. Tuples are similar to __________, but their values cannot be __________.

 

2. Once a tuple is created, its values stay the same for the rest of the __________.

 

3. A tuple is useful when a program needs to store data that should not be __________.

 

4. One example of data that works well in a tuple is the names of the __________ of the year.

 

5. To declare a tuple, we use __________ brackets.

 

6. The general syntax for declaring a tuple is:

   tupleName = (__________)

 

7. In a tuple, multiple values are separated by a __________.

 

8. Example tuple declaration:

   monthsOfYear = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "July", "Aug", "Sep", "Oct", "Nov", "Dec")

   This tuple contains __________ values.

 

9. We access individual values in a tuple using their __________.

 

10. The value of monthsOfYear[0] is __________.

 

11. The value of monthsOfYear[-1] is __________.


 

Short questions


1. What is one main difference between a tuple and a list in Python?

______________________________________________________________________________


2. Why are tuples useful for storing the names of the months of the year?

______________________________________________________________________________


3. What type of brackets are used when declaring a tuple?

______________________________________________________________________________


4. Write the general syntax used to declare a tuple.

______________________________________________________________________________


5. How are multiple values separated when creating a tuple?

______________________________________________________________________________


6. What is the name of the example tuple that stores the months of the year?

______________________________________________________________________________


7. How do you access individual values in a tuple?

______________________________________________________________________________


8. What value is stored at index 0 in the monthsOfYear tuple?

______________________________________________________________________________


9. What value is stored at index -1 in the monthsOfYear tuple?

______________________________________________________________________________


No comments:

Post a Comment