Basic Concepts of Python Programming
There are Five Important basic concepts of python. These five are called as tokens.
- Identifiers
- Keywords
- Operators
- Delimiters
- Literals
Identifiers or Variables
An identifier or variables are used to identify a variable, functions, objects, and class. You can easily understand variables as variable = vary + able vary means change and able means it happens. variables can be changed from person to person. for example,
- name=input(“Enter your name”) # name is variable
- age=int(input(“Enter your age”)) #age is variable
If you want a name means you give name as a variable and if you want age means you give age as a variable. but Keywords are not used for variables. we can see keywords in the next topic.
Some important rule to write identifiers
- An Identifiers must start with alphabet (A to Z or a to z) and underscore( _ )
- It does not allow punctuation character such as %,$, @, etc.,
- Identifiers must not be a python keyword.
Valid and Invalid Identifiers
- Reg_no – Valid Identifier
- name&name – Invalid Identifier
- num1 – Valid Identifier
- 1num – Invalid Identifier
Keywords
Keywords are special or reversed words. It already built-in by a python interpreter for doing some specific tasks. Keywords are not used for any other purpose. Examples for keywords are, if, else, def, in, class, for, while, and, return, etc.
Operators
There are various types of Operations,
- Arithmetic Operator
- Logical Operator
- Relational Operator
- Assignment Operator
- Bitwise Operator
- Conditional Operator
- Membership Operator
- Identity Operator
An operator is a huge concept. so, I cover the content in the next new post. Let move on
Delimiters or Punctuation
Python uses symbols in various fields such as list, tuple, dictionary, etc.
Literals or Constant
Literals are three types. They are,
- Numeric
- Strings
- Boolean
Numeric
Numeric Literals consist of digits and are immutable (unchangeable). Numeric literals
can be classification into 3 types,
- Integer – Whole number
- float – Decimal number
- complex – 1 + 3.14 j
Strings
In Python, a string literal is a sequence of characters surrounded by quotes. Python
supports single, double, and triple quotes for a string. A character literal is a single character surrounded by single or double-quotes. The value with triple-quote “‘ ‘” is used to give multi-
line string literal.
- “Single Line Strings”
- “‘ This is for multiline strings “‘
Boolean
A Boolean literal can have either True or False.
- True – Condition is satisfied based on condition
- False – Condition is not satisfied based on condition
My Previous Post
Core Parts of Python: https://iterathon.tech//core-parts-of-python-idle-input-and-output/
LEARN LITTLE BY LITTLE TO CHANGE THE TECH WORLD