117
60.1k
Chapter:

Variables Solved MCQs

in Problem Solving and Python Programming

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Computer Science Engineering (CSE) , Information Technology Engineering (IT) , Electrical Engineering , Civil Engineering , Mechanical Engineering .

Chapters

Chapter: Variables
1.

Is Python case sensitive when dealing with identifiers?

A. yes
B. no
C. machine dependent
D. none of the mentioned
Answer» A. yes
Explanation: case is always significant.
2.

What is the maximum possible length of an identifier?

A. 31 characters
B. 63 characters
C. 79 characters
D. none of the mentioned
Answer» D. none of the mentioned
Explanation: identifiers can be of any length.
3.

Which of the following is invalid?

A. _a = 1
B.     a = 1
C.     str     = 1
D. none of the mentioned
Answer» D. none of the mentioned
Explanation: all the statements will execute successfully but at the cost of reduced readability.
4.

Which of the following is an invalid variable?

A. my_string_1
B. 1st_string
C. foo
D. _
Answer» B. 1st_string
Explanation: variable names should not start with a number.
5.

Why are local variable names beginning with an underscore discouraged?

A. they are used to indicate a private variables of a class
B. they confuse the interpreter
C. they are used to indicate global variables
D. they slow down execution
Answer» A. they are used to indicate a private variables of a class
Explanation: as python has no concept of private variables, leading underscores are used to indicate variables that must not be accessed from outside the class.
6.

Which of the following is not a keyword?

A. eval
B. assert
C. nonlocal
D. pass
Answer» A. eval
Explanation: eval can be used as a variable.
7.

All keywords in Python are in                    

A. lower case
B. upper case
C. capitalized
D. none of the mentioned
Answer» D. none of the mentioned
Explanation: true, false and none are capitalized while the others are in lower case.
8.

Which of the following is an invalid statement?

A. abc = 1,000,000
B. a b c = 1000 2000 3000
C. a,b,c = 1000, 2000, 3000
D. a_b_c = 1,000,000
Answer» B. a b c = 1000 2000 3000
Explanation: spaces are not allowed in variable names.
9.

Which of the following cannot be a variable?

A. __init__
B. in
C. it
D. on
Answer» B. in
Explanation: in is a keyword.

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.