HELP! Floating numbers and loops


#1

PLEASE HELP ME!

Here is my assignment:

Write a loop control program that will provide important statistics for the grades in a class. The program will utilize a loop to read five floating-point grades from user input. Ask the user to enter the values, then print the following data: Average Maximum Minimum

My textbook and instructor have really given me no guidance on how to use floating numbers in a loop. Here is what I have come up with so far:


for grade in range(5):
    int(input("Enter Grade (percentage): "))
    if max:
        print('Max:')
    if min:
        print('Min:')
else:
    print('Average:')

This allows me to get the loop to run 5 times but how do I actually calculate the min, max, and average for unknown variables?


#2

you would need to collect the data first, and store it. What data type do we have for this?


#3

The data is supposed to be input by the user. That’s why I’m not sure how to actually do the calculations when I don’t know what the user will input.


#4

then you need to validate the user input, and store the user input. How else are you are going to do calculations?

So we need a data type which can hold multiple values. What data type does python have for this?


#5

Are you referring to a dictionary? Or something more simple like a string?

I was able to get the loop to run 5 times which will allow me to get the user input that I need. What I don’t know how to do is store the information and then run the calculations for min, max, and average.


#6

It can be difficult at times to give an answer without doing the task for you. It’s made a whole lot worse when not knowing what you’ve been taught so far and what you’re supposed to be figuring out yourself.

Presumably you have learned, or are learning python in some manner. Somewhere in that material they must surely have gone over how to deal with multiple values?

Before considering that though, perhaps you should make sure that you’re reading them in correctly? Otherwise you’re moving to next problem before having solved the first. I suggest writing them back out after converting them to test that.

And, have you thought through what behaviour you would need from that container of values? There’s a lot to learn about what you need to write from studying how you yourself carry out the task manually.


#7

I’m taking a basic programming class online and unfortunately we all seem to be struggling with this unit. I’ve learned the basic math functions, strings, lists, and dictionaries. This week we learned about loops and I understand the concept of the for and while loops, but I do not understand what to do unknown variables. All of our examples have been given to us like this:

for name in [‘Bill’, ‘Nicole’, ‘John’]:
print ‘Hi %s!’ % name

I don’t want someone to do the work for me. I just want to understand how to store the information that is input by a user. I feel like I’m doing an assignment that I wasn’t given the tools to do.


#8

we having been trying to hint that list is very suitable to store multiple values (which you will get). Only now you need to figure out how to add the user input to the list


#9

Thank you! I’m sorry for the trouble just new to all of this and feeling very lost trying to teach myself.


#10

it is very challenging in the beginning. Butt ionation proves a valid point, you need to understand, think about it, ask critical questions


#11

No. Of course not.
It’s really hard to figure out what to say, that’s all.
You’re touching on almost every aspect of the task! Asking about one thing and describing how it’s blocking you can really help.

It doesn’t have much to do with min/max/average, does it? And it’s not about loops. It’s about reading input. What about that is the trouble though? Reading? Converting? Storing?
If it’s about storing, then you’d have to have made sure that you’re correctly reading and converting. But your code doesn’t have that finished, so that’s probably not it either.

The problem there is that there’s a lot of figuring out what the question is, and to answer it requires some kind of fix-it-all answer. And it’s not great to both have to refine the question, and to answer it.

Narrow it down as much as possible and ask about the one thing that blocks you.