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
Letters | A – Z, a – z |
Digits | 0 – 9 |
Special symbols | Space + – * / ** () [] {} // = != == < > . ‘’ “” ‘”’” , : ; % ! & # <= >= @ _(underscore) |
Whitespaces | Blank Space, tabs, carriage return, new line, form feed. |
Other characters | Python 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
- Keywords
- Identifiers (Name)
- Literals
- Operator
- 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
- An identifier is an arbitrarily long sequence of letters and digits.
- The first character must be a letter; the underscore (_) counts as a letter.
- Upper- and lower-case letters are different. All characters are significant
- The digits 0 though 0 can be part of the identifier except for the first character.
- Identifiers are unlimited in length. Case in significant i.e., python is case sensitive as it treats upper and lowercase characters differently.
- An identifier cannot contain any special character expert for underscore (_).
- An identifier must not be a keyword of python.
- Example for valid identifiers
- Myname
- Myfile
- _ok
- Date_78_6
- 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:
- String literals
- Numeric literals
- Boolean literals
- Special literals NONE
- 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:
- Unary Operators
- 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