Python Fundamentals

python fundamentals

Python fundamentals is craziest as we are going to learn about fundamentals of python to write a code in python. This is our promise by the end of this module you can able to write a program(code) using python.

Python Character Set

  • It is a set of valid characters that a language can recognize.
  • A character means any letter, digit or any other symbol.
  • Python supports UNICODE ENCODING STANDARD.
  • Python have the following character set
LettersA – Z, a – z
Digits0 – 9
Special symbolsSpace + – * / ** () [] {} // = != == < > . ‘’ “” ‘”’” , : ; % ! & # <= >= @ _(underscore)
WhitespacesBlank Space, tabs, carriage return, new line, form feed.
Other charactersPython can process all ASCII and UNICODE characters as part of data or literals.

Tokens

  • It can be defined as the smallest individual unit in a program is known as a token.
  • In other words, we can say it as lexical unit or lexical element.
  • In python there are basically 5 types of tokens are there that are as follows
    1. Keywords
    2. Identifiers (Name)
    3. Literals
    4. Operator
    5. Punctuator
  • These are the important python fundamentals used to write a basic python program

1. Keywords

  • It can be defined as these are the reserved word having special meaning and it is reserved by the programming language.
  • These words convey a special meaning to the language complier/interpreter.
  • This word cannot be used as identifier (give name).
  • These fundamentals of python are used in different parts of a program.
  • There are 33 keywords are there in python that are:
False               class               from                or             None                continue            global              pass                 True                def                 if                  raise                  and                 del                 import              return             as                  elif                in                     try                   assert              else                    is                  while              async            except           lambda              with await               finally             nonlocal            yield             break               for                 not

2. Identifiers (names)

  • This is the fundamental building blocks of a program and are used as the general terminology for the names given to different parts of the program viz. variables, objects, classes, functions, lists, dictionaries etc.
  • Rules of using identifier in python
    1. An identifier is an arbitrarily long sequence of letters and digits.
    2. The first character must be a letter; the underscore (_) counts as a letter.
    3. Upper- and lower-case letters are different. All characters are significant
    4. The digits 0 though 0 can be part of the identifier except for the first character.
    5. Identifiers are unlimited in length. Case in significant i.e., python is case sensitive as it treats upper and lowercase characters differently.
    6. An identifier cannot contain any special character expert for underscore (_).
    7. An identifier must not be a keyword of python.
    8. Example for valid identifiers
      • Myname
      • Myfile
      • _ok
      • Date_78_6
    9. Example for non-valid identifiers
      • Data-rec
      • 25name
      • finally
      • halfwork
  • If you will Not going through these python fundamentals will make mistake in code.

3. Literals in Python

  • A fixed numeric or non-numeric value is know as literal.
  • It can be defined as a number, text, or other data that represents values to be stored in variables.
  • In general literals(python fundamentals) are of 5 types that are:
    1. String literals
    2. Numeric literals
    3. Boolean literals
    4. Special literals NONE
    5. Literal collection

4. Operators

  • It can be defined as a symbol or a word that performs some kind of operation on given values and return the result.
  • In python it of two different types that are:
    1. Unary Operators
    2. Binary Operators

5. Punctuators

  • It can be defined as the symbols that are used in a programming language to organize programming sentences structures, and to separate the values or to enclose some values.
  • In other words, punctuators can be called as Delimiters.
  • For example, ‘ “  #  \  ()  []   {}  @  ,  :  .  –  =

Note :-

  • Learn Python Programing from basics – Click here
  • How To Install Python in Very Easy Steps – Click here
  • Operators in Python– Click here