Python Forum
help with 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: help with homework (/thread-13712.html)

Pages: 1 2


help with homework - the_last - Oct-28-2018

I need help with creating a manually generated float list.

Results should look like this

[Image: unknown.png]

Thanks!


RE: help with homework - j.crater - Oct-28-2018

What have you tried?
Post your attempt (in code tags) and explain the (incorrect) results you get. Or post full error traceback message (in error tags) if you get errors.


RE: help with homework - the_last - Oct-28-2018

Hi,

I don't know where to begin. I got the beginning line, but that's it.

print("Sales Tax Calculator")
print("")
print("ENTER ITEMS (ENTER 0 TO END)")



RE: help with homework - j.crater - Oct-28-2018

It looks like there will need to be a repetition (asking user to enter values), so a loop is in place.


RE: help with homework - the_last - Oct-28-2018

print("Sales Tax Calculator")
print("")
print("ENTER ITEMS (ENTER 0 TO END)")

cost_of_item = float(input("Cost of item: "))

while(cost_of_item > 0):
    print()
    print("Cost of item: ", cost_of_item)
issue with this code is that the results are infinite. I want to have separate instances as shown in the image.


RE: help with homework - j.crater - Oct-28-2018

That's a good start.
The loop cycles infinitely because the condition in while loop never changes. Make sure user can input a new number afer each iteration, so that cost_of_item is updated, and while() can check against new condition.


RE: help with homework - the_last - Oct-28-2018

How do I reset?

print("Sales Tax Calculator")
print("")
print("ENTER ITEMS (ENTER 0 TO END)")

cost_of_item = 1

while(cost_of_item > 0):
    cost_of_item = float(input("Cost of item: "))
    print()
    print("Cost of item: ", cost_of_item)
So I have separate numbers - I want to build an aggregate list.


RE: help with homework - j.crater - Oct-28-2018

Any code you write after the while loop will be executed when the loop exits.
As for the calculations, you will need to store the values after each loop iteration in a proper data type / container.
If you read about some Python basics you will easily figure this out.


RE: help with homework - the_last - Oct-29-2018

Hi,

I don't know which tool(code) I need to use.


RE: help with homework - j.crater - Oct-29-2018

Hello,
reading a basic tutorial will probably be enough to learn all you need to solve this task.
Make sure you learn about data types (and basic operations on them), conditional statements and loops.
It really doesn't take too much effort to learn the basics, but it's probably not a single afternoon task if you are a beginner.
There is plenty of resources online, as well as in the Tutorials section of our forum.
If you have more questions or face coding issues feel free to post back.