Python Forum
Need help with this project / Beginner
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with this project / Beginner
#1
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"))
Reply
#2
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))
Reply
#3
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? :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  My first project as a beginner lil_e 4 1,108 Feb-27-2023, 08:19 AM
Last Post: lil_e
  Open source project that a beginner could contribute to? JJJame 16 11,545 Apr-15-2017, 06:13 PM
Last Post: Low_Ki_

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020