Python Programming Language MCQ with Answers Set 5

 

1. The ------- keyword is used to create tuple





ANSWER= (A)tuple
Explain:- The tuple keyword is used to create tuple data structure in Python

 

2. The ------- keyword is used when loop is used on tuple,set,list sequence





ANSWER= (B)in
Explain:- When loop is applied on tuple, set or list with the loop in keyword is also used

 

3. The split() is used on a sequence for ----------- of data element





ANSWER= (C)Spliting or seperation
Explain:- The split() is used for the seperation of data elements from set, tuple,list sequence

 

4. The set data structure is --------- in nature





ANSWER= (A)mutable
Explain:- The set data structure is mutable in nature. Means once set created you can insert or modify or delete set

 

5. The list data structure is ---------- in nature





ANSWER= (A)mutable
Explain:- The list data structure is mutable in nature. Means you can insert, modify or delete data items from list

 

6. What will be the output of following code my_list1=[10,200,300,400,'a1','a2','aaaaaa'] ; for i in my_list1: ; if isinstance(i,str): ; print(i)





ANSWER= (C) a1 a2 aaaaaa
Explain:- The isinstance() function is used to check only str value to check so compiler will display only display string values and exclude numeric values

 

7. What will be the output of following tuple1=[1,2,3,4,'hello'] ; sum=0; for i in tuple1:; sum=sum+i; print(sum)





ANSWER= (A) Type casting error
Explain:- On the given sequence isinstance() method is not applied to include only integer values from given list. The numerical operations are not possible on string. One data element is string. So type casting error will occur

 

8. What will be the output of following set1={1,2,3,4,5,6,7,8,9,10}; for i in set1:; if i%2!=0:; print(i)





ANSWER= (D) 1 3 5 7 9
Explain:- Loop is applied to access set data items and test condition is given to check only those data items whose division remaider is not equals to zero. and these numbers are 1 3 5 7 9

 

9.The ----- function is used to get total size(length) of sequence





ANSWER= (A)len()
Explain:-The len() in Python is used to get total number of elements in sequence.

 

10.The ----- function is used to get total occurances of specified element of sequence





ANSWER= (B)count()
Explain:-The count() in Python is used to get total number occurances of specified element in sequence.

टिप्पणी पोस्ट करा

0 टिप्पण्या