0

How to do this with nested if statement only?

Python You have been asked to coordinate the dance school competition․ The terms of the competition are as follows: - if the score is 80 or more the participant gets a certificate - if the score is 90 or more the participant gets a certificate and also is admitted to the school. The given program takes the score as input. Task Complete the program that will output "certificate" if the score is greater than or equal to 80. On top of that, the program should also output "admitted" if the score is greater than or equal to 90. Sample Input 91 Sample Output certificate admitted

22nd Sep 2021, 6:39 PM
Asphalt
Asphalt - avatar
9 Antworten
+ 2
Rajarshi Or try this one, score = int(input()) if score >= 80: print("certificate") if score > 90: print("admitted") Happy coding!
22nd Sep 2021, 6:57 PM
mesarthim
mesarthim - avatar
+ 2
mesarthim Ok the second anwer you gave is right. So while I was trying using nested if I wrote smt like score = int(input()) if score >= 80 and score <90: print("certificate") If score >= 90: print("certificate\nadmitted") But this gave no output when the input was 91 so where is the problem?
23rd Sep 2021, 3:35 AM
Asphalt
Asphalt - avatar
+ 1
Rajarshi In your last question, If you write this elimination (if score >=80 and score <90), firstly you scanned the score is between 80 and 90. After you write (if score >=90) you've already selected the score and the score is between 80 and 90, so how the score can be greater than 90. The problem this is and you had to change the order. Look my solution, in that case you choose the score is greater than 80 and the result is certificate, after that if the score is also greater than 90 you added admitted. This is the correct answer. I think, you understand now. :)
23rd Sep 2021, 3:40 PM
mesarthim
mesarthim - avatar
+ 1
Oh I see now thx mesarthim
23rd Sep 2021, 3:42 PM
Asphalt
Asphalt - avatar
0
Please, show your attempt/code and explain your problem, clearly. So, we can help. Thanks for understanding. Happy coding!
22nd Sep 2021, 6:45 PM
mesarthim
mesarthim - avatar
0
It's all right but I used elif
22nd Sep 2021, 6:48 PM
Asphalt
Asphalt - avatar
0
Rajarshi I think, if you write like this, score = int(input()) if score >= 90: print("certificate\nadmitted") elif score >= 80 and score <90: print("certificate") must be okay. I hope, it helps.
22nd Sep 2021, 6:51 PM
mesarthim
mesarthim - avatar
0
You're welcome! Good luck! Rajarshi
23rd Sep 2021, 3:43 PM
mesarthim
mesarthim - avatar