Python tests, quizzes, and exams are great ways to learn and test your Python programming skills. Whether you’re a beginner or experienced, challenge and boost your confidence with our engaging online quizzes on Python basics, operators, loops, strings, lists, tuples, sets, dictionaries, functions, modules, files, and exceptions. Start the Python online test now
Python Online Practice Test - 1 Q Python is ? A General-purpose interpreted language B General-purpose interpreted and interactive language C General-purpose interpreted, interactive language and object-oriented language D General-purpose interpreted, interactive language, object-oriented and high-level programming language Correct Answer : OPTION D, General-purpose interpreted, interactive language, object-oriented and high- level programming language Q Python was created by ? A Rasmus Lerdorf B Guido van Rossum C Larry Wall D Brendan Eich Correct Answer : OPTION B, Guido van Rossum Q Python source code is also available under which license? A GPL B EPL C Apache D MIT Correct Answer : OPTION A, GPL Q Which of the one is an invalid python environment variable? A PYTHONPATH B PYTHONSTARTUP C PYTHONCASEOK D PYTHONLIBRARY Correct Answer : OPTION D, PYTHONLIBRARY Q What is PYTHONHOME? A It is an alternative module search path B It contains the path of an initialization file containing Python source code C It is used in Windows to instruct Python to find the first case-insensitive match in an import statement D None of the above Correct Answer : OPTION A, It is an alternative module search path Q What is PYTHONPATH? A It is used for installation of Python B It tells the Python compiler where to locate the module files imported into a program C It tells the Python interpreter where to locate the module files imported into a program D None of the above Correct Answer : OPTION C, It tells the Python interpreter where to locate the module files imported into a program Q What is PYTHONSTARTUP? A It is executed every time you start the compiler B It is executed every time you start the interpreter C It is needed while booting of a particular process D None of the above Correct Answer : OPTION B, It is executed every time you start the interpreter Q What is PYTHONCASEOK? A It is used to find the first case-sensitive match in an import statement B It is used to find the first case-insensitive match in an import statement C It is used to find the first case-insensitive match in a package statement D None of the above Correct Answer : OPTION B, It is used to find the first case-insensitive match in an import statement Q What is the use of -d command line option? A It provides debug input B It provides debug output C It generates optimized bytecode D None of the above Correct Answer : OPTION B, It provides debug output Q What is the extension of Python files? A .pt B .py C .pm D .class Correct Answer : OPTION B, py Q Which of these is invalid naming convention for Python identifiers? A An identifier can start with lowercase letter B An identifier can start with uppercase letter C An identifier can start with a number D An identifier can start with underscore(_) Correct Answer : OPTION C, An identifier can start with a number Q What is the maximum possible length of an identifier? A 20 characters B 30 characters C 50 characters D None of the above Correct Answer : OPTION D, None of the above Q All keywords in Python are in ? A Lowercase B Uppercase C Alphanumeric D None of the above Correct Answer : OPTION A, Lowercase Q Python keywords can be used as ? A Constant B Variable C Identifier D None of the above Correct Answer : OPTION D, None of the above Q Which is not a valid keyword? A eval B except C Both A and B D None of these Correct Answer : OPTION A, eval Python Online Practice Test - 2 This Test will cover complete Python with very important questions, starting off from basics to advanced level Q Which one of these is used to comment statements in Python? A * B # C @ D % Correct Answer : OPTION B, # Q How many standard data types does Python support? A 3 B 4 C 5 D None of the above Correct Answer : OPTION C, 5 Q Which one of these is not a part of standard data types in Python? A Numbers B Character C String D List Correct Answer : OPTION B, Character Q Reference to a number object can be deleted using which statement? A del B delete C free D malloc Correct Answer : OPTION A, del Q Python does not support which of these numerical types? A int B signedInt C long D complex Correct Answer : OPTION B, signedInt Q Which operator is used to concatenate strings in Python? A / B C + D ! Correct Answer : OPTION C, + Q What is the difference between Lists and Arrays? A Unlike array, items belonging to Lists can be of different data type B Unlike array, list uses parentheses to store items C There is no difference between Lists and Arrays D None of the above Correct Answer : OPTION A, Unlike array, items belonging to Lists can be of different data type Q Elements in Tuples are stored using ? A [] B () C {} D None of the above Correct Answer : OPTION B, () Q Dictionaries are enclosed by curly braces and values can be assigned and accessed using square braces ? A [] and {} B {} and [] C () and {} D [] and () Correct Answer : OPTION B, {} and [] Q Python supports which types of operators? A Arithmetic, Relational, Assignment and Logical operators B Arithmetic, Relational, Assignment, Logical and Bitwise operators C Arithmetic, Relational, Assignment, Logical, Bitwise and Membership operators D Arithmetic, Relational, Assignment, Logical, Bitwise, Membership and Identity operators Correct Answer : OPTION D, Arithmetic, Relational, Assignment, Logical, Bitwise, Membership and Identity operators Q Which one of these is not an Arithmetic operator? A // B ** C *** D None of the above Correct Answer : OPTION C, *** Q Which one of these is not Comparison operator? A == B != C >= D === Correct Answer : OPTION D, === Q Which one of these is not an Assignment operator? A **= B //= C ***= D None of the above Correct Answer : OPTION C, ***= Q Which one among these are Membership operator? A if and else B in and not in C if and not if D None of the above Correct Answer : OPTION B, in and not in Q Which one among these are Identity operator? A is and not is B is and not if D if and if not C is and is not Correct Answer : OPTION C, is and is not Python Online Practice Test - 3 This Test will cover complete Python with very important questions, starting off from basics to advanced level Q What is the order of precedence in python? A Parentheses, Exponential, Division, Multiplication, Addition, Subtraction B Parentheses, Multiplication, Division, Exponential, Addition, Subtraction C Parentheses, Division, Multiplication, Addition, Subtraction, Exponential D None of the above Correct Answer : OPTION A, Parentheses, Exponential, Division, Multiplication, Addition, Subtraction Q What is the value of following expression: 3*1**3 A 1 B 3 C 9 D 27 Correct Answer : OPTION B, 3 Q Which one of the following have the same precedence? A Addition and Subtraction B Multiplication and Division C Both A and B D None of the above Correct Answer : OPTION C, Both A and B Q What will be the output of the below program? >>>str="studytonight" >>>str[:5] >>> A tonight B study C studytonight D 5 Correct Answer : OPTION B, study Q What is the datatype of below statement? L = [1, 'hello', 'studytonight', 1] A Array B Dictionary C List D Tuple Correct Answer : OPTION C, List Q Which datatype is used to store values in terms of key and value? = -10 A Array B List C Class D Dictionary Correct Answer : OPTION D, Dictionary Q What does ~9 evaluate to? A 8 B -8 C 10 D -10 Correct Answer : OPTION D, -10 It is evaluated as –(9+1) Q What is the value of following expression: 24//6%3 A 0 B 1 C 2 D 3 Correct Answer : OPTION B, 1 Q What is the value of following expression: bin(0x8) A 8 B 1000 C '0bx1000' D '0b1000' Correct Answer : OPTION D, '0b1000' Q What is the output of the code shown below? bool('False') bool() A True True B False True C False False D True False Correct Answer : OPTION D, True False Q What is the output of the code shown below? ['study', 'tonight'][bool('')] A Error B No output C study D tonight Correct Answer : OPTION C, study Q What is pass statement in Python? A It declares variables B It defines function D None of the above C It is a null statement Correct Answer : OPTION C, It is a null statement Q What is the output of the code shown below? if (9 < 0) and (0 < -9): print("hello") elif (9 > 0) or False: print("study") else: print("tonight") A hello B study C tonight D None of the above Correct Answer : OPTION B, study Q What is the output of the code shown below? X="studytonight" print("05d"%X) A 00000studytonight B studytonight00000 C Error D None of the above Correct Answer : OPTION C, Error Q What is the output of the code shown below? s='{0}, {1}, and {2}' s.format('hello', 'good', 'morning') A 'hello study and tonight' B 'hello, study, tonight' D Error C 'hello, study, and tonight' Correct Answer : OPTION C, 'hello, study, and tonight' Python Online Practice Test - 4 This Test will cover complete Python with very important questions, starting off from basics to advanced level Q What is the output of below code? print(type([1,2])) A B C D Correct Answer : OPTION D, Q What is the output of below code? print(type(1/2)) A B D C Correct Answer : OPTION C, Q What is the output of below code? d = lambda p: p * 2 t = lambda p: p * 3 x = 2 x = d(x) x = t(x) x = d(x) print(x) A 12 B 24 C 36 D 48 Correct Answer : OPTION B, 24 Q If PYTHONPATH is set in the environment, which directories are searched for modules? I) PYTHONPATH directory II) Current directory III) Home directory IV) Installation dependent default path