I Haz Codes
The final part of IF statements is to look at how we can make use of elif and else. Else allows us to do something when the condition is false. Elif allows us to daisy chain multiple if statements together but only allowing one of them to be true.
You need to write a program which will say what grade you got in a test. The grades can be found in the table below. You need to write a program which will say what grade you got in a test. The grades can be found in the table below.
| Grade | Score |
| A | 85 |
| B | 76 |
| C | 63 |
| D | 52 |
| E | 44 |
| F | 33 |
| U | <33 |
Enter the code below. This program will ask the user a simple maths question and then should check to see if the answer is correct or not. You need to complete the code by adding the if statement. It should –
Display “correct” if they enter the correct answer
Display “incorrect” if they enter an incorrect answer
Try the following quiz to test your knowledge.