click below
click below
Normal Size Small Size show me how
PCAP
Python Cert Trying
| Question | Option 1 |
|---|---|
| What is the preferred naming style for variables in Python? | Snake_case is preferred (e.g., user_input), as recommended by PEP 8, Python's style guide. |
| How should you name a constant in Python? | Use all uppercase letters with underscores (e.g., MAX_SIZE), though Python doesn’t enforce constants. |
| What does PEP 8 say about naming variables with multiple words? | Use lowercase with underscores between words (e.g., total_count), not camelCase. |
| Why avoid starting a variable name with an underscore in Python? | A single leading underscore (e.g., _secret) signals a variable is private or for internal use; don’t overuse it. |
| Can you use Python keywords like for or while as variable names? | No, Python keywords are reserved; using them (e.g., for = 5) will cause a syntax error. |