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
  Python Assignment 5.2 amos76823 3 117 Jan-17-2019, 07:34 AM
Last Post: perfringo
  Python for Everybody 3.1 assignment ramadan2099 14 409 Jan-07-2019, 07:31 PM
Last Post: ramadan2099
  Help for my assignment - Object Oriented Programming denizkb 5 152 Jan-05-2019, 06:43 PM
Last Post: stullis
  [split] Python for Everybody 5.2 assignment ramadan2099 2 164 Jan-05-2019, 12:54 PM
Last Post: ramadan2099
  help with assignment 3 Mof44 5 209 Dec-14-2018, 01:33 PM
Last Post: Mof44
  help with assignment 2 Mof44 4 259 Nov-29-2018, 08:26 PM
Last Post: Mof44
  help with assignment Mof44 9 404 Nov-18-2018, 11:58 PM
Last Post: Larz60+
  Need help on assignment sstonne 1 274 Nov-01-2018, 02:48 PM
Last Post: sstonne
  Dictionary based assignment: Need help RoyceJ 6 532 Aug-29-2018, 05:30 AM
Last Post: perfringo
  Trouble with "Weather Program" Assignment sarah_mb_sues 5 856 Aug-10-2018, 02:29 AM
Last Post: ichabod801

Forum Jump:


Users browsing this thread: 1 Guest(s)