Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
55 views4 pages

More Tuple Output Class 11

Tuple
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views4 pages

More Tuple Output Class 11

Tuple
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

(1) t1=4

print(type(t1))

output:- <class 'int'>

(2) t1=4,5,6

print(type(t1))

output:- <class 'tuple'>

(3) t1=(1,2,3,4,5,6,7,8)

print(t1)

print(t1*2)

print(t1+t1)

print(len(t1)*2)

output:- (1, 2, 3, 4, 5, 6, 7, 8)

(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8)

(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8)

16

(4) t1=(1,2,3,4,5,6,7,8)

print(t1[0])

print(t1[2+3])

print(t1[4-1])

print(t1[7%2])

output:- 1

(5) t1=(1,2,3,4,5,6,7,8)

print(t1[:])

print(t1[3:])

print(t1[:4])

print(t1[-2:-5])

output:- (1, 2, 3, 4, 5, 6, 7, 8)

(4, 5, 6, 7, 8)

(1, 2, 3, 4)

()
(6) t1=(1,2,3,4,5,6,7,8)

print(t1[1::2])

print(t1[-1:-5:-2])

print(t1[::-1])

print(t1[:7:2])

output:- (2, 4, 6, 8)

(8, 6)

(8, 7, 6, 5, 4, 3, 2, 1)

(1, 3, 5, 7)

(7) t1=(1,2,3,4,5,6,7,8)

print(t1[15])

output:- index error

(8) t1=(45,67,98)

t1=t1+(1,2,3)

print(t1)

output:- (45, 67, 98, 1, 2, 3)

(9) t1=(45,67,98)

t1=t1*3

print(t1)

output:- (45, 67, 98, 45, 67, 98, 45, 67, 98)

(10) t1=(45,67,98)

t2=((45,67,98))

print(t1 in t2)

print(45 in t2)

print(45 in t1)

print(t1 +t2)

output:- False

True

True

(45, 67, 98, 45, 67, 98)


(11) #Write a program to accept five fruit name from the user and store it in a tuple.

b=()

for a in range(5):

n=input("enter name")

b=b+(n,)

print(b)

(12) #T1 = (12, 3, 45, 'Hockey', 'Anil', ('a', 'b'))

#a. Display the first element of 'T1'

#b. Display the last element of 'T1'

#c. Display 'T1' in reverse order.

#d. Display 'Anil' from tuple 'T1'

#e. Display 'b' from tuple 'T1'

 t1 = (12, 3, 45, 'Hockey', 'Anil', ('a', 'b'))

print(t1[0])

print(t1[-1])

print(t1[::-1])

print(t1[4])

print(t1[-1][-1])

(13) #find output:-

for i in tuple("SARADA"):

print(i+i)

=>SS

AA

RR

AA

DD

AA

(14) #Write the output of the following :

T1 = (23, 32, 4, 5, 2, 12, 23, 7, 9, 10, 23)

print(len(T1) + T1[-1])

print(T1[T1.count(23) + len(T1) -5])

print(T1.count(T1[6]))

print(T1.count(max(T1)))
(15)Write the output of the following :

T1 = (23, 32, 4, 5, 2, 12, 23, 7, 9, 10, 23)

print(max(T1))

print(min(T1))

_________________________ x _________________________

You might also like