I am trying to complete a homework exercise for the following and I am stumped:
Create a variable called
markand assign it the value 65. Then write a series ofif ... elif ... elsestatements to assign a new variable a grade such that marks below 50 produce "Fail", from 50 to 59 produce "Pass", from 60 to 69 produce "Merit" and from 70 and up produce "Distiction".Print the grade.
Then implement the same logic again, but this time without using if statements.
I am able to complete the first part but I am unsure on how to do the same avoiding IF functions - can anyone help?
Using IF functions I have the following which works as expected:
mark = 50
if mark > 69:
print(mark, "marks is a Distinction")
elif mark <= 69 and mark >= 60:
print(mark, "marks is a Merit")
elif mark <= 59 and mark >= 50:
print(mark, "markss is a Pass")
else:
print(mark, "marks is a Fail")
I have no idea where to begin for avoiding if functions
whilewith an unconditionalbreakat the end as a replacement for anif. It's silly, but so's the assignment.matchstatement...