-
-
Save KKarthikeya/ec7e579b2a205978d351 to your computer and use it in GitHub Desktop.
score = float(raw_input("Enter score between 0.0 and 1.0: ")) | |
if score>1.0 or score<0.0 : | |
print "error" | |
elif score>=0.9 : | |
print 'A' | |
elif score>=0.8 : | |
print 'B' | |
elif score>=0.7 : | |
print 'C' | |
elif score>=0.6 : | |
print 'D' | |
else : | |
print 'F' |
#This worked. Easy to understand, give this a try.
score = input("Enter Score: ")
try:
x = float(score)
except:
print("Error")
if 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")
else:
print("Please Enter a valid score")
score = float(raw_input("Enter score between 0.0 and 1.0: "))
if score>1.0 or score<0.0 :
print ("error")
elif score>=0.9 :
print ("A")
elif score>=0.8 :
print ("B")
elif score>=0.7 :
print ("C")
elif score>=0.6 :
print ("D")
else :
print ("F")
#This works perfectly guys
score=input("Please type a score between 0.0 and 1.0:")
try:
s=float(score)
if s >= 0.9 and s <= 1.0:
print("A")
elif s >= 0.8 and s <= 0.9:
print("B")
elif s >= 0.7 and s <= 0.8:
print("C")
elif s >= 0.6 and s <= 0.7:
print("D")
elif s > 0 and s <= 0.6:
print("F")
else:
print("Bad score. Please run the program again.")
except:
print("Bad score. Please run the program again.")
try this
score = input("Enter score: ")
score = float(score)
if score>1.0 or score<0.0 :
print ("error")
elif score>=0.9 :
print ("A")
elif score>=0.8 :
print ("B")
elif score>=0.7 :
print ("C)
elif score>=0.6 :
print ("D")
else :
print ("F")
#coursea code assignment 3.3
score = float(input("Enter score between 0.0 and 1.0: "))
if score>1.0 or score<0.0 :
print ("error")
elif score>=0.9 :
print ("A")
elif score>=0.8 :
print ("B")
elif score>=0.7 :
print ("C")
elif score>=0.6 :
print ("D")
else :
print ("F")
`score = input("Enter Score: ")
x = float(score)
if 0.0 < x > 1.0:
print("Score is out of range")
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")
`
score = input('Enter a Score between 0.0 to 1.0: ')
if 0.0 <= float(score) <= 0.6:
print('F')
elif 0.6 <= float(score) <= 0.7:
print('D')
elif 0.7 <= float(score) <= 0.8:
print('C')
elif 0.8 <= float(score) <= 0.9:
print('B')
elif 0.9 <= float(score) <= 1.0:
print('A')
else:
print("the score is out of range")
try:
inp = raw_input("Enter a number between 0.0 and 1.0: ")
score = float(inp)
if (score >= 1.0):
print("You didn't follow instructions")
exit()
elif (score >= 0.9):
print("A")
elif (score >= 0.8):
print("B")
elif (score >= 0.7):
print("C")
elif (score >= 0.6):
print("D")
else:
print("F")
except:
print("Please enter numerical numbers")
exit()
"Try this code it works accurately".
this works
score = input("Enter Score: ")
try:
scr = float(score)
except:
print("Sorry, enter a valid number to proceed...!")
quit()
if scr > 1.0 or scr < 0.0:
print('Sorry, not in the range')
elif scr >= 0.9:
print('A')
elif scr >= 0.8:
print('B')
elif scr >= 0.7:
print('C')
elif scr >= 0.6:
print('D')
else:
print('F')
score=input("Please type a score between 0.0 and 1.0:")
try:
float(score)
if float(score) >= 0.9 and float(score) <= 1.0:
print("A")
elif float(score) >= 0.8 and float(score) <= 0.9:
print("B")
elif float(score) >= 0.7 and float(score) <= 0.8:
print("C")
elif float(score) >= 0.6 and float(score) <= 0.7:
print("D")
elif float(score) > 0 and float(score) <= 0.6:
print("F")
else:
print("Bad score. Please run the program again.")
except:
print("Bad score. Please run the program again.")
There was an error but this fixes it:
score=input("Please type a score between 0.0 and 1.0: ")
try:
score = float(score)
except:
print("Bad score")
exit(0)
if float(score) >= 0.9 and float(score) <= 1.0:
print("A")
elif float(score) >= 0.8 and float(score) <= 0.9:
print("B")
elif float(score) >= 0.7 and float(score) <= 0.8:
print("C")
elif float(score) >= 0.6 and float(score) <= 0.7:
print("D")
elif float(score) > 0 and float(score) <= 0.6:
print("F")
else:
print("Bad score")
score = input('Enter score: ')
s = float(score)
if s >= 0.9 and s <= 1.0:
print('A')
elif s >= 0.8 and s < 0.9 :
print('B')
elif s >= 0.7 and s < 0.8 :
print('C')
elif s >= 0.6 and s < 0.7 :
print('D')
elif s < 0.6 and s > 0.0 :
print('F')
else :
try:
if s <= 0.0 or s >= 1.0 :
print('Error,Score is out of range.Please enter score between 0.0 and 1.0')
except :
quit()
Improve your grogram in Question 1 by adding try and except. If a non-numeric input is
submitted, your program should print a message and exit the program.
Example input and output:
Enter Hours: 50
Enter Rate: ten
Error, please enter a numeric dat
#This works simple
score = input("Enter Score: ")
try:
scr= float(score)
except:
print("Sorry, enter a valid number to proceed...!")
quit()
#below syntax checks for the number between 1.0 and 0.0.
if scr > 1.0 or scr < 0.0:
print('Sorry, not in the range')
elif scr >= 0.9:
print('A')
elif scr >= 0.8:
print('B')
elif scr >= 0.7:
print('C')
elif scr >= 0.6:
print('D')
else :
print('F')