0% found this document useful (0 votes)
45 views1 page

Python List and Tuple Exercises

Uploaded by

jeyadev12345
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)
45 views1 page

Python List and Tuple Exercises

Uploaded by

jeyadev12345
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

I.

Answer the following questions:


1. Given is a Python list declaration:
Listofnames=[“Aman”, “Ankit”, “Ashish”, “Rajan”, “Rajat”]
Write the output of:
print(Listofnames [-1:-4:-1])
2. Consider the following tuple declaration:
tup1=(10, 20, 30, (10, 20, 30), 40) write the output of print([Link](20))
3. Given the following tuple Tup=(10, 20, 30, 50)
Which of the following statements will result in an error?
a) print(Tup[0]) b) [Link](2, 3) c) print(Tup[1:2]) d) print(len(Tup))
4. Given is a python string declaration:
NAME=”Learing Python is Fun”
Write the output of: print(NAME[-5:-10:-1])
5. Write the output of the code given below:
dict1={1:[“Rohit”,20], 2:[“Siya”,90]}
dict2={1:[“Rahul”,95], 5:[“Rajan”,80]}
[Link](dict2)
print([Link]())
6. Find the output:
s=”Python is fun”
L=[Link]()
s_new=”_”.join([l[0].upper(), l[1], l[2].capitalize()])
print(s_new)
7. Which command will delete key-value pair for key=”Red” from a dictionary D1?
8. Find the output:
Pride=”#G20 Presidency”
print(Pride[-2:2:-2])
9. Which of the following statement(s) would give an error during execution of the
following code?
tup=(20, 30, 40, 50, 80, 79)
print(tup) #Statement 1
print(tup[3]+50) #Statement 2
print(max(tup)) #Statement 3
tup[4]=80 #Statement 4
10. Find the output:
x=[[10.0, 11.0, 12.0], [13.0, 14.0, 15.0]]
y=x[1][2]
print(y)

You might also like