Skip to content
Worked Examples · Example 5.5

Q.Example 5.5:
#create a tuple tuple1
tuple1 = (10, 20, "Apple", 3.4, 'a')
#print the elements of the tuple tuple1
print(tuple1)
(10, 20, "Apple", 3.4, 'a')

West Bengal WbchseTextbookSubjective· 2mImportance★★★★★est
18% · 9/49 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

A tuple is an ordered, immutable, mixed-type sequence in parentheses; printing tuple1 gives (10, 20, 'Apple', 3.4, 'a') — Python shows strings in single quotes, a small departure from the book's printed output.

The concept is the tuple data type: like a list it is ordered, indexable and can hold mixed types — but it is immutable, meaning once created its elements can never be replaced, added or removed. Tuples are the right container for data that must not change (coordinates, a date, a record).

#create a tuple tuple1
>>> tuple1 = (10, 20, "Apple", 3.4, 'a')
#print the elements of the tuple tuple1
>>> print(tuple1)
(10, 20, 'Apple', 3.4, 'a')

The contents:

IndexElementType
010int
120int
2'Apple'str
33.4float
4'a'str (a single character is just a string of length 1)

A faithfulness note on the output: the textbook shows the echo as (10, 20, "Apple", 3.4, 'a') — with double quotes around Apple. Running the code, Python actually prints all strings in its canonical single-quote form: (10, 20, 'Apple', 3.4, 'a'). The values are identical; only the quote style in the display differs. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.