Is Python Case Sensitive? When Dealing With Identifiers

Python is an easy-to-learn programming language. It has a user-friendly environment a beginner can effortlessly learn python, python has the simplest syntax there is no need to add semi colon at the end of each line of code like in other programming languages, and the way of declaring different functions, loops, variables, methods, libraries is also very easy but if we talk about declaring identifiers using any name and symbol in python so the answer will be no. 

A big ‘NO’ because Python is a case-sensitive language and it does not allow the declaration of an identifier with a symbol, integer, or the keywords of python.

An identifier in python can be a name of any class, variable, method, object, etc.

If python was not case-sensitive so developers will face problems while coding the same name of identifiers will cause errors and bugs in the program and the code will become confusing and difficult to understand.

Python is case sensitive so we cannot declare identifiers with the same name as Python keywords, make sure your identifier doesn’t resemble any Python keyword and with the following symbols.

An Identifier name should not start with:

  • *
  • ()
  • %
  • $
  • @
  • !
  • &
  • ^
  • With space
  • Cannot start with a number
  • Cannot be the only digit

You can declare an identifier in the following ways:

  • Can start with an underscore (_)
  • Can be in uppercase (a to z)
  • Can be in lowercase (A to Z)
  • Can be digit with letter e.g (8fm)

Make sure your identifier doesn’t match with any of the following keywords:

Falseawaitelseimportpass
Nonebreakexceptinraise
Trueclassfinallyisreturn
andcontinueforlambdatry
asdeffromnonlocalwhile
assertdelglobalnotwith
asyncElififoryield

You can check this keyword table in your python window by executing the following code line:

Help(“keywords”)

After executing the above line of code the keyword table will appear like this.

6.png

Conclusion

In this tutorial we talked about a very interesting topic, we briefly discussed is python case sensitive when dealing with identifiers.

We also discussed the reason behind its case-sensitivity and then we discussed the rules of declaring an identifier in python.

 In the end, we saw the list of python keywords and we see the line of code for checking the keyword table in our python window as well.

That’s all for today hope you like the tutorial if you have any queries regarding this article feel free to ask below. Thanks for reading.

Leave a Comment