gs gs109 Python Tuples - Python Tuples - Quiz No.2
gs gs109 Python Quiz
This quiz belongs to book/course code gs gs109 Python of gs organization. We have 134 quizzes available related to the book/course Python. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Python Tuples. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: What is the data type of (1)?
Tuple
Integer
List
Both tuple and integer
Question 2: If a=(1,2,3,4), a[1:-1] is _________
Error, tuple slicing doesn’t exist
[2,3]
(2,3,4)
(2,3)
Question 3: What will be the output of the following Python code?
>>> a=(1,2,(4,5)) >>> b=(1,2,(3,4)) >>> a<b
False
True
Error, < operator is not valid for tuples
Error, < operator is valid for tuples but not if there are sub-tuples
Question 4: What will be the output of the following Python code?
>>> a=("Check")*3 >>> a
(‘Check’,’Check’,’Check’)
* Operator not valid for tuples
(‘CheckCheckCheck’)
Syntax error
Question 5: What will be the output of the following Python code?
>>> a=(1,2,3,4) >>> del(a[2])
Now, a=(1,2,4)
Now, a=(1,3,4)
Now a=(3,4)
Error as tuple is immutable
Question 6: What will be the output of the following Python code?
>>> a=(2,3,4) >>> sum(a,3)
Too many arguments for sum() method
The method sum() doesn’t exist for tuples
12
9
Question 7: Is the following Python code valid?
>>> a=(1,2,3,4) >>> del a
No because tuple is immutable
Yes, first element in the tuple is deleted
Yes, the entire tuple is deleted
No, invalid syntax for del method
Question 8: What type of data is: a=[(1,1),(2,4),(3,9)]?
Array of tuples
List of tuples
Tuples of lists
Invalid type
Question 9: What will be the output of the following Python code?
>>> a=(0,1,2,3,4) >>> b=slice(0,2) >>> a[b]
Invalid syntax for slicing
[0,2]
(0,1)
(0,2)
Question 10: Is the following Python code valid?
>>> a=(1,2,3) >>> b=('A','B','C') >>> c=tuple(zip(a,b))
Yes, c will be ((1, 'A'), (2, 'B'), (3, 'C'))
Yes, c will be ((1,2,3),(‘A’,’B’,’C’))
No because tuples are immutable
No because the syntax for zip function isn’t valid