# Game.py Copyright (c) 2006 Kari Laitinen # http://www.naturalprogramming.com # 2006-05-28 File created. # 2006-05-28 Last modification. # 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 raw_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 :", integer_from_keyboard = int( raw_input() ) one_larger_integer = integer_from_keyboard + 1 print "\n You typed in %d." % integer_from_keyboard, print "\n My number is %d." % one_larger_integer, print "\n Sorry, you lost. I won. The game is over."