Variables
We used variables to store the value to use them later. A
variable is like a label, and we use “=” symbol known as the assignment
operator to assign value to a variable.
For
Example:-
a=23
b=28
c=a+b
print(c)
Variable
Type:-
There are two main types of Variables in Python. These are
Integer and Float. The most
important difference between them is that a float is a number that has a
decimal point, and an int is a number without a decimal point.
For
Example:-
float_number = 25.0
print(type(float_number))
# print type of variable "float_number"
number = 45
print(type(number)) #
print type of variable “number”
Type
Conversion:-
There are a lot of Buit in functions that let you convert
data from one data type to another.We can easily convert one data type to
another because of buit in function.We can convert int to Float and Float to
Int.
For
Example:-
number = 9
print(type(number)) #
print type of variable "number"
float_number = 9.0
print(float_number)
print(int(float_number))
Arithmetic
Operators:-
Python Language also have Arithmetic Operators like other
programming Languages like addition,Substraction,Division and Multiplication.In
addition, Python has the power(**) and Modulo(%) Operator.
For
Example:-
a = 45
b = 23
c = 12
d=a+b*c
print(d)
Boolean
Operators:-
Boolean is a type of value that can only be True or False. In
the Boolean Operators , Two Operators are compared to each other.
For
Example:-
two = 2
three = 3
is_equal = two == three
print(is_equal)
Assignments:-
Augmented assignment is a single statement combining a binary
operation and an assignment statement such as +=, -=, etc.
For
Example:-
number = 25
print("number = " + str(number))
number -= 3
print("number = " + str(number))
number += 12
print("number = " + str(number))
Usefull
ReplyDelete