Python Forum

Full Version: Python for Everybody 3.3 assignment
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a code error?
What do you need to get output?

http://www2.0zz0.com/2019/01/08/03/932918971.png





inp = input("Choose a score between 0.0 and 1.0")
score = float(inp)

if score >= 0.0 and score < 0.6:
    print
    'F'


elif score >= 0.6 and score < 0.7:
    print
    'D'

elif score >= 0.7 and score < 0.8:
    print
    'C'

elif score >= 0.8 and score < 0.9:
    print
    'B'

elif score >= 0.9 and score <= 1.0:
    print
    'A'

else:
    print
    'Error: input not within range'
You need to put what you're printing on the same line as the print statement. Right now, everything is on the next line. In Python, a plain string is a legal line, and print by itself just prints a newline, so your code is legal although it doesn't do what I suspect you want it to.
print()
(Jan-08-2019, 12:14 AM)ramadan2099 Wrote: [ -> ]Is there a code error?
What do you need to get output?

http://www2.0zz0.com/2019/01/08/03/932918971.png





inp = input("Choose a score between 0.0 and 1.0")
score = float(inp)

if score >= 0.0 and score < 0.6:
    print
    'F'


elif score >= 0.6 and score < 0.7:
    print
    'D'

elif score >= 0.7 and score < 0.8:
    print
    'C'

elif score >= 0.8 and score < 0.9:
    print
    'B'

elif score >= 0.9 and score <= 1.0:
    print
    'A'

else:
    print
    'Error: input not within range'

inp = input("Choose a score between 0.0 and 1.0")
score = float(inp)

if score >= 0.0 and score < 0.6:
    print
    (F)

elif score >= 0.6 and score < 0.7:
    print
    (D)

elif score >= 0.7 and score < 0.8:
    print
    (C)

elif score >= 0.8 and score < 0.9:
    print
    (B)

elif score >= 0.9 and score <= 1.0:
    print
    (A)

else:
    print
    'Error: input not within range'
Did you mean that?
I didn't mention parenthesis. I said they should be on the same line, more like this:
if score >= 0.0 and score < 0.6:
    print 'F'
If you're using Python 3, then you'll need parenthesis as well as the quotes. The code block I've provided will work for Python 2 but will be a syntax error in Python 3, though you should be able to correct it easily.
(Jan-08-2019, 11:40 PM)micseydel Wrote: [ -> ]I didn't mention parenthesis. I said they should be on the same line, more like this:
if score >= 0.0 and score < 0.6:
    print 'F'
If you're using Python 3, then you'll need parenthesis as well as the quotes. The code block I've provided will work for Python 2 but will be a syntax error in Python 3, though you should be able to correct it easily.

thanks well done
It is not getting output. It shows "your program does not have any output"