I recently started learning python.
I am creating a small program to get input from user then python will generate that number of random numbers from 1 to 100.
Enter number of integers to be generated: 10
Generated values: 77 15 13 54 96 73 100 12 98 28
My question is how to find the maximum, minimum and average number from generated random numbers. Thanks in advance slight_smile:
n = int(input("Enter number of integers to be generated: “))
print(n, “Generated values:”, end=” “)
for i in range(n):
r = random.randint(1, 100)
print(r, end=” ")
You keep track of the current maximum, current minimum and total in the body of your for loop. At the end, the current maximum is the maximum of all of them, the current minimum is the minimum of all of them and the total can be divided by the number of integers to get the average.
In your loop you could add each random number to a list, as well as calculate the “running sum”.
When the loop is finished you could take your
total / yourList.length for your average. The max and min can be found using
You could also sort the list, this would put your min at the beginning of the list and the max at the end, from there use bracket notation to extract.
You might find these links helpful for what you are trying to do.
min and max methods
augmented assignment operators
I was given an assignment in school on python, but I don’t know how to program. please I need advice on the python course / guidance or personal assistance to solve this problem. below are the details of the project:
It is very dangerous to carry out construction under the crane. Your research work is to judge this situation. The main work can be divided into the following steps:
(1) Collect at least 1000 pictures of construction under the crane, the more the better. Of course, some pictures including the crane but not including the construction scene under the crane are also required.
(2) Use labelimg or other annotation tools to classify and annotate the collected images and generate corresponding XML configuration files
(3) Use Yolo or other deep learning models to train the marked pictures and realize the identification of construction under the crane. The recognition accuracy shall be more than 90%.
(4) The recognition algorithm is applied to the video scene.
(5) Strive to write an international conference paper.
First: create a new topic for a new question like this.
Second: it sounds like this course is expecting you to have some pretty significant Machine Learning background otherwise they would have taught it to you in the course. If you are not prepared to answer this type of problem it sounds like you should drop the course.
Welcome to the community. I think you would have better luck on someone seeing your post if you created a new topic. It is usually a good idea to keep posts related to a single issue.
If that is your school work and you are new to programming then I feel for you. Hope you get it sorted out.
I design cranes for a living and for some reason took it personally when I read cranes are dangerous to work under. My mind starting going through a lot of OSHA codes. This has nothing to do with your issue and the fact that I am mentioning only confirms that old age is kicking in. The tangents…
best of luck
@jmrunkle beat me to the post. That’s what I get for rambling like a senior citizen…not that there is anything wrong with senior citizens…
Honestly, I am very new to programming, it’s my degree project by my supervisor, I don’t really know where to start. hope someone can rescue me
Honestly, I am very new to programming, it’s my degree project by my supervisor, I don’t really know where to start. i just hope someone can rescue me
We can try to give you some advice but please login to the website and create a new topic for your post.