Python Quizzes

Results

-
Share to Your Friend
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Share to Your Friend
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

#1 Which is a valid identifier in Python?

Correct option is _DS

Option DATA-REC is false because -(hyphen)  can not be part of an identifier.

Option 29CLCT is false because 29( a number i)  can be part of  an identifier, however, it can not be at the beginning.

#2 If s is a set having elements s={1,2,3,4,5,6}, what would be the output of the above program ?

Explanation-

for loop iterates over set s, and it first stores values  in item variable


if checks whether 1 % 2  which is equal to 1

And Python treats non-zero numbers as True  then it prints  value of item which is 1


if checks whether 2 % 2  which is equal to 0

And Python treats zero as False  and  control does not enter in if block


if checks whether 3 % 2  which is equal to 1

And Python treats non-zero numbers as True  then it prints   value of item which is 3


if checks whether 4% 2  which is equal to 0

And Python treats zero as False  and does not enter in if block


if checks whether 5% 2  which is equal to 1

And Python treats non-zero numbers as True  then it prints  value of item which is 5


if checks whether 2 % 2  which is equal to 0

And Python treats zero as False  and does not enter in if block


Answer is

1 3 5

 

 

 

 

 

#3 If d is a dictionary having elements d={‘India’:’New Delhi’, ‘Germany’:’Berlin’, ‘France’:’Paris’, ‘Spain’:’Madrid’}, how will value ‘Berlin’ be accessed.

Click on the  below link to see the explanation

Dictionary in Python

#4 A tuple in Python is

Click on the below link to see the explanation

Tuples in Python

 

 

#5 If t is a tuple having elements t=(1,2,3,4,5,6), how will element 5 be printed?

Click on the below link to see the explanation

Tuples in Python

#6 If a nested list is a=[3,5,8,4,15,34,[5,8,[-4,-8],9,3], 8,9,[6,9],12,7], then how which index you will use to access element -8.

#7 What would be the output of the above program? (See ASCII code table corresponding to hexadecimal values)

#8 Which one is a Boolean literal in Python?

#9 Which one is a special literal in Python?

#10 Which quotation mark can be used for a multiline string?

#11 Which option is correct?

None of the above is correct because  opening quotation is triple but closing is double. So, there would be an error

You Can Finish If You Want

Share to Your Friend
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Leave a Comment