PYTHON FUNDAMENTALS
PYTHON FORÂ CBSE CLASS 11
Character Set is a valid set of characters that a language recognizes. It could be any letter, digit or any symbol. Python has the following character set:
Letters | A – Z, a – z |
Digits | 0 – 9 |
Special Symbols | Space + – * / % // ( ) [ ] { } \ # , ; :: ‘ ‘ “ “ @ _ < > = & ** != == |
Whitespaces | Blank Space, tabs, carriage return (enter sign), newline, formfeed |
Other characters | Python can process all ASCII and UNICODE characters. |
TOKENS
The smallest individual unit in a program is called as Token or a lexical unit.
Python for cbse class 11 has following tokens:
Keywords                   Identifiers                   Literals                       Operators                   Punctuators
Keywords:Â Â Â Â Â Â A keyword is a word having special meaning reserved by programming language.
Eg:-Â Â Â Â False, True, print, id, and, or, not
Identifiers:     Identifiers are the names build by programmer and are used in program but are not keywords. Python has some rules to form an identifier –
           — An identifier is a long sequence of letters and digits with unlimited length.
           — The first character could be a letter or an underscore ( _ ).
           — Upper case and lower case is differently processed i.e. A is not process as a.
             Python is case sensitive language.
           — The digit 0 to 9 could be a part of identifier but cannot be the first character.
           — Identifier cannot contain any special character.
Eg:-    Valid Identifiers: Name                     _DT                Z12345           My_File
           Invalid Identifiers:     29Abc My.File           False               dat$comp
Literals / Values:Â Â Â Â Â Â Â Literals are also called constant values are data items have fixed values.
Python allows following literals.
         — String Literals:       These are created by enclosing text in single quotes or double quotes.
Eg: “ Hello World “  ,  ‘ My name is Sara ‘
               — Numeric Literals:   These could be integer types, floating types or complex types.
Integer literal:Â These are whole numbers without any fractional part. These could be positive ( + ) or negative ( – ). Eg: 125, -78, +86
Floating literal: These have fractional part and could be represented in Fractional form or   Exponent form. Eg: 13.8, 2.0, -63.556 (fractional)
        1.7E, 0.58E02 (exponent form)
                       — Boolean literal: This could be either 0 or 1. 1 means True and 0 means False.
                       — Special Literal None: The None literal indicates the absence of value. It is also used to
                                                              indicate the end of the lists in Python.
           Operators:      These are used to perform operations on values and variables. They trigger some  Â
                                  computation. Â
                       — Unary Operators: They only need one operand to operate upon.
                                             +         Unary Plus                 (Eg: +63, 951)
-       Unary Minus              (Eg:  -25, -3.65)
~Â Â Â Â Â Â Â Â Â Bitwise Complement (Eg:Â 8 bits-Â Â complement(0) is 11111111Â )
not      Logical negation        (Eg:  if x = 1, not x = 0 )
                       — Binary Operators:   They need two operand to operate upon.
                   Arithmetic Operators             ( + – * / // % ** )
                   Identity operators                  ( is      is not )
                   Relational Operators              ( < > <= >= == != )
                   Assignment Operators       = /= += -= %= //= **= *=
                                               Logical Operators                  and                 or
                                               Membership Operators           in                    not in
           Punctuators:   Theses are symbols that are used in programming languages to organize structures,
                                   statements, expressions.
                                   Eg:      ‘ “ # \ ( ) { } [ ] @ : , =