ICS3U - Summative Write- up
For this summative I am doing the level four invoice system. The program requires file
Level4InvoiceInformation.txt as well as 2 2 modules.
The first module is called user_info, this is design to read through the file and categ
Keeping your code organized
Organized code is strong code.
Less likely to crash.
Easier to debug.
Easier to understand.
Easier to modify and customize.
Tools for Organizing Code
mandatory in Python
How do you get Python to generate a random integer?
import random #do @ top of pgm
randNum = random.randint(3,50)#do a/where
Generates a random integer between 3 and 50 and
stores it in randNum
We can also randomly choose a symbol.
Come in 3 flavours
Nothing in yr program will execute
Yr program will execute statements until it
encounters the problem.
E.g. you try to divide a value by 0
Then it crashes!
Your program wont cra
Semester 1 2012-2013
ADD IN REQ TO DOCUMENT TESTING
ADD IN REQ TO DOCUMENT IMPROVEMENTS
There are two options to this summative.
Create a text-based computer game. I recommend using an existing game as the basis for
your game. If
Parsing the line
In Exercise 3.1 cat, you printed out each line
of the file.
What if we wanted to have access to each
word in the line?
We can use split() to break up a string.
> line = "the rain in spain"
> words = line.split()
> print words
Variables and Simple User
16 = myAge
Whats the problem with this statement
from the POV of the Python interpreter?
Hint: it has to do with the nature of
Yup, the = sign means give the value on
the RHS to the LHS so 16 = myA
Format Specifiers: special character
sequences inside strings that are meant to
be replaced by other strings or floats or
fName = Billy
print Hello % fName
> Hello Billy
String Formatting (contd)
This thing is called a