Ask coding questions

← Back to all posts
if/elis help in Python
ecarroll42 (2)

I'm working on a project for my Computer Science class that can average the given grades. I'm stuck on the if/ elis part to print the scores if anyone can help.

Commentshotnewtop
Geocube101 (252)
if condition:
  code
elif condition:
  code
else:
  code

[Note]: else is not required for this statement

ecarroll42 (2)

can you give me a little more detail about what command id use for the code?
@Geocube101

Geocube101 (252)

@ecarroll42 It all depends on what condition you're using
For Example - testing if scores are in a range

if score == 100:
  print('Perfect Score')
elif score >= 60 and score < 100:
  print('You Passed')
elif score >= 0 and score < 60:
  print('You Failed')
else:
  print('Invalid Score')