# SumImproved.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-28 File created. # 2016-11-17 Converted to Python 3. Last modification. # This is a simple calculator program that can # calculate the sum of the two integers that are # typed in from the keyboard. # The number sign (#) starts a comment line in Python. # All statements in Python 'main' program must begin in the # first column. Statements may not be indented unnecessarily since # indented statements form a nested program block. # You must use a backslash (\) to continue a statement on the # following program line. # Variables are not declared in Python programs. Instead, variables # are 'born' when they are assigned values. # Built-in runction input() reads a string from the keyboard. # Built-in function int() converts a string to an integer value. # Built-in function print() prints text to the terminal window. # The print() function prints a newline to the end unless the # parameter end = "" is specified. # See programs Distance.py and Formatting.py in pythonfiles2 for # information about the format specifiers (e.g. %d). print( "\n Please, type in an integer: ", end = "" ) first_given_integer = int( input() ) print( "\n Please, type in another integer: ", end = "" ) second_given_integer = int( input() ) sum_of_two_integers = first_given_integer + \ second_given_integer print( "\n The sum of %d and %d is %d. \n" % ( first_given_integer, second_given_integer, sum_of_two_integers ) )