1 PreparationBefore your workshop class:• Read all of this document.• Review the lecture notes sections 1 to 11.• Bring some paper (a print-out of this document is best) and writing implements.• Bring a storage device, such as a portable hard drive and cable, or a USB drive.2 Pre-workshop questions (1 mark)Complete these questions in writing before the start of the workshop. They will be marked early in theworkshop.1. Which Python type would be appropriate for:(a) the number of students in the class?(b) a person’s weight in kilograms?(c) a person’s height in metres?(d) a person’s height in centimetres?(e) the number of children in a family?(f) the average number of of children in all Australian families?2. Some operators are binary and some are unary. What do these words mean in this context?13. What is the important difference between types int and float?4. Describe the difference between a compiler and an interpreter?5. Which of these are valid variable names? Answer \yes" or \no". If \no" say why.(a) x ;(b) x2 ;(c) 2x ;(d) SHOUT ;(e) robin ;(f) yellow robin ;(g) yellowRobin ;(h) YELLOW ROBIN ;(i) epsilon ;(j) lambda ;6. Complete this table, if the following statements have already been executed.i = 7j = 2x = 2.2
expression type value 3 int 3 x i + x i % j j % i ’x’ ’x’ + ’i’
23 Workshop activitiesYou may choose any tools you like, so long as the program is written in Python 3. At any stage, whenyou are stuck, ask your tutor!3.1 Problem 1 (1 mark)Problem: The grades at Koala University are awarded based on the number of marks awardedfor the course out of 100. Marks of 90 or above receive the grade of \gum leaf cluster". Marksless than that but of 60 or above receive the grade of \leafy twig". Marks less than that butof 45 or above receive the grade of \gum leaf". Anything less gets the grade of \dead twig".Write a program that asks the user for a number of marks, and prints the grade awarded.Example:$ python3 koalaU.pyHow many marks? 85leafy twig$3.2 Problem 2 (1 mark)Problem: There are three candidates standing for Lord Mayor of Wobatville, Angus, Betty,and Cathy. If in the first round of voting, no canditate has more than 50 % of the votesanother round of voting will be required. Write a program that inputs the numbers of votesfor each candidate in the first election and declares its result, either:• the name of the outright winner, or• the names of the two or three candidates to be voted on in the next round of voting.Examples:$ python3 voting.pyHow many votes for Angus? 10How many votes for Betty? 4How many votes for Cathy? 5Angus wins.$ python3 voting.pyHow many votes for Angus? 5How many votes for Betty? 5How many votes for Cathy? 5Next round: Angus, Betty, and Cathy.$ python3 voting.pyHow many votes for Angus? 4How many votes for Betty? 10How many votes for Cathy? 7Next round: Betty and Cathy.$ python3 voting.pyHow many votes for Angus? 6How many votes for Betty? 10How many votes for Cathy? 6Next round: Angus, Betty, and Cathy.$3.3 Problem 3 (1 mark)Problem: A rugby team has 15 players. A bus company has only big buses that can carry 38passengers. Write a program that the tournament organiser can use to calculate the numberof big buses that should be hired.3Example:$ python3 bus2.pyHow many teams? 3Number of big buses = 2$3.4 Problem 4 (1 mark)Problem: A salesperson in a camera shop earns a base wage of $30.25 per hour up to theirnormal work week of 37 hours. Only whole hours are counted. If they work more hours thanthat (overtime) they get paid at 1.5 times their normal rate for the overtime. If they sell morethan $3000.00 worth of camera gear in the week, they get a bonus of 3% of the sales over the$3000.00 minimum. Write program to calculate the wages plus bonus for a salesperson in aweek.Examples:$ python3 cameraPay.pyHow many hours were worked? 20Total sales for the week? 5000Pay = 665.0$ python3 cameraPay.pyHow many hours were worked? 40Total sales for the week? 100
Pay = $ 1255.375
4 After the workshop• You have created programs that might be useful to refer back to in future workshops. Make surethat you will have that work in the future. One copy is not enough for at IT professional. Youshould have at least 2 copies:1. on your Griffith network storage drive; and2. on your portable storage device.