Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python for Everybody 3.3 assignment
#1
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'
Quote
#2
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.
Quote
#3
print()
Quote
#4
(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?
Quote
#5
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.
Quote
#6
(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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Powerball assignment, how to get correct output of a dictionary ? msp1981 5 94 Mar-19-2019, 11:02 PM
Last Post: Yoriz
  Help with homework assignment grayarea3 1 178 Feb-20-2019, 10:10 PM
Last Post: ichabod801
  Help with assignment dxfrelince 7 301 Feb-18-2019, 09:16 PM
Last Post: dxfrelince
  Need help with a tough school assignment datson79 5 216 Feb-18-2019, 06:01 PM
Last Post: ichabod801
  Need some help with a bit of code for an assignment. JackMercer50 1 143 Feb-09-2019, 04:13 PM
Last Post: stullis
  Help with arrays assignment hyg71886 15 405 Jan-30-2019, 09:36 AM
Last Post: perfringo
  Python Assignment 5.2 amos76823 3 393 Jan-17-2019, 07:34 AM
Last Post: perfringo
  Python for Everybody 3.1 assignment ramadan2099 14 621 Jan-07-2019, 07:31 PM
Last Post: ramadan2099
  Help for my assignment - Object Oriented Programming denizkb 5 262 Jan-05-2019, 06:43 PM
Last Post: stullis
  [split] Python for Everybody 5.2 assignment ramadan2099 2 363 Jan-05-2019, 12:54 PM
Last Post: ramadan2099

Forum Jump:


Users browsing this thread: 1 Guest(s)