# Game.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-28 File created. # 2022-12-16 Converted to Python 3. # 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. # print is a Python keyword. print statements normally print a # newline after the printing operation. This can be prevented by # writing a comma at the end of the print statement. # See programs Distance.py and Formatting.py for information about # the format specifiers (e.g. %d). print( "\n This program is a computer game." \ "\n Please, type in an integer : ", end="" ) integer_from_keyboard = int( input() ) one_larger_integer = integer_from_keyboard + 1 print( "\n You typed in %d." % integer_from_keyboard, end="" ) print( "\n My number is %d." % one_larger_integer, end="" ) print( "\n Sorry, you lost. I won. The game is over." )