You are on page 1of 5

Branchwise MCQs School MCQs DSA Tests Jobs Internship Training Videos Books Contact

1000 Python MCQs


Python Questions and Answers – Variable Names
Next »

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Variable Names”.

1. Is Python case sensitive when dealing with identifiers?


a) yes
b) no
Python MCQ - Variable c) machine dependent
Names, Operators & d) none of the mentioned
Data Types
View Answer
Python Variable Names
Related Topics
Python Basic Operators Answer: a
Explanation: Case is always significant while dealing with identifiers in python. Python MCQ Questions
Python Core Data Types
Linked List Programs in Python
Python Numeric Types
2. What is the maximum possible length of an identifier?
Searching and Sorting in Python
Python MCQ - a) 31 characters
Precedence & b) 63 characters Python Programs on Trees
Associativity, Bitwise c) 79 characters Python Programs on Graphs
d) none of the mentioned
Python Precedence
Associativity - Set 1 View Answer
Python Precedence
Associativity - Set 2 Answer: d
Explanation: Identifiers can be of any length.
Python Bitwise - Set 1
Python Bitwise - Set 2
3. Which of the following is invalid?
Python Boolean a) _a = 1
b) __a = 1
Python MCQ - Formatting
& Decorator
c) __str__ = 1
d) none of the mentioned
Python Formatting - Set 1
View Answer
Python Formatting - Set 2
Python Advance Formatting Answer: d
Explanation: All the statements will execute successfully but at the cost of reduced readability.
Python Decorators

Python MCQ - While &


For Loops Subscribe Now: Python Newsletter | Important Subjects Newsletters

Python While & For Loops -


Set 1 advertisement
Python While & For Loops -
Set 2
Python While & For Loops -
Set 3
Python While & For Loops -
Set 4 Popular Pages
Python While & For Loops -
Python Programming Examples
Set 5
C# String Programs
Python While & For Loops -
Set 6 String Programs in C++

Python MCQ - Strings String Programs in C


Visual Basic MCQ Questions
Python Strings - Set 1
Python Strings - Set 2 4. Which of the following is an invalid variable?
a) my_string_1
Python Strings - Set 3 b) 1st_string
Python Strings - Set 4 c) foo
Python Strings - Set 5
d) _

Python Strings - Set 6 View Answer

Python Strings - Set 7


Answer: b
Python Strings - Set 8 Explanation: Variable names should not start with a number.
Python Strings - Set 9
Python Strings - Set 10 5. Why are local variable names beginning with an underscore discouraged?
a) they are used to indicate a private variables of a class
Python Strings - Set 11 b) they confuse the interpreter
Python Strings - Set 12 c) they are used to indicate global variables
d) they slow down execution
Python Strings - Set 13
View Answer
Python MCQ - Lists Answer: a
Explanation: As Python has no concept of private variables, leading underscores are used to indicate variables that
Python Lists - Set 1 must not be accessed from outside the class.
Python Lists - Set 2
Python Lists - Set 3 Become Top Ranker in Python Programming Now!
Python Lists - Set 4
Python Lists - Set 5 6. Which of the following is not a keyword?
Python Lists - Set 6 a) eval
Python Lists - Set 7
b) assert
c) nonlocal
Python MCQ - List d) pass
Comprehension
View Answer
Python List Comprehension
Python List Comprehension - Answer: a
Set 1 Explanation: eval can be used as a variable.
Python List Comprehension -
Set 2 7. All keywords in Python are in _________
a) lower case
Python Matrix List
Comprehension
b) UPPER CASE
c) Capitalized
Python MCQ - Tuples d) None of the mentioned
Python Tuples - Set 1 View Answer
Python Tuples - Set 2
Answer: d
Python Tuples - Set 3 Explanation: True, False and None are capitalized while the others are in lower case.
Python MCQ - Sets
8. Which of the following is true for variable names in Python?
Python Sets - Set 1
a) unlimited length
Python Sets - Set 2 b) all private members must have leading and trailing underscores
Python Sets - Set 3 c) underscore and ampersand are the only two special characters allowed
d) none of the mentioned
Python Sets - Set 4
View Answer
Python Sets - Set 5

Python MCQ - Dictionary Answer: a


Explanation: Variable names can be of any length.
Python Dictionary - Set 1
Python Dictionary - Set 2
9. Which of the following is an invalid statement?
Python Dictionary - Set 3 a) abc = 1,000,000
Python Dictionary - Set 4 b) a b c = 1000 2000 3000
c) a,b,c = 1000, 2000, 3000
Python MCQ - Built-in d) a_b_c = 1,000,000
Functions
View Answer
Python Built-in Functions -
Set 1
Answer: b
Python Built-in Functions - Explanation: Spaces are not allowed in variable names.
Set 2
Python Built-in Functions - 10. Which of the following cannot be a variable?
Set 3 a) __init__
b) in
Python MCQ - Functions
c) it
Python Function - Set 1 d) on
Python Function - Set 2 View Answer
Python Function - Set 3
Answer: b
Python Function - Set 4
Explanation: in is a keyword.
Python MCQ - Argument
Passing, Variables & Sanfoundry Global Education & Learning Series – Python.
Recursion

Python Argument Passing - To practice all areas of Python, here is complete set of 1000+ Multiple Choice Questions and Answers.
Set 1
» Next - Python Questions and Answers – Basic Operators
Python Argument Passing -
Set 2
Python Global vs Local
Next Steps:
Variables - Set 1
Get Free Certificate of Merit in Python Programming
Python Global vs Local Participate in Python Programming Certification Contest
Variables - Set 2 Become a Top Ranker in Python Programming
Python Recursion Take Python Programming Tests
Python Shallow Copy vs Deep
Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Copy Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Python MCQ - Mapping


Functions
Python Functional Tools Related Posts:
Python Mapping Functions -
Set 1 Buy Python Books
Python Mapping Functions - Apply for Programming Internship
Set 2 Apply for Python Internship
Practice Programming MCQs
Python Mapping Functions - Buy Information Technology Books
Set 3

Python MCQ - Modules


Python MCQ
Python Modules
Python Math - Set 1 Recommended Articles:
1. C Programming Questions and Answers – Variable Names – 1
Python Math - Set 2
2. Python Program to Check String is Palindrome using Stack
Python Math - Set 3 3. C Programming Questions and Answers – Variable Names – 2
Python Datetime Module - 4. Python Program to Swap Two Numbers without using Third Variable
Set 1 5. Python Program to Implement Stack
6. Python Program to Reverse a Stack using Recursion
Python Datetime Module -
7. Python Program to Calculate the Length of a String Without using Library Functions
Set 2
8. Python Questions and Answers – Python Modules
Python Random Module - Set 9. Python Questions and Answers – Strings – 11
1 10. Python Program to Check Expression is Correctly Parenthesized
Python Random Module - Set
2
Python Sys Module
Python Operating System
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of
Python Turtle Module - Set 1 Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!
Python Turtle Module - Set 2
Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Python Turtle Module - Set 3
Python Pickle Module
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at
Python MCQ - Regular Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN
Expressions Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.
Python Regular Expressions
Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.
Python Regular Expressions -
Set 1
Python Regular Expressions -
Set 2
Python Regular Expressions -
Set 3
Python Regular Expressions -
Set 4
Python Regular Expressions -
Set 5

Python MCQ - Files

Python Files - Set 1


Python Files - Set 2
Python Files - Set 3
Python Files - Set 4
Python Files - Set 5

Python MCQ - Classes &


Objects

Python Operator
Overloading
Python Classes & Objects -
Set 1
Python Classes & Objects -
Set 2

Python MCQ - Python


OOPs

Python Inheritance - Set 1


Python Inheritance - Set 2
Python Polymorphism
Python Encapsulation

Python MCQ - Exception


Handling

Python Exception Handling -


Set 1
About | Certifications | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2023 Sanfoundry. All Rights Reserved.

You might also like