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
  Write pseudo code for a class assignment Scrimshot 3 156 May-07-2019, 05:38 PM
Last Post: Scrimshot
  Need help with my assignment please - game of Solitaire Muzz 2 226 Apr-09-2019, 03:48 PM
Last Post: Muzz
  [split] University Assignment Help needed Nomathemba 2 130 Apr-07-2019, 11:49 PM
Last Post: micseydel
  Powerball assignment, how to get correct output of a dictionary ? msp1981 5 192 Mar-19-2019, 11:02 PM
Last Post: Yoriz
  Help with homework assignment grayarea3 1 254 Feb-20-2019, 10:10 PM
Last Post: ichabod801
  Help with assignment dxfrelince 7 377 Feb-18-2019, 09:16 PM
Last Post: dxfrelince
  Need help with a tough school assignment datson79 5 279 Feb-18-2019, 06:01 PM
Last Post: ichabod801
  Need some help with a bit of code for an assignment. JackMercer50 1 186 Feb-09-2019, 04:13 PM
Last Post: stullis
  Help with arrays assignment hyg71886 15 581 Jan-30-2019, 09:36 AM
Last Post: perfringo
  Python Assignment 5.2 amos76823 3 593 Jan-17-2019, 07:34 AM
Last Post: perfringo

Forum Jump:


Users browsing this thread: 1 Guest(s)