Lesson 02   Python Keywords and Identi ers Perth AI School
Python Keywords and Identi ers (Variable names) In this tutorial, you will learn about keywords (reserved words in Python) and identi ers (names given to variables, functions, etc.). Python Keywords Keywords are the reserved words in Python. We cannot use a keyword as a variable name, function name or any other identi er. They are used to de ne 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 over the course of time. All the keywords except , and are in lowercase and they must be written as they are. The list of all the keywords is given below. True False None False await else import pass None break except in raise True class nally is return and continue for lambda try as def from nonlocal while assert del global not with async elif if or yield Looking at all the keywords at once and trying to gure out what they mean might be overwhelming.
Python Keywords and Identi ers (Variable names) Python Identi ers An identi er is a name given to entities like class, functions, variables, etc. It helps to di erentiate one entity from another. Rules for writing identi ers 1. Identi ers can be a combination of letters in lowercase or uppercase or digits or an underscore . Names like , and , all are valid example. (a to z) (A to Z) (0 to 9) _ myClass var_1 print_this_to_screen 2. An identi er cannot start with a digit. is invalid, but is a valid name.1variable variable1 3. Keywords cannot be used as identi ers. =global 1 Output File "<interactive input>", line 1 global = 1 ^ SyntaxError: invalid syntax 4. We cannot use special symbols like , , , , etc. in our identi er.! @ # $ % a@ = 0 Output File "<interactive input>", line 1 a@ = 0 ^ SyntaxError: invalid syntax 5. An identi er can be of any length. Things to Remember Python is a case-sensitive language. This means, and are not the same.Variable variable
Python Keywords and Identi ers (Variable names) Always give the identi ers a name that makes sense. While is a valid name, writing would make more sense, and it would be easier to gure out what it represents when you look at your code after a long gap. c = 10 count = 10 Multiple words can be separated using an underscore, like .this_is_a_long_variable

Lesson 02 python keywords and identifiers

  • 1.
    Lesson 02   Python Keywordsand Identi ers Perth AI School
  • 2.
    Python Keywords andIdenti ers (Variable names) In this tutorial, you will learn about keywords (reserved words in Python) and identi ers (names given to variables, functions, etc.). Python Keywords Keywords are the reserved words in Python. We cannot use a keyword as a variable name, function name or any other identi er. They are used to de ne 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 over the course of time. All the keywords except , and are in lowercase and they must be written as they are. The list of all the keywords is given below. True False None False await else import pass None break except in raise True class nally is return and continue for lambda try as def from nonlocal while assert del global not with async elif if or yield Looking at all the keywords at once and trying to gure out what they mean might be overwhelming.
  • 3.
    Python Keywords andIdenti ers (Variable names) Python Identi ers An identi er is a name given to entities like class, functions, variables, etc. It helps to di erentiate one entity from another. Rules for writing identi ers 1. Identi ers can be a combination of letters in lowercase or uppercase or digits or an underscore . Names like , and , all are valid example. (a to z) (A to Z) (0 to 9) _ myClass var_1 print_this_to_screen 2. An identi er cannot start with a digit. is invalid, but is a valid name.1variable variable1 3. Keywords cannot be used as identi ers. =global 1 Output File "<interactive input>", line 1 global = 1 ^ SyntaxError: invalid syntax 4. We cannot use special symbols like , , , , etc. in our identi er.! @ # $ % a@ = 0 Output File "<interactive input>", line 1 a@ = 0 ^ SyntaxError: invalid syntax 5. An identi er can be of any length. Things to Remember Python is a case-sensitive language. This means, and are not the same.Variable variable
  • 4.
    Python Keywords andIdenti ers (Variable names) Always give the identi ers a name that makes sense. While is a valid name, writing would make more sense, and it would be easier to gure out what it represents when you look at your code after a long gap. c = 10 count = 10 Multiple words can be separated using an underscore, like .this_is_a_long_variable