Python Test 4

More Python Tests

Question 1: What will be the output of the following code?

>>> i=100
>>> type(i)

Question 2: Which of the following statements are valid in Python?

Question 3: What will be the output of the following program?

x = "X" 
y = "X"
print(x is y)

Question 4: 'str' in 'string' returns _________.

Question 5: Given x='HelloWorld'which expression out of the following will return 'World'?

Question 6: What will be the output of the following code?

nums=list({1:'one',2:'two'})
print(nums)

Question 7: Which of the following is true?

Question 8: If lst=[[1,2],[3,4]], which of the following will return true?

Question 9: What will be the output of the following code?

lst = [1, 2, 3, 4, 5]
print(lst[0:1])

Question 10: Which of following will result in error?

Question 11: The items() method of dictionary returns:

Question 12: years={1995:'Java', 1972:'C', 1994:'Python'} is a dictionary with key-value pairs of the year of invention and name of a language. The expression list(years)will return:

Question 13: What will be the output of the following code?

s1={1,2,3,4,5}
s2={4,5,6,7,8}
print(s1-s2)

Question 14: How to convert a tuple to a set object?

Question 15: What will be the output of the following code?

s={1,2,3 }
s[0]=10
print(s)