pop up description layer
Last modified: 20070716:152428/added three small exercises

FIT2022 AJH-2007-12

Tutorial 1

Objectives | Outcomes from this Tutorial | Setting Yourself Up with Python | Introduction to Python

Objectives

In this first pair of tutorial/laboratory sessions, we focus upon objective 6. Operating systems are programmed systems, and we need to do some programming to understand what goes on inside the operating system. Most of this tutorial is directed at learning some basic Python coding, since Python is the language in which the laboratory exercises are to be undertaken.

Students have asked in the past: ``Why do we have to learn another programming language?''. Unfortunately (or fortunately, depending upon your point of view), there are many, many programming languages, characterized only by one thing: they were all designed to address programming tasks. Some focus upon efficiency, some upon clarity, some upon particular application domains, and some upon teaching. Python is one of the so-called scripting languages, but it is also object-oriented, so you can see that sometimes designers have more than one target in mind when they design a language. Computer Scientists and Software Engineers just cannot get away with only knowing one or two programming languages, and even more importantly, they need to know languages from a range of paradigms.

The other serious contender for use in a computer systems unit is the C Programming Language. While most of you will have learnt Java (and there are some significant similarities between the syntax of Java and C), C is a difficult language to learn and use effectively. You just don't have time in a single semester unit to learn about C and operating systems. For that reason, we have elected to use Python. As we suggest above, you'll probably have to learn C at some stage in your career, but now is not that time.

Why Python? Well, it is a modern, object-oriented language, with clear syntax (one of its unusual features is that it uses indentation to specify nested structures), and excellent error messages. All of the modern programming artifacts are in it, and it comes with an excellent library that allows the programmer to quickly and effectively develop programs. Most importantly for this unit, it has an exec function, which allows us to do the `magic' of executing the programs that we write. More of this anon.

Outcomes from this Tutorial

This tutorial is addressing objective 6. At the end of this tutorial, you should:

  1. Have a basic understanding of the syntax of Python;
  2. Be able to write a few simple programs in Python; and
  3. Appreciate the value of rapid prototyping in a scripting language.

Setting Yourself Up with Python

The lab sessions are based upon using Linux boxes, and these have all been set up with Python systems. Many of you will have personal computers, and will want to run your programs on those systems. If you have Linux, then you can install the same system as is on the lab machines. But Python is fairly consistent across platforms, anyway. Instructions on installing Python are on the Resources Page .

Introduction to Python

Most of this tutorial is dedicated to discussing Python. It is suggested that you work through the Informal Introduction to Python that is in the tutorial document on Python. But feel free to explore your own teaching resources.

Exercise 1

Write a sequence of Python statements to assign your given name and family name to the two variables given and family respectively, and then to print out your complete name in a single line.

Exercise 2

Write a sequence of Python statements to build a list, containing your given name, a space character, and your family names. Now alter the middle element of the list to contain your middle name (make one up if you don't have a middle name!)

Exercise 3

write a Python function addname with two parameters, given and family, that adds a full name given family to a list of names of people, called names.

Warning:You do not need to understand the following section: it is included for information and interest only. This program won't work if you try it out - you need to declare the list of names to be global, see later. Now read on:

Document History

20070716:152428 1.0.2 ajh added three small exercises
20070711:135403 1.0.1 ajh fleshed out the tutorial tasks
20070705:170756 1.0.0 ajh first draft of tutorial 1

This page maintained by John Hurst.
Copyright Monash University Copyright Policy
1752 accesses since
10 Jul 2007
My PhotoTrain Photo

Generated at 20090703:0609 from an XML file modified on 20070717:1000
Maintainer use only; not generally accessible: Local ServerWork ServerCSSE Server

2174 accesses since 10 Jul 2007, HTML cache rendered at 20120526:0107