Python Forum
Python for Everybody 3.3 assignment - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Python for Everybody 3.3 assignment (/thread-15201.html)



Python for Everybody 3.3 assignment - ramadan2099 - Jan-08-2019

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'



RE: Python for Everybody 3.3 assignment - micseydel - Jan-08-2019

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.


RE: Python for Everybody 3.3 assignment - ayaz786amd - Jan-08-2019

print()


RE: Python for Everybody 3.3 assignment - ramadan2099 - Jan-08-2019

(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?


RE: Python for Everybody 3.3 assignment - micseydel - Jan-08-2019

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.


RE: Python for Everybody 3.3 assignment - ramadan2099 - Jan-09-2019

(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


RE: Python for Everybody 3.3 assignment - Saikumar - Apr-08-2020

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


RE: Python for Everybody 3.3 assignment - DeaD_EyE - Apr-08-2020

https://docs.python.org/3/whatsnew/3.0.html#print-is-a-function