Syntax of tuples

  • Write a sentence or a piece of code to assign to the variable t the following value:

  1. a tuple with 3 elements: True, 3.14 and ‘Hello’

  2. the empty tuple ()

  3. a tuple with a single element, integer 3

  4. a tuple formed with the list of the 100 integers from 0 to 99, the boolean False, all the lowercase letters of the alphabet.

  • Le’s variable t be a tuple with value (2, 3, 4, 5). Write a sentence or a piece of code to modify its value so that, after the execution, it will contain the following value:

  1. (2, 3, 4)

  2. (2, 3, 4, 5, 6, 7)

  3. (2, 3, 4, 5, (2, 3, 4, 5))

  4. ((2, 3, 4, 5), (2, 3, 4, 5))

  5. ((2, 3), (4, 5))

  • Write a sentence that converts a list into a tuple having the same elements.

  • Write a sentence that converts a tuple into a list having the same elements.

  • Write a sentence that from a tuple yields another tuple with equal contents except the last element.

  • Write a sentence that from a tuple yields another tuple with equal contents except the first element.

  • Write a sentence that from a string yields a tuple formed by each one of the characters of the string

  • Write a sentence that from a tuple such that all its elements are caràcters, obtains a string with the same elements of the tuple and in the same order.