Computer Science
Which of the following creates a tuple?
- t1 = ("a", "b")
- t1 [2]= ("a", "b")
- t1= (5) *2
- None of these
Python Tuples
1 Like
Answer
t1 = ("a", "b")
Reason — The statement t1 = ("a", "b") creates a tuple with two elements: "a" and "b".
Answered By
2 Likes
Related Questions
Which of the following will delete key-value pair for key = "Red" from a dictionary D1 ?
- delete D1("Red")
- del.D1("Red")
- del D1["Red"]
- del D1
What will be the output?
D1 = { "Rahul":56, "Virat":99} print("virat" in D1)- True
- False
- No output
- Error
Assertion (A): Tuple in Python is an ordered and immutable data type.
Reasoning (R): Tuples can contain heterogenous data and permit duplicate values as well.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Consider the given two statements:
Statement 1: t1 = tuple('python')
Statement 2: t1[4] = 'z'Assertion (A): The above code will generate an error.
Reasoning (R): Tuple is immutable by nature.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.