This labsheet is a gentle introduction to the CSSE working environment and the Python programming language. Make sure you use this time to familiarise yourself with the programming environment before commencing with the technical aspects of the unit.
The computers we will use in this unit are the all-in-one computers found in Labs 2.03 of the CSSE building. We will be using the Mac OS however, Python script will run the same way in Windows and Linux. You will have 24/7 access to these labs provided your security card has been enabled for access.
Once you are enrolled in a CSSE unit, your student card should automatically allow you after-hours access to the CSSE building. If you are having any difficulties accessing the lab, please see an administrative assistant in the reception area (Room 1.31).
After-hours access will commence in the second week of semester. Outside normal working hours, make sure you carry your student card with you at all times.
Ensure your account is working correctly by logging on.
The lab 2.03 computers will only have Mac OS, although you can use other operating systems to complete exercises at home.
At the login screen type in your Student Number and Pheme password. Usernames and passwords are case sensitive. If you have trouble logging in, try using bookings for both username and password, and the computer will bring up a web page telling you what to do.
After successfully logging in using your account, launch Internet Explorer from the Start Menu. If you are asked for a proxy enter your University account password. This is only needed for accessing websites external to the University. To do this, you will first need to upgrade your account to a Full Service Account if you haven't already done so - see https://www.its.uwa.edu.au/student/accounts. In the meantime you should be able to hit "Cancel" and close any window that is trying to access an external site.
Navigate your way (via the School's "Current Students" page) to the on-line version of this lab sheet and proceed using the on-line version.
The primary and the fastest way to get help in CITS4406 will be via help4406. Try it out now, by reading and sending messages.
Check help4406 often for useful information about the unit, including about the assessments.
The suggested way of using Python with the text in this course is via an "integrated program development environment" called IDLE, documented at IDLE docs. IDLE is available both from the Start Menu, via Programming Software, and from the Applications folder on the desktop. Try the following.
#returns the square of x
return x * x
#prints the first x Fibonacci numbers
#each number is the sum of the previous two
a,b = 0,1
for i in range(x):
print("fib(", i, ") = ", a)
a,b = b,a+b
Use the print operation from above to write a Python function that displays the name of the Python course.
(Challenge) Write a Python function that displays the expressions and answers to Question 3 above.
From page 10 of the text, copy the chaos program (printed below for your convenience) into your lab1.py
print("This program illustrates a chaotic function")
x = eval(input("Enter a number between 0 and 1: "))
for i in range(1,10):
x = 3.9 * x * (1 - x)
As an indication of what you will be able to achieve in CITS1401, have a look at the prize-winning entries for Project 2 from the last two years. Both years the challenge was to design a board game where the computer plays agains a human. Writing a program where the computer makes legal moves and does not allow the human to make any illegal move would fetch full marks.
However, an extra component for brilliant students was to put some intelligence into the program where the computer plays good moves and tries to win the game.
Feel free to have a look at these programs from previous years. I am sure they will appear complicated at first but in three months time, if you work hard, you will be able to write something like this!