0% found this document useful (0 votes)
3 views3 pages

Python Identifier Assignment

The document consists of an assignment focused on Python identifiers, divided into three parts: conceptual questions, multiple-choice questions, and brainstorming tasks. It covers topics such as rules for naming identifiers, case sensitivity, the use of keywords, and best practices according to PEP-8. Additionally, it includes practical exercises for creating valid identifiers and understanding special cases in Python.

Uploaded by

Bhuma Nithisha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Python Identifier Assignment

The document consists of an assignment focused on Python identifiers, divided into three parts: conceptual questions, multiple-choice questions, and brainstorming tasks. It covers topics such as rules for naming identifiers, case sensitivity, the use of keywords, and best practices according to PEP-8. Additionally, it includes practical exercises for creating valid identifiers and understanding special cases in Python.

Uploaded by

Bhuma Nithisha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment 1: Python Identifiers

Part A: Conceptual (Q1–Q8)

1. Define an identifier in Python.

2. What are the rules for naming identifiers in Python?

3. Can identifiers start with digits? Explain with an example.

4. Are identifiers case-sensitive in Python? Give an example.

5. Can Python keywords be used as identifiers? Why or why not?

6. Write two valid and two invalid identifiers in Python.

7. What is the difference between identifiers and variables?

8. Why are underscores _ often used in identifiers?

Part B: MCQs (Q9–Q16)

9. Which of the following is a valid identifier?


a) 123var
b) var_123
c) for
d) @name

10. Which of the following is invalid?


a) abc
b) abc
c) ab-c
d) abc123

11. Which identifier follows PEP-8 best practices?


a) studentName
b) student_name
c) Studentname
d) studentname

12. Which identifier is not valid?


a) True
b) none_value
c) _private
d) value2

13. Identifiers can include:


a) Letters, digits, underscores
b) Letters only
c) Digits only
d) Symbols like @, #

14. Python reserved words are:


a) Case-sensitive
b) Case-insensitive
c) Optional
d) None

15. Which identifier is invalid in Python 3?


a) Class
b) myClass
c) class_
d) CLASS

16. Which naming style is commonly used for constants?


a) snake_case
b) CamelCase
c) UPPERCASE
d) PascalCase

Part C: Brainstorming (Q17–Q25)

17. Write 5 valid identifiers for a program that calculates student grades.

18. Write 3 invalid identifiers and explain why they are invalid.
19. Why is __init__ a special identifier in Python?

20. Predict the output:

Value = 10
value = 20
print(Value, value)

21. Can my_variable and My_Variable refer to the same object? Why?

22. Explain why def = 5 gives an error.

23. What happens if you use print as a variable name?

24. Suggest a good identifier name for storing the radius of a circle.

25. Compare temp1, _temp, and __temp__. When are such names used?

You might also like