Python Forum

Full Version: Need help with this project / Beginner
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
MY CODE--> I know i have to float the string somehow but i can't. And i don't know how. Also when it comes to the if statements I've understood that i can't make this statements between string and float. How should i do?
Regards

score = input("Enter Score: ")
if score > 1.0 or score < 0.5:
print("error")
if score > 0.9:
print(A)
if score >= 0.8:
print(B)
if score >= 0.7:
print©
if score >= 0.6:
print(D)
if score < 0.6:
print(F)
print(float("score"))
You had the right idea in the end.
print(float("score")), you just need to use the same method for input:
score = float(input("Enter Score: "))

Additionally you're trying to print the string "score" as a float, instead of referencing your variable:
print(float("score"))
print(float(score))

score = float(input("Enter Score: "))
print(score)
print(type(score))
if score > 1.0 or score < 0.5:
	print("error")
if score > 0.9:
	print("A")
if score >= 0.8:
	print("B")
if score >= 0.7:
	print("©")
if score >= 0.6:
	print("D")
if score < 0.6:
	print("F")
print(float(score))
Thank you!
One question. I tried to float the input before but like this
score = input("Enter Score: ")
x = score
z = float(x)
But i got can't convert from string to float....
Whats wrong with it? :)