You are on page 1of 1

I.

Answer the following questions:


1. What will be the output for the following Python statements?
D = {“Amit”: 90, “Reshma”: 96, “Suhail”: 92, “John”: 95}
print(“John” in D, 90 in D, sep= “#”)
2. Identify the errors in the following code:
MyTuple1=(1, 2, 3) #Statement1
MyTuple2=(4) #Statement2
MyTuple1.append(4) #Statement3 print(MyTuple1,
MyTuple2) #Statement4
3. Suppose str= ‘welcome’. All the following expression produce the same result
except one. Which one?
(a) str[ : : -6] (b) str[ : : -1][ : : -6] (c) str[0] + str[-1] (d) str[ : :6]
4. Consider the following code:
dict1 = {‘Mohan’: 95, ‘Ram’: 89, ‘Suhel’: 92, ‘Saritha’: 85}
What suitable code should be written to return a list of values in dict1 ?
5. Find the correct output of the following code:
>>>str1 = ‘India is a Great Country’
>>>str1.split(‘a’)
6. What will be the output of the following Python code?
d1={“a”:10, “b”:2, “c”:3}
str1= “ ”
for i in d1:
str1=str1+str(d1[i])+ “ ”
str2=str1[ : -1]
print(str2[: : -1])
7. Given is a Python string declaration:
str1="!!Welcome to Python!!"
Write the output of: print(str1[::-2])
8. Write the output of the code given below:
dict1 = {"name": "Suman", "age": 36}
dict1['age'] = 27
dict1['address'] = "Chennai"
print(dict1.keys())

You might also like