Python Quiz by anupmaurya June 5, 2021 written by anupmaurya 0 minutes read 623 December 8, 2024 Welcome to your Python Quiz Name Email In Python 3, the maximum value for an integer is 263 - 1: a) False b) True None What is the output for − 'python ' [-3]? a) 'o' b) 't' c) 'h' d) Negative index error. None Which operator is right-associative a) - b) * c) = d) % None Name the python module which supports regular expressions. a) regex b) re c) pyre d) pyregex None 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 None 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 None 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 None 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 None 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 None 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 None 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 None 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 None 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) 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 None Time's up 0 FacebookTwitterPinterestEmail anupmaurya "Hi there, My name is Anup Maurya. I have a passion for programming and previously worked at TCS, one of the best global IT services and consulting companies, as a System Administrator. I also enjoy graphic design. It's a pleasure to have you here." next post Pructor Quiz 7 Leave a Comment Cancel Reply