Tuples in Python

Beschreibung

Coding Python Quiz am Tuples in Python, erstellt von PathaPadha Support am 27/10/2020.
PathaPadha Support
Quiz von PathaPadha Support, aktualisiert more than 1 year ago
PathaPadha Support
Erstellt von PathaPadha Support vor etwa 4 Jahre
384
0

Zusammenfassung der Ressource

Frage 1

Frage
What is the output of the following ? tuple1 = (1120, 'a') print(max(tuple1))
Antworten
  • TypeError
  • 1120
  • ‘a’

Frage 2

Frage
What is the output of the following tuple operation ? aTuple = (100,) print(aTuple * 2)
Antworten
  • TypeError
  • (100, 100)
  • (200)

Frage 3

Frage
Select true statements regarding the Python tuple
Antworten
  • We can remove the item from tuple but we cannot update items of the tuple
  • We cannot delete the tuple
  • We cannot remove the items from the tuple
  • We cannot update items of the tuple.

Frage 4

Frage
What is the output of the following tuple operation ? aTuple = (100, 200, 300, 400, 500) aTuple.pop(2) print(aTuple)
Antworten
  • (100, 200, 400, 500)
  • (100, 300, 400, 500)
  • AttributeError

Frage 5

Frage
Select which is true for Python tuple
Antworten
  • A tuple maintains the order of items
  • We can change the tuple once created
  • We cannot change the tuple once created
  • A tuple is unordered

Frage 6

Frage
A Python tuple can also be created without using parentheses
Antworten
  • True
  • False

Frage 7

Frage
Choose the correct way to access value 20 from the following tuple aTuple = ("Orange", [10, 20, 30], (5, 15, 25))
Antworten
  • aTuple[1:2][1]
  • aTuple[1:2](1)
  • aTuple[1:2][0]
  • aTuple[1][1]

Frage 8

Frage
What is the output of the following code ? aTuple = (100, 200, 300, 400, 500) aTuple[1] = 800 print(aTuple)
Antworten
  • TypeError
  • (100, 800, 200, 300, 400, 500)
  • (800, 100, 200, 300, 400, 500)

Frage 9

Frage
What is the output of the following ? aTuple = (10, 20, 30, 40, 50, 60, 70, 80) print(aTuple[2:5], aTuple[:4], aTuple[3:])
Antworten
  • (30, 40, 50) (10, 20, 30, 40) (40, 50, 60, 70, 80)
  • (20, 30, 40, 50) (10, 20, 30, 40) (30, 40, 50, 60, 70, 80)
  • (30, 40, 50) (10, 20, 30, 40) (40, 50, 60, 70)
  • (30, 40, 50) (10, 20, 30) (40, 50, 60, 70, 80)

Frage 10

Frage
What is the type of the following variable ? aTuple = ("Orange") print(type(aTuple))
Antworten
  • list
  • tuple
  • array
  • str

Frage 11

Frage
What is the output of the following code ? aTuple = (100, 200, 300, 400, 500) print(aTuple[-2]) print(aTuple[-4:-1])
Antworten
  • 400 (200, 300, 400)
  • IndexError: tuple index out of range
  • 400 (200, 300)

Frage 12

Frage
What is the output of the following ? aTuple = "Yellow", 20, "Red" a, b, c = aTuple print(a)
Antworten
  • (‘Yellow’, 20, ‘Red’)
  • TyepeError
  • Yellow
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Python Quiz
karljmurphy
Think Python
tsilvo2001
Basic Python - Print Formatting
Rebecca Noel
What is Python?
Daniel Ingram
Python
54671
Know your Python!
educ8ict
Basic Python - Strings
Rebecca Noel
Study on IoT systems design
Tomasz Cieplak
Python
Kirstie Wu
OpenSource Programming
Faheem Ahmed
Basic Python - Lists
Rebecca Noel