This post was most recently updated on July 31st, 2024
Adding two integer number and print sum
“#” is used to write comment in program
here we are declaring two numbers
1 2 3 4 5 |
num1 = 44 # If we are assigning value integer then num1 variable will be treated as integer. num2 = 53 sum = num1 + num2 print ("addition of two number is " , sum) print ("sum of {0} and {1} is = {2}".format(num1,num2,sum)) |
#Adding two float number
1 2 3 4 5 |
num1 = 4.4 # If we are assigning value float then num1 variable will be treated as float. num2 = 5.3 sum = num1 + num2 print ("addition of two float number is " , sum) print ("sum of {0} and {1} is = {2}".format(num1,num2,sum)) |
#use type function to identify variable type
1 2 3 4 |
a = 11 b = 2.3 print (" a is ",type(a)) print ("b is " type(b)) |