-
Printing output in Python 2 :-
print "argument that you want to print"
OR
print 'argument that you want to print'
-
Mathematical operators :-
x = 8
y = 4
print x + y
# it will give output of sum of x and y
print x - y
# it will give difference of x and y
print x / y
# it will give quotient when x is divided by y
print x % y
# it is modulo function and gives remainder when x is divied by y
print x ** y
# it means x^y. it is way to represent power operator -
Single line comments can be given by putting # before a line
-
Multi line comments can be given by putting 3 double quotes before and after the lines.
example of putting multiline comments is :
""" hello
how are you """ -
To validate a variable to be an integer or a string, use
isinstance(<var>, <type>)
it accepts two parameter:- variable name
- Type to be validated
example: isinstance(a, dict) , isinstance(num, integer)
It returns True if true else False.