Python Quiz by anupmaurya June 5, 2021 written by anupmaurya 0 comment 176 views May 25, 2022 Welcome to your Python Quiz 1. In Python 3, the maximum value for an integer is 263 - 1: a) False b) True 2. What is the output for − 'python ' [-3]? a) 'o' b) 't' c) 'h' d) Negative index error. 3. Which operator is right-associative a) - b) * c) = d) % 4. Name the python module which supports regular expressions. a) regex b) re c) pyre d) pyregex 1 out of 3 5. What does the following Python3 code do? (using python 3.X version): n = int(input('Enter a number?'))i = 1while i <= n: i = i+1 print (i) a) Print all integers from 1 to n b) Print all integers from 1 to n-1 c) Print all integers from 2 to n d) Print all integers from 2 to n+1 6. What will the output of the following Python3 program (using python 3.X version)? n = 13sum = 0while (n> 1): n = n//2 sum = sum + nprint(sum) a) 2 b) 10 c) 9 d) Error 7. What will the output of the following Python3 program? If the program has error, select the option ERROR (using python 3.X version): n,p = 9,1while (n >= 1): n,p = n//2,n*p print(int(p)) a) 8 b) 102 c) 9 36 72 72 d) Error 8. The following code should print all positive even numbers less than or equal to N. N is taken as input from the user. What should replace the X for the code to work correctly?(using python 3.X version): int(input('Enter N:'))i = 1while ( i < N ) : if ( X ): print(i) i = i + 1 a) i//2 == 0 b) i%2 != 0 c) i//2 != 0 d) i%2 == 0 9. The following code should print all positive odd numbers less than or equal to N. N is taken as input from the user. What should replace the X for the code to work correctly? (using python 3.X version): N = int(input('Enter N:'))i = 1while ( i < N ) : print(i) X a) i = i + 2 b) i=i+3 2 out of 3 10. 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 11. 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) a) If x1 is smaller than x2, then y1 and y2 will be same. b) If x1 is greater than x2, than y1 wll 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 12. Which of the below statement/s is/are true for global keyword in python ? a) It is used to read global variables 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 a global variable. d) All of the above 13. What will be the output of the following code:- def keywordExample(x=1, y=2, z=4):sum = x+ymin = sum - zprint (min)keywordExample(y=8,x=4,z=y) 14. Which of the following statement is false for string in python: a) They represent sequence of characters b) strings are mutable c) Backslash can be used to escape quote d) All of the above 3 out of 3 Name Email Share 0 FacebookTwitterLinkedinRedditWhatsappTelegramEmail anupmaurya Hey there, My name is Anup Maurya. I was born with love with programming and works at TCS. One of best global (IT) services and consulting company as System Administrator . I also love graphics designing. It's my pleasure to have you here. next post Pructor Quiz 7 Leave a Comment Cancel Reply Save my name, email, and website in this browser for the next time I comment. * By using this form you agree with the storage and handling of your data by this website.