Page 298 - Artificial Intellegence_v2.0_Class_9
P. 298

Python Character Set

        A character set can be a set of valid characters. For example,

           • Digit like 0, 1, 2, …. 9
           • Letters in upper or lowercase like A to Z or a to z
           • Special symbols like $, %, ^, &, *, (), @, !, etc.
           • Whitespaces like spacebar, Tab key or Enter key
           • ASCII or UNICODE characters like emoji symbols or other symbols with unique code.


                 Statements in Python

        Instructions written in a source code that are executed by a Python interpreter are called statements. There are
        three types of statements in Python which are simple statements, multiline statements and multiple statements.
        Let us learn about them in detail.


        Simple Statements
        By default, the end of a statement is done by pressing an Enter key. Each statement is written on a new line.
           a=5 is a simple statement where variable 'a' is created with value 5.

           c=a + b

        Multiline Statements

        We can make a statement that extends over multiple lines by using line continuation character (\) as shown
        below:

           a = 4 + 5 +\
                     6 + 7 +\
                     8 + 9

        The main advantage of using multiline is when we need to do long calculations and cannot fit these statements
        into one line.


        Multiple Statements
        Multiple statements represent more than one statement in a single line. This can be done by separating the
        statements using semicolon (;).

           a = 5; b = 10; c = a + b; print(c)

                 Tokens


        Tokens are the smallest meaningful unit of a program. Python supports the various tokens. Let us learn about them.

        Keywords

        Words that have special meaning are reserved by Python for special purposes and are not allowed to be used
        as identifiers. We can see the list of the reserved keywords by giving the following command at the python
        command prompt:

             >>> import keyword
             >>>keyword.kwlist
              296     Touchpad Artificial Intelligence (Ver. 2.0)-IX
   293   294   295   296   297   298   299   300   301   302   303