Is Python Case Sensitive When Dealing With Identifiers?

Question: Is Python case sensitive when dealing with identifiers?

Possible Answers:

a) Yes
b) No
c) Machine Dependent
d) None of the Mentioned

The answer is A, yes, Python is a case-sensitive language.

This means that identifiers (such as variable names, function names, and class names) are treated as distinct based on their case. For example, the identifier “myVariable” is different from “myvariable” and “MYVARIABLE” in Python.

It is a good practice to use a consistent naming convention for identifiers in your code. One common convention is to use lowercase letters for variables and functions, and to use CamelCase (with the first letter of each word capitalized) for class names.

Here is an example of how Python treats case sensitivity in identifiers:

# These are all different identifiers myVariable = 10 myvariable = 20 MYVARIABLE = 30 print(myVariable) # Output: 10 print(myvariable) # Output: 20 print(MYVARIABLE) # Output: 30
Code language: PHP (php)

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *