Python Quiz Solution week 6 ( new 2021 ) Quiz Aktu | python quiz answer week 6 with reason | AKTU / Prutor | python quiz 6

 Python Quiz Solution week 6 ( new 2021 )

Python Programming Quiz – 6th 

Week Quiz Solution 2020 


.1. In python,

(a).indentation indicates a block of code.

(b). def keyword is used to indicate starting of a function.

(c). A function can call other functions. 

(d).All of the Above


Answer;- (d).All of the Above.


Reason:-  Python uses indentation to indicate a block of code. &  The “def” keyword is a statement for defining a function in Python. You start a function with the def keywordspecify a name followed by a colon (:) sign. so all are include in python .


Q.2.Assume that the "min" function computes the minimum of two value and "max" function computes the maximum of two value 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,y2)

(a).if x1 is smaller than x2 , then y1 and y2 will be same 

(b).if x1 is greater  than x2 , then y1 will be equal to x2.

(c).if we further run y3=max(y1,y2),then y3 will always be equal to x1

(d).All of the above


Answer:- (c).if we further run y3=max(y1,y2),then y3 will always be equal to x1.



Reason:-the "min" function computes the minimum of two value and "max" function computes the maximum of two value Let x1, x2 be 2 distinct integers. than we can say if we further run y3=max(y1,y2),then y3 will always be equal to x1.


Q3.which of of the below statement /s is/ are true for global keyword in Python?.

(a).it is used to read Global variable inside a function.

(b).if we want to use value of global variable inside a function, we will have to use Global keyword

(c).A variable name inside a function can be same as variable name of global variable.

(d).All of the above.


Answer:- (b).if we want to use value of global variable inside a function, we will have to use Global keyword.

Reason:- Different variables in a python program have different scope. ... A variable declared outside a function is a global variable by default. We use a global keyword for a variable which is inside a function so that it can be modified. Without the global keyword, the variable inside a function is local by default.



Q.4.what will be the output of the following code:-

def keywoedExample(x=1,y=2,z=4):

sum=x+y

min=sum - z

print(min)

keywordExample(y=8,x=4,z=y)


(a).Error

(b).9

(c).0

(d).5


Answer:-(a).Error

Reason:- File "HelloWorld.py", line 2

    sum = x+y
      ^
IndentationError: expected an indented block , so the answer is error 


Q.5.Which of the following statement is false for string in Python:

(a).they represent sequence of characters 

(b).strings are mutable

(c).backslash be used to escape quote

(d).All of the above


Answer:-  (d).All of the above

Reason:-To create a string, put the sequence of characters inside either single quotes, double quotes, or triple quotes and then assign it to a variable. You can look into how variables work in Python in the Python variables tutorial. For example, you can assign a character 'a' to a variable single_quote_character .

Post a Comment

0 Comments