Answer to Question #292869 in Python for suresh

Question #292869

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

 



1
Expert's answer
2022-02-01T23:56:51-0500

Lists

myList=[10,20,30,'apple',True,8,10]

myList.append(30)
myList.append(40)

reversedList=myList.reverse()
print(reversedList)

dictionary Country

Country={"India":"Delhi","China":"Beijing","Japan":"Tokyo",
"Qatar":"Doha","France":"Marseilles"}

varr=Country["France"].replace("Marseilles","Paris")
Country["France"]=varr

Tuples

tuple_1=(1,5,6,7,8)
tuple_2=(8,9,4)
  • The code that will not work is the line below since tuples do not allow assignment
 tuple_1[3]= 45

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS