Python Programming Language MCQ with Answers Set 2

 

1. ------ function is used to get data type of variable





ANSWER= (B) type
Explain:-The type() method is used in python to get data type of particular method

 

2. a=input("Enter first number") b=input("Enter second number") c=a+b print(c) What will be the output of given code, if your input is 10 and 10





ANSWER= (A) 1010
Explain:-When you input any value without defining it as an integer the input function by default return it as string and we cannot perform any numerical operation on string. So in this example + operator has taken by compiler to concatenate the i.e. combine the two strings. So output will be 1010

 

3. a=10; b=2; c=a/b; print(c) what will be the output of given code What will be the output of given code, if your input is 10 and 10





ANSWER= (C) 5.0
Explain:-The forward slash i.e. division operator returns the result in float type. So when you devide 10 by 2 your division will be 5.0

 

4.---- is the identity operator in Python





ANSWER= (D) Bothe A and B
Explain:-The identity operator in Python is 'is' and 'is not' are used to compare the objects

 

5.a=10; b=2;c=20; if a>b or a>c: print("a greater")





ANSWER= (B) print statement will be executed
Explain:-print statement written in if block will get executed because at least one condition becomes satisfy. When you use logical or operator to combine tow conditions then if one condition satisfy the statement in if block will get execute

 

6.The indentation referes the ------- at the begining of the line





ANSWER= (A) Space
Explain:-The identation is the space at the begining of code line

 

7.The variable names are------ in Python





ANSWER= (B) case sensitive
Explain:-The variables in Python are case sensitive. For example if we declare variable A=10, B=20 , Then this A variable and B variable you cannot use a+b

 

8.The ------ is used to remove the element from list.





ANSWER= (C) pop()
Explain:-The pop() in Python is used to remove element from list

 

9.If index is not given pop() will remove ------ item from list





ANSWER= (B) last
Explain:-In the pop() if index is not given then pop() will remove last element from list

 

10.Which of the following are bultin data type in Python





ANSWER= (D) last
Explain:-In Python str,int,float,list,set,tuple, dict are built in data type

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

0 टिप्पण्या