Python Forum
Please help. Simple homework - 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: Please help. Simple homework (/thread-24163.html)



Please help. Simple homework - Asm0deus314 - Feb-02-2020

Exercise 1:

What’s wrong with this code?

The following code should read an integer into the variable rating:

rating = input ('Enter an integer rating between 1 and 10')


Exercise 2:

Replace *** in the following code with a statement that will print the message 'Congratulations! Your grade of 91 earns you an A in this course'.

Your statement should print the value stored in the variable grade:

grade = 91

if grade >= 90:

***

Edit: I know this is day one stuff. I've tried figuring it out, but the phrasing is ambiguous to me. It's an online course, and the professor is very unhelpful. I'm not just looking for answers, but would appreciate an explanation so I can actually learn it. Thanks!


RE: Please help. Simple homework - michael1789 - Feb-02-2020

What exactly are you wanting help with? Post what you have tried.


RE: Please help. Simple homework - Asm0deus314 - Feb-02-2020

So for the first exercise, I've tried a variety of things, but I don't know exactly what's being asked. One thing I've tried is:
rating = input(int([x])
rating = input(int("Enter an integer rating between 1 and 10"))

The second I've tried:
>>> grade = 91
>>> if grade >= 90:
print: (ind('Congratulations! Your grade of 91 earns you an A in this course')

It seems that no matter what I type there, it just drops down. Not understanding how to execute the command

>>> grade = 91
>>> if grade >=90:
91 = float( input( "Congratulations! Your grade of 91 earns you an A in this course : " ) )

is this closer?


RE: Please help. Simple homework - michael1789 - Feb-02-2020

For the first one you are close, you just need to put it all in the int().
rating = int(input('Enter an integer rating between 1 and 10'))
print(rating, type(rating))
For the second, there are a number of errors. I think you just need a basic print() statement print("Hello World").