#! /usr/bin/env python # -*- coding: utf-8 -*- """ Code from the chapter 1 on "Python in Easy Steps" book. Can be downloaded from http://ineasysteps.com/resource-centre/downloads/ (http://ineasysteps.com/wp-content/uploads/2013/07/src.zip) Credit: Lilian Besson for http://perso.crans.org/besson/cs101/solutions/easysteps/ License: GPLv3 """ # Page 15 8 + 4 3 * 8 + 4 3 * (8 + 4) # Page 16 print "Hello World!" # Page 18 a = 8 a = b = c = 8 a, b, c = 1, 2, 3 # Page 19 # Initialize a variable with an integer value var = 8 print var # Assign a float (ie. real number) to the variable var = 3.142 print var # Assign a string (piece of text) to the variable var = "Python in easy steps" print var # Assign a boolean (true or false) value to the variable var = True print var # Page 20 # Initialize a variable with a user-specified value user = raw_input("I am Groot. What is your name? : ") # Output a string and a variable value print "Welcome", user # Page 21 # Initialize another variable with a user-specified value # (taken from the terminal input --> on the Python or IPython console on the right of our Spyder window) lang = raw_input("What is your favorite programming language? : ") print lang, "is a good answer." # Page 22 # print "Python in easy steps, but with some bugs # Page 23 title = "Python in easy steps" # print titel num = 3 print num * 8 + 4 if __name__ == '__main__': from doctest import testmod testmod(verbose=False)