PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 41


Which of the following words can be used as a variable name? (Choose two.)

Show Answer
Correct Answer: CD

In Python, variable names must adhere to certain rules. They cannot be reserved words (keywords) in the language. The words 'for' and 'True' are reserved keywords and thus cannot be used as variable names. The word 'true' is not a reserved keyword because it does not follow Python's capitalization for booleans, and 'For' is simply a capitalized version of 'for' and is therefore not a keyword. Consequently, both 'true' and 'For' can be used as variable names.

Discussion

7 comments
Sign in to comment
AtulVSharmaOptions: CD
Oct 21, 2021

C and D are correct answers

macxszOptions: CD
May 3, 2022

C. true D. For

dicksonpwc
Mar 24, 2023

correct answer should be A and B

noobplayer
Apr 1, 2023

No these are reserved keywords in Python , you cannot use them as variable name

dicksonpwc
Apr 12, 2023

Correct answer should be A and B Python Reserved Words List - Your Complete Guide There is a restriction while naming identifiers that there are some restricted words that are built-in to Python which cannot be used as an identifier. Python reserved words (also called keywords) a predefined meaning and syntax in the language which Python uses for its syntax and internal processing. In this tutorial, we will discuss what those keywords are. Table of contents Reserved words Keywords Display all keywords Check if the name is included in the reserved word list Closing Thoughts Reserved words in Python Here is the list of all the reserved words in Python. Note - This list may change with different versions of Python. Python 3 has 33 while Python 2 has 30 reserved words. True elif in try and else is while as except lambda with assert finally nonlocal yield break for not class form or continue global pass

ArulkumarOptions: CD
Apr 15, 2023

for and True as reserved words . Ans : C & D https://realpython.com/lessons/reserved-keywords/

Ello2023Options: CD
Jun 15, 2023

C&D just like indentation capitalisation can also change the code. True and False are always capital. On the other hand for, and, in etc are lowercase.

Valcon_doo_NoviSadOptions: CD
Oct 12, 2023

But it would be very unwise to call your variables like that :)