ENGG1811 Lab 01: Introduction to the CSE computer environment, Spyder and Python

Objectives

In this first lab you will get familiar with the CSE computer environment and start using Spyder, an open source cross-platform integrated development environment (IDE) for scientific programming in the Python language. You will also learn how to use arithmetic operators in Python.

There are no marks for this lab.


Getting familiar with the CSE computer environment  

Your tutors will work through these steps with you in the class.

Each week you will have two hours of formal lab work in a scheduled class for ENGG1811.You may use the CSE (which is short for the School of Computer Science and Engineering) labs at other times, provided there are no classes in them. You can also remotely log onto your CSE account using VLAB (which is short for virtual lab), the instructions to do that can be found at the Getting Started section of the course website. 

UNSW has already provided you with a zPass to access myUNSW and other services. You can use your zID and zPass to log in to your CSE account. 

You will need to use a number of applications in your lab. In order to launch these applications, you will need to make use of the application menu located at the top-left hand corner of the Desktop.

If you expand the application menu, you will find many items and sub-menus.

Before starting your exercises, there are four tasks that we would like you to do. We will at the same time point those applications that you important for your work.

  1. You will be working with many files for the entire duration of this course. It is a good idea to get them organised. We recommend that you put the files in each lab in a separate folder. We ask you to create a folder called "lab01". This can be done using the File Manager application which is the third application on the application menu.
  2. The next task for you is to navigate to the ENGG1811 website. You can find a number of web browsers under the Internet sub-menu on the Applications menu. Launch the FireFox browser and enter the address http://www.cse.unsw.edu.au/~en1811 for the course website.
  3. The course forum on the website is a great place to ask questions. We ask you to post a message introducing yourselves on the course forum.
  4. Locate this week's lab (lab01) on the course website. 
  5. You can start Spyder by first navigating to the Development sub-menu and then choose Spyder. 


Demo by Tutor: Spyder and Python arithmetic operators 

Your tutor will introduce "Spyder" and discuss the important features relevant to the course. Spyder is an open source cross-platform integrated development environment (IDE) for scientific programming in the Python language.

Your tutor will demonstrate and explain how to use the Python arithmetic operators ( + - * / // % **) to do some calculations. ( This page shows some examples of using these operators.) Please pay special attention to the rules of precedence which specifies the order in which the computer will evaluate the arithmetic operations within a mathematical expression. For example, the computer will say that the result of 2 + 3 * 4 is 14 because the multiplication operation is carried out before the addition. You should read the following notes on this topic: The Rules of Precedence. If you have any questions, feel free to ask your tutor!

Now, get ready to solve the following exercise!


Exercise 1: Using the iPython console and precedence

In this exercise you will use the Python arithmetic operators, which are + - * / // % **, to do some calculations. If you cannot remember what they mean, you can consult the notes on The Rules of Precedence. In this exercise, you want you to use as few parentheses as possible in the Python arithmetic expressions. For example, you will get the same answer by using these two Python expressions: 1 + 2 * 3 and 1 + (2 * 3) but the parentheses in the second expression are unnecessary. In order to determine whether parentheses are necessary, you will need to apply the rules of precedence.

The first calculation that you want to do is to compute:


Type a Python expression into the console that can compute this quantity. You should verify that the Python expression gives the correct value. Determine if you have used any unnecessary parentheses in your expression; if there are, we ask you to remove them. We want you to use as few parentheses as possible in your expression. This is to test whether you understand the concept of precedence.

The second calculation is:

You should use as few parentheses as possible in your Python expression.

Note that the expressions that you type into the console will be saved in a log. If you click on the "History log" tab (see picture below), you will see the expressions that you have entered into the console. When you want to show the tutor your work, you can copy the expression from the log and paste it into the console. If you want to get back to the console, you should click the "iPython console" tab.


Exercise 2: Using the iPython console for calculations

Our default concept on birthday is that it is annual. If you go to the website https://www.timeanddate.com/date/birthday.html on alternative birthday calculator, you can calculate when your 1 billion second birthday, 1 million minute birthday etc. will be. Quantities such as 1 billion seconds are hard to comprehend for most of us. However, if we tell you 1 billion seconds is approximately 31 years and 259 days (assuming each year has 365 days, i.e. ignoring leap years) then you probably feel a bit more comfortable. A comforting news for most of you is that you haven't missed your 1 billion second birthday and there is plenty of time to plan a big bash for that auspicious second! 

Let us consider the problem of expressing 1,000,000 (1 million) minutes in terms of years, days, hours and minutes. For this exercise, we ask you to work out the number of complete years and complete days in 1 million minutes; you can work out the hours and minutes in your own time. We impose the following assumptions and restrictions:

If you want to check whether your calculated number of years and days are correct, you can check the answers here.



At the End of the Lab

You should be able to show your tutor the above exercises. You should be familiar the CSE computer environment and comfortable using Spyder, as discussed in the lab.

If you have completed everything, please do not forget to logout. To do that, navigate to the application menu and choose "Log out" which is the last menu item.