So far, we have presented a Boolean option for conditional statements, with each if statement evaluating to either true or false. In many cases, we will want a program that evaluates more than two possible outcomes. For this, we will use an else if statement, which is written in Python as elif. The elif or else if statement looks like the if statement and will evaluate another condition.
In the bank account program, we may want to have three discrete outputs for three different situations:
Now, there are three possible outputs that can occur once we run the program:
Since elif statements will evaluate in order, we can keep our statements pretty basic. This program is completing the following steps:
Write a program that:
Write a program that creates a multiple choice quiz of 4 possible answers.
Write a program that asks for a pupil score and outputs a suitable grade and comment.
Thanks [name] from [whichclass][location], Mr McG will get your message…"
[message]"…and will get back to you ASAP via [email]. Catch you soon.
Have a great day!!
K McGuinness - 2018
No personal data will be shared with any third party. The only data processed via this website is anonymous browsing data to best manage your user experience.