Exercise 3.2 (Multiple Conditional Tests in Python)
1. Ensure you have viewed the video (associated with this exercise) at this link >>
2. Consider the computer programs below. They are nonsense programs meaning they do not implement any algorithm they are just to test your understanding of relational operators and the elif clause. By reading the program (i.e. do not execute them to get the answers) write down on paper the output you would expect from each program.
You can check your own answer by copying the code and pasting it into your Python editor, and then executing the code.
You can check your own answer by copying the code and pasting it into your Python editor, and then executing the code.
Exercise 3.2 Example 1
Exercise 3.2 Example 2
Exercise 3.2 Example 3
Exercise 3.2 Example 4
3. Write a program that asks users to enter their percentage mark for a module of study. The program prints the module grade as either distinction, merit, pass or fail depending on the percentage mark entered (try and avoid referring to the answer in the video).
A mark of 70% and above is awarded a distinction.
A mark in the range of 60% through to 69% is awarded a merit.
A mark in the range of 40% through to 59% is awarded a pass.
Marks less than 40% are awarded a fail
A mark of 70% and above is awarded a distinction.
A mark in the range of 60% through to 69% is awarded a merit.
A mark in the range of 40% through to 59% is awarded a pass.
Marks less than 40% are awarded a fail
4. Write a program that asks users to enter their percentage mark for a module of study. The program prints the module grade as either A, B, C, D, E or F depending on the percentage mark entered.
A mark of 80% and above is awarded an A.
A mark in the range of 70% through to 79% is awarded a B.
A mark in the range of 60% through to 69% is awarded a C.
A mark in the range of 50% through to 59% is awarded a D.
A mark in the range of 40% through to 49% is awarded a E.
Marks less than 40% are awarded an F.
A mark of 80% and above is awarded an A.
A mark in the range of 70% through to 79% is awarded a B.
A mark in the range of 60% through to 69% is awarded a C.
A mark in the range of 50% through to 59% is awarded a D.
A mark in the range of 40% through to 49% is awarded a E.
Marks less than 40% are awarded an F.
END Next Exercise >>