Followers

Latest techys

Part2- Python Fundamentals | Start from the basics


If u fell any difficulty in watching the content, try to reduce the size of this page or rotate your portable device if you are using it
Prayer or High Five? This Emoji is getting people confused

 

In the previous article, we have learnt about Python Character Set and the definition of Tokens.

In today's blog we shall learn about different types of tokens one-by-one. So let's start : )

  • Python has the following tokens:
        1. Keywords: Keywords are the words that convey a special meaning to the language compiler/interpreter. There are reserved special purpose & must not be used as normal identifier names.

                             Python programming language contains the following  keyword:

                             

         2. Identifiers (Names): Identifiers are fundamental building blocks of a program & are used as the general terminology for the names given to different parts of the program viz. variables, objects, classes, functions, lists, dictionaries, etc.


Identifier forming rules of Python are being specified below:

  1. An identifier is an arbitrarily long sequence of letters & digits.
  2. The first character must be a letter, the underscore ( _ ) counts as a letter.
  3. Upper & lower-case letters are different. All characters are significant.
  4. The digits 0 through 9 can be the part of the identifier except for the first character.
  5. Identifiers are unlimited in length. Case is significant  i.e. Python is case sensitive as it treats upper & lower-case characters differently.
  6. An identifier must not be a keyword of python.
  7. An identifier cannot contain any special character except for underscore ( _ ).


The following are some valid identifiers:                   The following are some invalid identifiers:

Myfile            DATE_7_77                                          DATA-REC           contains special character -                                                                                                                           (hyphen)


MYFILE        _DS                                                        29CLCT                starting with a digit                                                        


CHK               FILE13                                                  break                     reserved keyword


Z2T0Z9   _      HJI3_JK                                                My.file                  contains special character                                                                                                                             .(dot)


        3. Literals/Values: Literals (often referred to as constant Values) are data items that have a fixed value. Python allows several kinds of literals:

                1. String literals                        2. Numeric literals                        3. Boolean literals                                4. Special Literal - None           5. Literal Collections




We shall learn about the types of literals in the next article.





No comments