In this practice, we will cover concepts from all 7 tutorials in Python.

For each exercise, submit 1 Python Script that we can run to check your code. In total there is 4 exercises, so we expect a total of 4 Python Scripts (.py) in a zip file.

**Exercise 1 ****– Writing your first Python script**

Assign 2 to variable number “a” and 2 to variable number “b”. Add them up and minus 1 and do this all in the script!

**Assignment requirement**

Show the simple lines of code, such that when the Python Script is run, the correct output of “3” should appear

**Exercise 2 – AutoGrader**

Try to code an if-else programme to allocate grades to a certain mark

A+ : 90

A: 80

B+: 75

B: 70

C: 60

D: 50

**Assignment requirement**

Your code should have the below format.

score = int(input()) # rest of the code goes here print(grade)

## Exercise 3 – Rounding off

- Every student receives a
in the inclusive range from 0 to 100.**grade** - Any grade less than
is a fail grade**40**

Sam is a professor at the university and likes to round each student’s grade according to these rules:

- If the difference between the grade and the next multiple of 5 is less than 3, round grade up to next multiple of 5 (hint: modulus % will help)
- If the value of grade is less than 38, no rounding occurs as the result will still be a failing grade.

For example, grade = 84 will be rounded to 85 but grade = 29 will not be rounded because rounding can’t save you from failing (<40 marks)

Given the initial value of grade for each of Sam’s * n* students, write code to automate the rounding process. For each grade, round it according the rules above and print the results on a new line

(hint: Loops, list as a data structure is important)

**Input Format**

The first line contains a single integer denoting * n *(the number of students).

Each line* i* of the

**subsequent lines contains a single integer, grade denoting i-th student’s grade**

*n***Constraints**

- 1 <= n <= 60
- 0 <= grade <= 100

**Output Format**

For each grade of the * n* grades, print the rounded grade on a new line.

**Assignment requirement**

Your code should have the below format.

n = int(input()) grades = [] for _ in range(n): grades_item = int(input()) grades.append(grades_item) - rest of the code goes here -

(figure out how to print the results line by line)

**Further Explanations**

Sample Input |
Sample Output |

73 67 38 33 |
75
67 40 33 |

There is a total of 4 students:

- Student 1 received a 73, and the next multiple of 5 from 73 is 75. Since 75 – 73 < 3, the student’s grade is rounded to 75
- Student 2 received a 67, and the next multiple of 5 from 67 is 70. Since 70 – 67 = 3, the grade will not be modified and the student’s final grade is 67.
- Student 3 received a 38, the next multiple of 5 from 38 is 40, Since 40 – 38 < 3, the student’s grade will be rounded to 40.
- Student 4 received a grade below 38, so the grade will not be modified and the student’s final grade is 33.

## Exercise 4 – Processing Housing Dataset

Download the resale housing dataset from here. Let’s just use the dataset after year 2015.

You can try to use the in-built csv library to read in the dataset, but in data analytics we usually use this library call * pandas *for data wrangling.

Try to do as much as possible for this exercise. Pandas is not taught in the tutorial series, so this is a test of your skills in googling solution (hint: look for cheatsheets)

- What is the mean transaction value for the entire dataset?
- What is the average price of HDB sold for each year (2015, 2016, 2017, 2018)?
- Find all entries of housing transaction that are more than the mean value of the data in the price column.

(To clarify, please print out all entries that are more than the mean value of the data in the price column)

**Assignment requirement**

Perform 1, 2 and 3 in a single python script:

**Sample Output:**

Mean: xxxxxxx

Mean in 2015:

Mean in 2016:

Mean in 2017:

Mean in 2018:

– print whatever rows of data that fulfills the condition –

– End of Assignment –

Please email the completed assessments available through the Google form link (https://forms.gle/dcmK8nzfTUJ8gy457) and your resume to bactnus@gmail.com for the application to BACT in AY2021 Sem 1. You do not need to email us the 4 exercises in the Python Assignment Challenge.