Python Online Quiz


Advertisements


Following quiz provides Multiple Choice Questions (MCQs) related to Python. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - Which of the following environment variable for Python is an alternative module search path?

A - PYTHONPATH

B - PYTHONSTARTUP

C - PYTHONCASEOK

D - PYTHONHOME

Answer : D

Explanation

PYTHONHOME − It is an alternative module search path. It is usually embedded in the PYTHONSTARTUP or PYTHONPATH directories to make switching module libraries easy.

Q 2 - What is the output of print tinylist * 2 if tinylist = [123, 'john']?

A - [123, 'john', 123, 'john']

B - [123, 'john'] * 2

C - Error

D - None of the above.

Answer : A

Explanation

It will print list two times. Output would be [123, 'john', 123, 'john'].

Q 3 - What is the output of print tuple[0] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?

A - ( 'abcd', 786 , 2.23, 'john', 70.2 )

B - abcd

C - Error

D - None of the above.

Answer : B

Explanation

It will print first element of the list. Output would be abcd.

Q 4 - Which of the following function convert a String to a set in python?

A - set(x)

B - dict(d)

C - frozenset(s)

D - chr(x)

Answer : A

Explanation

set(s) − Converts s to a set.

Q 5 - Which of the following function convert an integer to an unicode character in python?

A - unichr(x)

B - ord(x)

C - hex(x)

D - oct(x)

Answer : A

Explanation

unichr(x) − Converts an integer to a Unicode character.

Q 6 - Which of the following operator in python evaluates to true if it does not finds a variable in the specified sequence and false otherwise?

A - **

B - //

C - is

D - not in

Answer : D

Explanation

not in − Evaluates to true if it does not finds a variable in the specified sequence and false otherwise. x not in y, here not in results in a 1 if x is not a member of sequence y.

Q 7 - Which of the following function checks in a string that all characters are numeric?

A - islower()

B - isnumeric()

C - isspace()

D - istitle()

Answer : B

Explanation

isnumeric() − Returns true if string has at least 1 character and all characters are numeric.

Q 8 - Which of the following function converts a string to all lowercase?

A - lower()

B - lstrip()

C - max(str)

D - min(str)

Answer : A

Explanation

lower() − Converts all uppercase letters in string to lowercase.

Q 9 - What is the output of 3 in [1, 2, 3]?

A - true

B - false

C - Error

D - None of the above.

Answer : A

Explanation

true

Q 10 - What is the following function returns item from the list with min value?

A - cmp(list)

B - len(list)

C - max(list)

D - min(list)

Answer : D

Explanation

min(list) − Returns item from the list with min value.


python_questions_answers.htm

Advertisements