0
Help me to solve this problem.
https://sololearn.com/compiler-playground/cS3Yu0qNW44b/?ref=app
9 RĂ©ponses
+ 2
Thanks brođ
+ 1
# first you need to declare a variable
student_marks = 70
# the if statement in python begin with lower case if
if student_marks >60:
#note that for your code to be in if block it needs
#to be indedted by 4 spaces or 1 tab
print("passed")
#the print statement should be enclosed in bracket
#this is the else if sector example
elif student_marks >90:
print("passed with an A")
else:
print("failed")
#if you have another condition you put in the else if sector
0
Anirudh Kavediya
"If" must be in all lowercase
Python is a case sensitive language
0
Anirudh Kavediya And, use "elif", not "else". else always goes after "if" and "elif" (elif stands for else if)
Else is a last resort if all conditions are false, it runs.
0
Anirudh Kavediya Sorry for another ping
there were more issues, like, you need to convert the user input to a integer as python saves them as strings. and the correct syntax for print is print("string")
here is the corrected code:
student_marks = int(input())
if student_marks > 60:
print("pass")
elif student_marks < 60:
print("failed")
print(student_marks)
0
np
0
If you enter exactly 60 there will be no result.
this is correct and more compact:
student_marks = int(input())
print(student_marks, "pass" if student_marks>=60 else "failed")
0
https://sololearn.com/compiler-playground/cJ66R3MnGFS4/?ref=app