Why are local varia...
 
Notifications
Clear all

Why are local variable names beginning with an underscore discouraged?

2 Posts
1 Users
0 Likes
82 Views
Fahad
(@fahad)
Posts: 412
Prominent Member
Topic starter
 

Question: Why are local variable names beginning with an underscore discouraged?

 

Options are:

 

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

 

Correct answer is in first reply

 
Posted : 19/03/2023 2:09 pm
Fahad
(@fahad)
Posts: 412
Prominent Member
Topic starter
 

correct option is:

 

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.

 
Posted : 19/03/2023 2:10 pm
Share:
Scroll to Top