Python Week 6 Quiz Answers



Disclaimer for Pruto-ai

If you require any more information or you have any problem regarding Copyright or have any questions about our site’s disclaimer, please feel free to contact us by email at contact@prutor-ai.com.

All the information on this website is published in good faith and for general information and educational purpose only. Prutor-ai does not make any warranties about the completeness, reliability, and accuracy of this information. Any action you take upon the information you find on this website (Prutor-ai.blogspot.com), is strictly at your own risk. will not be liable for any losses and/or damages in connection with the use of our website.

In this students get weekly assignments that they have to complete every week. Here we will show you or give you all the answers for the python quiz, These answers are for all those who have confusion in the questions or they don’t want to submit wrong answers.

Q:1. In python,

        1.Indentation indicates a block of code.

       2.def keyword is used to indicate starting of a function.

       3.A function can call other functions.

       4.All of the above

Ans: All of the above

Reason: It is true that indention indicates a block of code and def keyword is used to indicate

               starting of a function. And it is also true that a function can call other function. Therefore all

               of the above is correct.

 

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.If x1 is smaller than x2, then y1 and y2 will be same.

      2.If x1 is greater than x2, than y1 wll be equal to x2.

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

      4.All of the above

Ans: All of the above

Reason: It is true when x1 is smaller than x2, then y1 and y2 will be same.

               When x1 is greater than x2, then y1 will be equal to x2, it is also true.

               If we further run y3=max{y1,y2}, then y3 will always be equal to x1 this statement is also

               true therefore all of the above is correct.

 

Q:3. Which of the below statement/s is/are true for global keyword in python ?

         1. It is used to read global variables inside a function.

        2. if we want to use value of global variable inside a function, we will have to use global         

           keyword.

       3. A variable name inside a function can be same as variable name of a global variable.

       4. All of the above

Ans: All of the above

Reason: Global keyword is used to read global variable inside a function, and if we want to use value

                of variable inside a function, we will have to use global keyword. And it is also true that a

                variable name inside a function can be same as variable name of a global variable.             

                Therefore all of the above options are 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.Error

          2.9

          3.0

          4.5

Ans: Error

Reason: It shows traceback

                Name error ; name y is not defined therefore we get an error.

 

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

         1.They represent sequence of characters

         2.strings are mutable

        3.Backslash can be used to escape quote

        4.All of the above

Ans: strings are mutable

Reason: We cannot overwrite the value of immutable objects. However, we            

                can assign the variable again, hence strings are mutable is correct.