Data Types and Operators in Python
import sys import keyword print("python keywords: ",keyword.kwlist)
The syntax for Python relies heavily on indentation, blocks of code are denoted by line indentation these indentations are rigidly enforced, The number of spaces in the indentation should be consistent in a block of code. Statements in python generally end with a new line, python, however, uses the line continuation character \ backward slash to denote that the line is continuing. Statements within square bracket [ ] curly bracket { } and parentheses ( ) need not to use the line continuation characters to start a new line. Python allows multiple statements on a single line separated by a semicolon. Print (“Statement1”); print(“Statement2”)
Python allows Single quote ‘word’ Double quote “A sentence” and Triple quotes “""A paragraph””” to denotes string literals, remember to use the same type of quote to start and end the string. Triple quotes are used to extend the string across multiple lines. Also, a # hash sign is considered as a comment by python. The interpreter ignores and takes all the characters as a comment that is used after a hash to the physical line. Python allows command-line arguments which means you can provide input via command line making it interactive.
A classic example of standard data types is a person's age needs to be stored as a numeric value and then his or her address needs to be stored as alphanumeric characters. Python has five standard data types. They are used to define the operation and storage for each of them so these data types are:
There are six basic data types supported in python data types that tell us about what kind of values can be stored in a variable and which operations can be performed on each of them. The python language has an extensive set of operators, they are classified into different categories there is also an order of preference in which order the operators get used in the evaluation of expressions. Python has
Arithmetic Operators to carry out
It has a comparison operators to compares the operands this could to check
It has a assignment operators combined with standard arithmetic operators eg. a+=b is same as a = a+b
Python also has a Logical Operators such as
In addition python has Membership Operators to check if something is a member of sequence or not.There are two membership operators
Python has Identity Operators to compare the memory locations of two objects