What is python?
Python is an object oriented programming language. It is easy to understand and a high level language. Python was developed by “Guido Van Rossum” .
Statements in Python language: like the other languages python also included if statement, while loop, for loop, do while loop, continue statement , pass statement , break statement etc.
Use of python : python is used for web development, software development, system scripting.
Creation of a variable in python: to create a variable python doesn’t have any command.
EXAMPLE for creating a variable :
x = 5
y = "VISHANK"
print(x)
print(y)
Simple example of python program :
x = 4 # x is of type int
x = "Sally" # x is now of type str
print(x)
Operators in python : Python has some operators like the other languages. And these are as follows-
1.) Arithmetic operators : these are the operators by which we can do the arithmetic operations. These operators are –
a.) addition (+)
Example : a+b;
b.) Subtraction : (-)
Example : a-b;
c.) Multiplication: (*)
Example: a*b;
d.) Division (/)
Example : a/b;
e.) Modulus : (%)
Example : a%b;
f.) Exponentiation (**)
Example : a**b;
g.) Floor division (//)
Example : a//b;
2.) Assignment operator: with the use of these operators we can assign the values.
a.) =
Example: x=a;
b.) +=
Example : x=x+a;
c.) -=
Example : x=x-a;
d.) *=
Example : x=x*a;
e.) /=
Example : x=x/a;
f.) %=
x=x%a;
g.) //=
Example : x=x//a;
h.) **=
Example : x=x**a;
i.) &=
Example : x=x&a;
j.) |=
Example : x=x|a;
k.) ^=
Example : x=x^a;
l.) >>=
Example : x=x>>a;
j.) <<=
Example : x=x<<a;
3.) Comparison operator : with the help of these operator we can compare the values.
a.) Equal (==) example: a==b;
b.) Not equal (!=) example: a!=b;
c.) Greater then (>) example: a>b;
d.) Less then (<) example: a<b;
e.) Greater then or equals to (>=) example : a>=b;
f.) Less then or equals to (<=) example : a<=b;
4.) Logical operators : are the operators which help to combine the conditional statement.
a.) And : it returns true if both conditions are true.
Example: x>a and x<b;
b.) OR : it returns true if one of the statement is true.
Example : x>a or x<b;
c.) Not : it reverse the result.
Example : x>a not x<b;
5.) Identity operators: these operators are used to compare the object. If they have the same object.
a.) Is : it returns true if both variables have the same object.
Example : x is y;
b.) Is not : if both variable have the same object.
Example : x is not y;
6.) Membership operator : are the operators tests if a sequence presented in an object.
a.) In : Example: a in b;
b.) Not in : a not in b;
7.) Bitwise operators : are used to compare binary numbers.
These are as follows
AND,OR,XOR ,NOT,Zero fill left shift, and Signed right shift.