Learn How To Code: Python Tutorial

Pages

Friday, 27 December 2019

Python Tutorial

            Python Keywords, Python Identifiers

                               
                               
python, python tutorial, python programming,learn python, python programming language,python tutorial for beginners, learn python programming, how to learn python, python programming tutorial, python for beginners, python course, python crash course, python language, python3, python basics, python learning, what is python programming

Python Keywords:

Keywords are the reserved words in Python.
We cannot use a keyword as a variable namefunction name or any other identifier. They are used to define the syntax and structure of the Python language.
In Python, keywords are case sensitive.
There are 33 keywords in Python 3.7. This number can vary slightly in the course of time.
All the keywords except TrueFalse and None are in lowercase and they must be written as it is. The list of all the keywords is given below.
Keywords in Python
Falseclassfinallyisreturn
Nonecontinueforlambdatry
Truedeffromnonlocalwhile
anddelglobalnotwith
aselififoryield
assertelseimportpass
breakexceptinraise

Python Identifiers:

An identifier is a name given to entities like class, functions, variables, etc. It helps to differentiate one entity from another.

Rules for writing identifiers

  1. Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore _. Names like myClassvar_1 and print_this_to_screen, all are valid example.
  2. An identifier cannot start with a digit. 1variable is invalid, but variable1 is perfectly fine.
  3. Keywords cannot be used as identifiers.
    1. >>> global = 1
    2. File "<interactive input>", line 1
    3. global = 1
    4. ^
    5. SyntaxError: invalid syntax
  4. We cannot use special symbols like !@#$% etc. in our identifier.
    1. >>> a@ = 0
    2. File "<interactive input>", line 1
    3. a@ = 0
    4. ^
    5. SyntaxError: invalid syntax
  5. An identifier can be of any length.

Things to Remember

Python is a case-sensitive language. This means, Variable and variable are not the same. Always name identifiers that make sense.
While, c = 10 is valid. Writing count = 10 would make more sense and it would be easier to figure out what it does even when you look at your code after a long gap.
Multiple words can be separated using an underscore, this_is_a_long_variable.
This is the  part2 of python learning do follow us for staying updated by submitting your email_id on feed burner section on a web page
and for the advanced section, you can follow us on Github https://gist.github.com/SANTOSHSHARMA11
PART2 ends'

No comments:

Post a Comment

Please do follow us for staying updated.
give your comment Formal way , if you have any doubt contact us

Our Popular Post