Write a python program that: - Defines a tuple of 5 integer numbers - prints the tuple - Appends a new value to the end of the tuple - prints the tuple again Please note that appending a new value to a tuple will change the tuple. However, as you learned in Unit 5, tuples are immutable i.e. do not change. Therefore, to solve this problem, you need to find a way to change a tuple.

Respuesta :

Answer:

The program is as follows:

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

print(my_tuple)

mylist = list(my_tuple)

mylist.append(6)

my_tuple = tuple(mylist)

print(my_tuple)

Explanation:

This defines a tuple of 5 integers

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

This prints the tuple

print(my_tuple)

To add new element to the tuple; First, we convert it to list. This is done below

mylist = list(my_tuple)

Then, an item is appended to the list

mylist.append(6)

The list is then converted to tuple

my_tuple = tuple(mylist)

This prints the tuple

print(my_tuple)

ACCESS MORE