Python quiz 6

 Start date- 12-05-2021                                                      End date- 25-05-2021



 

LET'S BEGIN......

________________________________________________________________________________________________________


Q.1. In python,

1.
2.
3.
4.
ANSWER :- (4) Here in python it uses indentation to indicate a block of code and def is used to indicate start of function also a function can call other function.

________________________________________________________________________________________________________



Q.2. Assume that the 'min' function computes the minimum of two values, and 'max' function computes the maximum of two values. Let x1, x2 be 2 distinct integers. What can you say about the following program (using python 3.X version):
y1 = min(x1, x2)
y2 = max(y1, x1)
1.
2.
3.
4.
ANSWER :- (4) In above given code x1 will remain maximum thus all of the above will be correct. 

________________________________________________________________________________________________________



Q.3. Which of the below statement/s is/are true for global keyword in python ?
1.
2.
3.
4.
ANSWER :- (4) Global keyword is a keyword that allows a user to modify a variable outside of the current scope and read variable inside function. In python function name of global keyword can be same, thus all of the above is correct. 

________________________________________________________________________________________________________



Q.4. What will be the output of the following code:-
def keywordExample(x=1, y=2, z=4):
    sum = x+y
    min = sum - z
    print (min)
keywordExample(y=8,x=4,z=y)
1.
2.
3.
4.
ANSWER :- (1) Here we get an error after running code in python idle it return's that name y is not defined.

_____________________________________________________________________________________________________


Q.5. Which of the following statement is false for string in python:
1.
2.
3.
4.
ANSWER :- (2) As python represents sequence of characters and also backslash can be used to escape quote. but the string data types are immutable, which means a string value cannot be updated. Thus second option is false.

Comments