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

Objectives

In this first lab you will get familiar with "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.

We suggest that you install the software "Anaconda for Python 3.7" on your laptop. Instructions for installing this software can be found at the "Getting Started" link on the course website.


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. Please pay special attention to the rules of precedence. 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! 

We are interested to express 1,000,000 (1 million) minutes in terms of years, days, hours and minutes. For this exercise, we would like you to work out the number of complete years and complete days in 1 million minutes. 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. Simply double click on the "Log Out" icon