Skip to content

Instantly share code, notes, and snippets.

@Mohamed2del
Created June 9, 2018 15:09
Show Gist options
  • Save Mohamed2del/a69a57dde82453a963c86af915b08feb to your computer and use it in GitHub Desktop.
Save Mohamed2del/a69a57dde82453a963c86af915b08feb to your computer and use it in GitHub Desktop.
Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade using the following table: Score Grade >= 0.9 A >= 0.8 B >= 0.7 C >= 0.6 D < 0.6 F If the user enters a value out of range, print a suitable error message and exit
score = input("Enter Score: ")
s = float(score)
x = 'Error'
if s >= 0.9:
x = 'A'
elif s >=0.8:
x='B'
elif s >=0.7:
x='C'
elif s >= 0.6:
x='D'
elif s < .6:
x ='F'
else:
x ="Out of Range"
print (x)
@tahira2k16
Copy link

score = input("Enter Score: ")
try:
Fscore = float(score)
except:
print("Enter Numeric Number")
quit()
if Fscore >= 1.0:
if Fscore < 0.0:
print("Enter Value Between 0.0 and 1.0")
quit()
if Fscore >= 0.9:
print("A")
elif Fscore >= 0.8:
print("B")
elif Fscore >= 0.7:
print("C")
elif Fscore >= 0.6:
print("D")
elif Fscore < 0.6:
print("F")

@sugarbaeslayr
Copy link

sugarbaeslayr commented Feb 10, 2023

s=input("score")

sc=float(s)

x=("error")

if sc >1:
print(x)
exit()
elif sc >= 0.9:
x= ('A')
elif sc >= 0.8:
x = ('B')
elif sc >= 0.7:
x = ('C')
elif sc >= 0.6:
x = ('D')
elif sc < 0.6:
x = ('F')

else:
x=("error message")

print(x)

@Seharish-Fatima
Copy link

print('Enter A Score Between 0.0 and 1.0')
score=float(input())
if score>=0.9 and score<=1.0:
print('A')
elif score>=0.8 and score<0.9:
print('B')
elif score>=0.7 and score<0.8:
print('C')
elif score>=0.6 and score<0.7:
print('D')
elif score<0.6:
print('F')
else:
print('Bad Score')

@Adenike998
Copy link

score = input("Enter Score: ")
s = float(score)
if s > 1.0:
print('error')
elif s == 1.0:
print('A')
elif s >= 0.9:
print('A')
elif s >= 0.8:
print('B')
elif s >= 0.7:
print('C')
elif s >= 0.6:
print('D')
elif s< 0.6:
print('F')

@Abdul36
Copy link

Abdul36 commented Nov 30, 2023

xx= input("enter the grade: ")
x= float(xx)
if x > 1:
print("Number is out of Range")
print("Enter number between 0.0 to 1.0")
elif x <=0:
print("Number is out of Range")
print("Enter number between 0.0 to 1.0")
elif x >=0.9:
print("A")
elif x >= 0.8 :
print("B")
elif x >= 0.7 :
print("C")
elif x >= 0.6:
print("D")
elif x < 0.6:
print("F")
**Hope so it works ** suggestions are appreciated at [email protected]

@j5210251
Copy link

score = input("Enter Score: ")
try:
s = float(score)
except:
print("Out of range")
quit()
if s > 1.0:
print("Out of range")
elif s >= 0.9:
print("A")
elif s >=0.8:
print("B")
elif s >=0.7:
print("C")
elif s >= 0.6:
print("D")
elif s < 0.6:
print("F")
else:
print("Out of range")

@YogaSarvan
Copy link

score = input("Enter Score: ")
s = float(score)
if s >= 0.9:
print('A')
elif s >= 0.8:
print ('B')
elif s >= 0.7:
print('C')
elif s >= 0.6:
print('D')
elif s< 0.6:
print('F')
else:
print(" Out of range ")

@Thattastyturtle
Copy link

score = input("Enter Score: ")
try:
s = float(score)
except:
print("Please type a numeric value in between 0.0 - 1.0")
quit()
if s > 1.0 or s < 0:
print("Please enter a grade in range of 0.0 - 1.0")
quit()
elif s >= 0.9:
print("A")
elif s >= 0.8:
print("B")
elif s >= 0.7:
print("C")
elif s >= 0.6:
print("D")
elif s < 0.6:
print("F")
elif s > 1.0 or s < 0:
print("Please enter a grade in range of 0.0 - 1.0")
quit()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment