Computer Science
Write the output of the following statements:
(a) >>> tuple([10,20,40])
(b) >>> ("Tea",)*5
(c) >>> tuple ("Item")
Python Tuples
1 Like
Answer
(a)
Output
(10, 20, 40)
(b)
Output
('Tea', 'Tea', 'Tea', 'Tea', 'Tea')
(c)
Output
('I', 't', 'e', 'm')
Answered By
1 Like
Related Questions
Consider the following code and find out the error:
T1 = (10, 20, 30, 40) T2 = (40, 50, 60) T1, T2, T3 = T1, T2t1 = (100, 200, "Global", 3, 3.5, "Exam", [1, 2], (30, 40), (3, 5, 3)) :
Consider the above tuple 't1' and answer the following questions:
(a) len(t1)
(b) 20 not in t1
(c) t1[-8:-4]
(d) t1[5:]
(e) t1.index(5)
(f) t1.index(3, 6)
(g) 10 in t1
(h) t1.count(3)
(i) any(t1)
(j) t1[2]*2
Consider two tuples t1 & t2 given below:
t1 = (100, 200, 300) t2 = (10, 20, 30, 40)Write the output of the following statements:
(a)
t1, t2 = t2, t1 print(t1) print (t2)(b)
print (t1!=t2)(c)
print (t1 < t2)WAP to accept values from a user. Add a tuple to it and display its elements one by one. Also display its maximum and minimum value.