Python Forum
Python for Everybody 3.3 assignment
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'
Reply
#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.
likes this post
Reply
#3
print()
Reply
#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?
Reply
#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.
Reply
#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
Reply
#7
It is not getting output. It shows "your program does not have any output"
Reply
#8
https://docs.python.org/3/whatsnew/3.0.h...a-function
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python for Everybody 5.2 assignment baba04201 20 173,232 Jul-25-2023, 04:15 PM
Last Post: MicaelSchutz
  Python for Everybody 3.1 assignment ramadan2099 18 45,372 Jan-23-2021, 06:27 AM
Last Post: KonohaHokage
  Coursera python for everybody 5.2 assignment SteppentigerV2 11 12,810 Oct-22-2020, 11:57 AM
Last Post: Larz60+
  [split] Python for Everybody 5.2 assignment ramadan2099 3 12,036 Jul-15-2020, 04:54 PM
Last Post: Bipasha
  Python Assignment 3 - Applied Data Science - 2.3 eyavuz21 8 4,940 Jun-06-2020, 08:59 AM
Last Post: eyavuz21
  Python Password Saver Assignment sshellzr21 2 6,144 May-02-2020, 01:34 AM
Last Post: sshellzr21
  Python for everyone course assignment 5.2 ofekx 3 8,525 Dec-23-2019, 08:41 PM
Last Post: nilamo
  [split] Python for Everybody 5.2 assignment jonchanzw 4 8,453 Oct-22-2019, 08:08 AM
Last Post: perfringo
  Python Assignment 5.2 amos76823 3 15,961 Jan-17-2019, 07:34 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020