1. Create a list named ‘myList’ that has the following elements: 10,20,30,’apple’, True, 8.10.
a. Now in the ‘myList’, append these values: 30,40
b. After that reverse the elements of the ‘myList’ and store that in ‘reversedList’
2. Create a dictionary ‘Country’ that maps the following countries to their capitals respectively:
Country
India
China
Japan
Qatar
France
State
Delhi
Beijing
Tokyo
Doha
Marseilles
Find 2 commands to replace “Marseilles” with “Paris”.
3. Create the tuples given below
tuple_1 = (1,5,6,7,8)
tuple_2 = (8,9,4)
Identify which of the following code does not work on a tuple.
a) sum(tuple_1)
b) len(tuple_2)
c) tuple_2 + tuple_1
d) tuple_1[3] = 45
myList=[10,20,30,'apple',True,8,10]
myList.append(30)
myList.append(40)
reversedList=myList.reverse()
print(reversedList)
Country={"India":"Delhi","China":"Beijing","Japan":"Tokyo",
"Qatar":"Doha","France":"Marseilles"}
varr=Country["France"].replace("Marseilles","Paris")
Country["France"]=varr
tuple_1=(1,5,6,7,8)
tuple_2=(8,9,4)
tuple_1[3]= 45
Comments
Leave a comment