Python MCQ (Multi Choice Questions)1) What is the maximum possible length of an identifier?
Answer: (d) None of these above Explanation: The maximum possible length of an identifier is not defined in the python language. It can be of any number. 2) Who developed the Python language?
Answer: (b) Guido van Rossum Explanation: Python language was developed by Guido van Rossum in the Netherlands. 3) In which year was the Python language developed?
Answer: (d) 1989 Explanation: Python language was developed by Guido van Rossum in 1989. 4) In which language is Python written?
Answer: (b) C Explanation: Python is written in C programming language, and it is also called CPython. 5) Which one of the following is the correct extension of the Python file?
Answer: (a) .py Explanation: ".py" is the correct extension of the Python file. 6) In which year was the Python 3.0 version developed?
Answer: (a) 2008 Explanation: Python 3.0 version was developed on December 3, 2008. 7) What do we use to define a block of code in Python language?
Answer: (c) Indentation Explanation: Python uses indentation to define blocks of code. Indentations are simply spaces or tabs used as an indicator that is part of the indent code child. As used in curly braces C, C++, and Java. 8) Which character is used in Python to make a single line comment?
Answer: (c) # Explanation: "#" character is used in Python to make a single-line comment. 9) Which of the following statements is correct regarding the object-oriented programming concept in Python?
Answer: (b) Objects are real-world entities while classes are not real Explanation: None 10) Which of the following statements is correct in this python code?
Answer: (b) id(name1) and id(name2) will have same value Explanation: "name1" and "name2" refer to the same object, so id(name1) and id(name2) will have the same value. 11) What is the method inside the class in python language?
Answer: (b) Function Explanation: Function is also known as the method. 12) Which of the following declarations is incorrect?
Answer: (d) None of these Explanation: All declarations will execute successfully but at the expense of low readability. 13) Why does the name of local variables start with an underscore discouraged?
Answer: (c) It indicates a private variable of a class Explanation: Since there is no concept of private variables in Python language, the major underscore is used to denote variables that cannot be accessed from outside the class. 14) Which of the following is not a keyword in Python language?
Answer: (a) val Explanation: "val" is not a keyword in python language. 15) Which of the following statements is correct for variable names in Python language?
Answer: (b) Unlimited length Explanation: None 16) Which of the following declarations is incorrect in python language?
Answer: (b) x y z p = 5000 6000 7000 8000 Explanation: Spaces are not allowed in variable names. 17) Which of the following words cannot be a variable in python language?
Answer: (c) try Explanation: "try" is a keyword. 18) Which of the following operators is the correct option for power(ab)?
Answer: (b) a**b Explanation: The power operator in python is a**b, i.e., 2**3=8. 19) Which of the following precedence order is correct in Python?
Answer: (a) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction Explanation: PEMDAS (similar to BODMAS). 20) Which one of the following has the same precedence level?
Answer: (b) Division and Multiplication Explanation: None 21) Which one of the following has the highest precedence in the expression?
Answer: (d) Parentheses Explanation: PEMDAS (similar to BODMAS). 22) Which of the following functions is a built-in function in python language?
Answer: (b) print() Explanation: The print() function is a built-in function in python language that prints a value directly to the system. 23) Study the following function: What will be the output of this function?
Answer: (d) 5 Explanation: The round function is a built-in function in the Python language that round-off the value (like 3.85 is 4), so the output of this function will be 5. 24) Which of the following is correctly evaluated for this function?
Answer: (c) (x**y) % z Explanation: None 25) Study the following function: What will be the output of this function?
Answer: (a) False Explanation: If any element is zero, it returns a false value, and if all elements are non-zero, it returns a true value. Hence, the output of this "all([2,4,0,6])" function will be false. 26) Study the following program: What will be the output of this code?
Answer: (a) error Explanation: Syntax error, there should not be a space between + and =. 27) Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:\java.txt''?
Answer: (a) Infile = open(''c:\\scores.txt'', ''r'') Explanation: None 28) Study the following code: What will be the output of this program?
Answer: (a) ['XX', 'YY'] Explanation: None 29) Study the following function: What will be the output of this code?
Answer: (d) 6.0 Explanation: This function prints the square of the value. 30) Study the following function: What will be the output of this code?
Answer: (b) True Explanation: None 31) Study the following statement: What will be the output of this statement?
Answer: (b) abc Explanation: In Python, the "+" operator acts as a concatenation operator between two strings. 32) Study the following code: What will be the output of this code?
Answer: (c) point Explanation: Slice operation is performed on the string. 33) The output to execute string.ascii_letters can also be obtained from:?
Answer: (d) string.ascii_lowercase+string.ascii_upercase Explanation: None 34) Study the following statements: What will be the output of this statement?
Answer: (a) t Explanation: The correct output of this program is "t" because -1 corresponds to the last index. 35) Study the following code: What will be the output of this statement?
Answer: (c) \njavat\npoint Explanation: None 36) Study the following statements: What will be the output of this statement?
Answer: (a) 33 Explanation: A, B and C are hexadecimal integers with values 10, 11 and 12 respectively, so the sum of A, B and C is 33. 37) Study the following program: Which of the following is the correct output of this program?
Answer: (d) Error is generated Explanation: Error is generated because self.o1 was never created. 38) Study the following program: What will be the output of this statement?
Answer: (d) Wick Nick Explanation: None 39) Study the following statements: What will be the output of this statement?
Answer: (b) -18 Explanation: ASCII value of h is less than the z. Hence the output of this code is 104-122, which is equal to -18. 40) Study the following program: Which of the following is correct output of this program?
Answer: (a) ['xy', 'yz'] Explanation: None 41) Study the following program: Which of the following is the correct output of this program?
Answer: (d) Invalid syntax Explanation: Invalid syntax, because this declaration (i = 1:) is wrong. 42) Study the following program: Which of the following is correct output of this program?
Answer: (b) 1 2 3 4 5 6 Explanation: None 43) Study the following program: What will be the output of this statement?
Answer: (c) 0 1 2 Explanation: None 44) Study the following program: What will be the output of this statement?
Answer: (c) 0 1 2 0 Explanation: None 45) Study the following program: What will be the output of this statement?
Answer: (b) No output Explanation: "j" is not in "xyz". 46) Study the following program: Which of the following is the correct output of this program?
Answer: (b) pqrs Explanation: None 47) Study the following program: What will be the output of this statement?
Answer: (b) 0 1 2 Explanation: None 48) Study the following program: What will be the output of this statement?
Answer: (b) 0 1 2 Explanation: None 49) Which of the following option is not a core data type in the python language?
Answer: (c) Class Explanation: Class is not a core data type because it is a user-defined data type. 50) What error will occur when you execute the following code?
Answer: (a) NamaError Explanation: Mango is not defined hence the name error. 51) Study the following program: What will be the output of this statement?
Answer: (d) indentationError Explanation: None 52) Which of the following data types is shown below? What will be the output of this statement?
Answer: (c) List Explanation: Any value can be stored in the list data type. 53) What happens when '2' == 2 is executed?
Answer: (a) False Explanation: It only evaluates to false. 54) Study the following program: What will be the output of this statement?
Answer: (a) invalid code Explanation: A new exception class must inherit from a BaseException, and there is no such inheritance here. 55) Study the following statement Which of the following is the correct statement?
Answer: (d) All of the above Explanation: All of the above statements is correct regarding Python code. Next TopicPython Tutorial
|
Python tutorial provides basic and advanced concepts of Python.
Vue.js is an open-source progressive JavaScript framework
HTML refers to Hypertext Markup Language. HTML is the gateway ...
Java is an object-oriented, class-based computer-programming language.
PHP is an open-source,interpreted scripting language.
Spring is a lightweight framework.Spring framework makes ...
JavaScript is an scripting language which is lightweight and cross-platform.
CSS refers to Cascading Style Sheets...
jQuery is a small and lightweight JavaScript library. jQuery ...
SQL is used to perform operations on the records stored in the database.
C programming is considered as the base for other programming languages.
JavaScript is an scripting language which is lightweight and cross-platform.
Vue.js is an open-source progressive JavaScript framework
ReactJS is a declarative, efficient, and flexible JavaScript library.
jQuery is a small and lightweight JavaScript library. jQuery ...
Node.js is a cross-platform environment and library for running JavaScript app...
TypeScript is a strongly typed superset of JavaScript which compiles to plain JavaScript.
Angular JS is an open source JavaScript framework by Google to build web app...
JSON is lightweight data-interchange format.
AJAX is an acronym for Asynchronous JavaScript and XML.
ES6 or ECMAScript 6 is a scripting language specification ...
Angular 7 is completely based on components.
jQuery UI is a set of user interface interactions built on jQuery...
Python tutorial provides basic and advanced concepts of Python.
Java is an object-oriented, class-based computer-programming language.
Node.js is a cross-platform environment and library for running JavaScript app...
PHP is an open-source,interpreted scripting language.
Go is a programming language which is developed by Google...
C programming is considered as the base for other programming languages.
C++ is an object-oriented programming language. It is an extension to C programming.
C# is a programming language of .Net Framework.
Ruby is an open-source and fully object-oriented programming language.
JSP technology is used to create web application just like Servlet technology.
The JSTL represents a set of tags to simplify the JSP development.
ASP.NET is a web framework designed and developed by Microsoft.
Perl is a cross-platform environment and library for running JavaScript...
Scala is an object-oriented and functional programming language.
VBA stands for Visual Basic for Applications.
Spring is a lightweight framework.Spring framework makes ...
Spring Boot is a Spring module that provides the RAD feature...
Django is a Web Application Framework which is used to develop web applications.
Servlet technology is robust and scalable because of java language.
The Struts 2 framework is used to develop MVC based web applications.
Hibernate is an open source, lightweight, ORM tool.
Solr is a scalable, ready-to-deploy enterprise search engine.
SQL is used to perform operations on the records stored in the database.
MySQL is a relational database management system based...
Oracle is a relational database management system.
SQL Server is software developed by Microsoft.
PostgreSQL is an ORDBMS.
DB2 is a database server developed by IBM.
Redis is a No SQL database which works on the concept of key-value pair.
SQLite is embedded relational database management system.
MongoDB is a No SQL database. It is an document-oriented database...
Memcached is a free, distributed memory object caching system.
Hibernate is an open source, lightweight, ORM tool.
PL/SQL is a block structured language that can have multiple blocks in it.
DBMS Tutorial is software that is used to manage the database.
Spark is a unified analytics engine for large-scale data processing...
IntelliJ IDEA is an IDE for Java Developers which is developed by...
Git is a modern and widely used distributed version control system in the world.
GitHub is an immense platform for code hosting.
SVN is an open-source centralized version control system.
Maven is a powerful project management tool that is based on POM.
Jsoup is a java html parser.
UML is a general-purpose, graphical modeling language.
RESTful Web Services are REST Architecture based Web Services.
Postman is one testing tools which is used for API testing.
JMeter is to analyze the performance of web application.
Jenkins builds and tests our software projects.
SEO stands for Search Engine Optimization.
MATLAB is a software package for mathematical computation, visualization...
Unity is an engine for creating games on multiple platforms.
Hadoop is an open source framework.
Pig is a high-level data flow platform for executing Map Reduce programs of Hadoop.
Spark is a unified analytics engine for large-scale data processing...
Spring Cloud is a framework for building robust cloud applications.
Spring Boot is a Spring module that provides the RAD feature...
AI is one of the fascinating and universal fields of Computer.
Cloud computing is a virtualization-based technology.
AWS stands for Amazon Web Services which uses distributed IT...
Microsoft Azure is a cloud computing platform...
IoT stands for Internet of Things...
Spring Cloud is a framework for building robust cloud applications.
Email:jjw.quan@gmail.com