These Python multiple-choice questions and their answers will help you strengthen your grip on the subject of Python. You can prepare for an upcoming exam or job interview with these 800+ Python MCQs.
So scroll down and start answering.
A. A statement.
B. A lambda.
C. A closure.
D. A suite.
E. An expression.
A. [[1, 2], [1, 2], [1, 2]]
B. Compilation error
C. [1, 2, 3, 4, 5, 6]
D. [6, 6, 6, 6, 6, 6]
E. [[1, 2], [3, 4], [5, 6]]
A. sys
B. re
C. regularexpressions
D. regexp
A. **
B. ^
C. Both are correct.
D. None are correct.
A. System administrators' toolkits for Python
B. GUI programming toolkits for Python
C. Test suites for Python
D. Names of popular Python repositories
A. Single quotes are for short strings. Double quotes are for long strings.
B. There is no difference.
C. Double quotes are for constants. Single quotes are for variables.
D. In Python you can use only single quotes.
A. '9'
B. [9]
C. '333'
D. [3, 3, 3]
A. ()
B. None of these
C. ""
D. {}
A. Always
B. Never
A. Yes
B. No
A. Always
B. Never
A. py
B. pl
C. pt
D. pie
E. pil
A. 0
B. 1
C. -2,147,483,648
D. -1
A. Repeatedly execute a block of code
B. Conditionally execute a block of code
C. Execute code from more than one place in a program
A. "a"
B. ret("a")
C. return "a"
D. a
A. bear
B. tiger
C. penguin
D. zebra
A. //
B. {
C. /*
D. #
A. print 'fred'
B. println('fred')
C. cout << "fred" << endl;
D. write('fred')
A. CPython
B. IronPython
C. Jython
D. PyPy
A. False
B. True
A. False
B. True
A. use
B. package
C. external
D. import
A. All are correct.
B. The name of the operating system where your Python code is run.
C. The largest integer the machine's architecture supports.
D. The Python interpreter's version number.
A. It's configurable.
B. 100000
C. 100
D. 10000
E. 1000000
A. This expression will result in a syntax error.
B. Undefined
C. 0
D. 1
A. None.
B. set
C. list
D. dictionary
E. All three.
A. >
B. #
C. $
D. >>>
A. Dynamic.
B. Inverse.
C. Loading.
D. Proportional.
E. Static.
A. Yes, but only in the interactive shell.
B. Yes, but only when the program runs on a remote server.
C. Yes.
D. No.
A. Counter.
B. List.
C. Dictionary.
D. Tuple.
E. Set.
A. Returns the status of all printers installed on the network.
B. Evaluates its parameters and writes the resulting objects to standard output.
C. Allows users to input data.
D. Prints the source code on the default printer.
A. len
B. length
C. size
D. Tuplen for tuples, listlen for lists, strlen for strings
A. <!-- text -->
B. # text
C. // text
D. /* text */
E. ^^ text ^^
A. "
B. """
C. '''
D. All of these are correct,
E. '
A. Repeats string1 string2 times (string2 must be in numeric format).
B. Concatenates string1 and string2.
C. It's a syntax error.
D. Adds string1 to string2 (both must be in numeric format).
A. "hello" * 2
B. "hello" ** 2
C. len ( "hello" )
D. "hello" + "hello"
A. A statement which allows you to choose one variant from a given set
B. A collection of elements, each identified by an index
C. An object which may contain some data
D. An object containing data whose value cannot be altered by the program
A. !=
B. isn't
C. =/=
D. ><
E. >=
A. With the "function" keyword.
B. With the "def" keyword.
C. With function prototypes declared in header files.
D. With "do function ... done".
A. Only HTTP
B. Only HTTP, FTP, POP3, IMAP4
C. None of them
D. All of them
A. There is no way to pass parameters to a class instance.
B. Specifying those parameters after the class name.
C. Specifying those parameters in the definition of an __init__ method of the class.
D. Writing the desired values after the class name when the class instance is created.
A. To remove a function from a list given its name.
B. To remove an item from a list given its index.
C. To delete a file from the file system given its path.
D. To delete a user if you are a privileged user.
A. False
B. True
A. x = list{'1', '2', '3'}
B. x = list(1, 2, 3)
C. x = {'1', '2', '3'}
D. x = [1, 2, 3]
E. x = new list (1, 2, 3)
A. elseif:
B. elif:
C. if:
D. else:
A. import date date.pause(5)
B. import time time.sleep(5)
C. import date date.pause(5.0)
A. 2
B. None and the system generates an error (exception)
C. None
D. 1
E. 3
A. l.len()
B. len(l)
C. length(l)
D. l.length()
A. i mod j
B. i % j
C. i // j
D. i / j
A. for i in range(11): print i
B. for( x = 0; x < 11; x++) printf("%s",x);
C. while x < 10: print x
D. for i in range(10): print i