Tags
Asked 3 years ago
30 Jul 2021
Views 257
Esmeralda

Esmeralda posted

How to add Two Numbers in Python program ?

How to add Two Numbers in Python program ?
jessica

jessica
answered Jul 30 '21 00:00

how to add two integer Numbers in python?
Answer is use + as to add up to float value in python


a=1
b=3
print(a+b)


Output :
4

how to add two float Numbers in python?

Answer is use + as to add up to float value in python

a=1.1
b=3.2
print(a+b)


Output :
4.3

How to round float to integer Numbers in the Python ?

if you want only to see round value not float value as output than use Math module . math module have floor(n) function which convert float to integer by rounding up it.


import math
a=1.1
b=3.2
print(math.floor(a+b))


Output :
4.0
Post Answer