Data Types And Arithmetic Operation In Python!!

Data Types And Arithmetic Operation In Python!!


Data Types :


There are three types of data types are used in python.

  • Integer
  • Float
  • Boolean

Integer :


Integer stores the numbers without any fraction.

Ex : 1,2,3,4....

Float :


Float stores the number with fraction.

Ex : 1.234,3.45,2.12.....

Boolean :


Boolean  gives value either True Or False.
d
It gives True value if condition is true.

It gives False value if condition is false.


Print Variable With Different Data Types


We store different values of different datatypes in variables.

As we see we store values is like,

x = 2  → Integer

y = 3.4  → Float

z = True  → Boolean

We can directly use print() method for print the variables and as a output we will get the values store in variable also in Boolean we get True as a output.


Program :








Output :

2
3.4
True

If we write True as a true then it gives error because it is case sensitive.Boolean value must have to written as a True and False.

Arithmetic Operation In Python :


We can do arithmetic operations in two ways :

1) with predefined values

2) get value from user.

we can do arithmetic operations like Addition, Subtraction, Multiplication, Division, Modulo.

Operators used for task :


Addition  → " + "

Subtraction  → " - "

Multiplication  → " * "

Division → " / "

Modulo → " % "

1) With predefined values :

In this method we already given value to variables. ae only have to do operation.

Program :







Output : 

5

we get output 3 + 2 = 5.


2) get values from user :

we use input() method for get data from user and for arithmetic operations we also take int() or float() method for accept what type of data we stored.

Program :














Output :

Enter a : 5
Enter b : 3
8
2
1.5
1.6666666667
2

First operation is addition so, 

5 + 3 = 8
5 - 3 = 2
5 * 3 = 15
5 / 3 = 1.666666667
5 % 3 =2

5 Pattern Programs In Pythons !!


So, let's learn the different - different amazing patterns.

Program 1 :






Output :

#
# #
# # #
# # # #

Program 2 :






Output :

# # # #
# # #
# #
#

Program 3 :






Output :

# # # #
# # # #
# # # #
# # # #

Program 4 :








Output :

enter the name : NibKarma

N
N i
N i b
N i b K
N i b K a
N i b K a r
N i b K a r m 
N i b K a r m a

Program 5 :










Output :

enter the number of rows : 5

    * 

   * * 

  * * * 

 * * * * 

* * * * *

so, we learnt about all operations in python and also know about different data types in python.for more knowledge keep join us and learn more about python!!