10th Oct 2024, 6:38 AM
Anirudh Kavediya
9 odpowiedzi
+ 2
Thanks bro😁
10th Oct 2024, 12:07 PM
Anirudh Kavediya
+ 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
11th Oct 2024, 12:15 PM
Emmanuel Kioko
0
Anirudh Kavediya "If" must be in all lowercase Python is a case sensitive language
10th Oct 2024, 6:49 AM
Xmosity
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.
10th Oct 2024, 6:50 AM
Xmosity
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)
10th Oct 2024, 6:54 AM
Xmosity
0
np
10th Oct 2024, 5:02 PM
Xmosity
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")
11th Oct 2024, 12:30 PM
SoloProg
SoloProg - avatar
0
https://sololearn.com/compiler-playground/cJ66R3MnGFS4/?ref=app
12th Oct 2024, 6:49 AM
N Sai Kiran
N Sai Kiran - avatar