Simple addition program. : Console Read « Development « Python






Simple addition program.

Simple addition program.


# prompt the user for input
integer1 = raw_input( "Enter first integer:\n" )  # read a string
integer1 = int( integer1 )                        # convert the string to an integer

integer2 = raw_input( "Enter second integer:\n" ) # read a string
integer2 = int( integer2 )                        # convert the string to an integer

sum = integer1 + integer2                         # assignment of sum

print "Sum is", sum                               # print sum



           
       








Related examples in the same category

1.Read numbers till eof and show squaresRead numbers till eof and show squares
2.Displaying location, type and value for your input.Displaying location, type and value for your input.
3.Displaying location, type and value for an intDisplaying location, type and value for an int