Python Forum
Finding MINIMUM number in a random list is not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding MINIMUM number in a random list is not working
#1
Hello,
I am trying to display the minimum number in a randomly created list but I am getting noting printed for the min function. I have my codes and display below. Any help is highly appreciated.

Here are the codes:
import random

random_numbers = []
average = 0
total = 0

for i in range(3):
    x = int((random.randint(0, 9)))
    random_numbers.append(x)
    total = sum(random_numbers)
    average = float(total / 3)
    
random_numbers = ', '.join(map(str, random_numbers))
print(random_numbers)

print("Low:", min(random_numbers))
print("High:", max(random_numbers))

print("average:", format(average,'.2f'))
print("Total:", total)
Here is the display:
Output:
>>> 9, 3, 2 Low: High: 9 average: 4.67 Total: 14 >>>
Reply


Messages In This Thread
Finding MINIMUM number in a random list is not working - by Mona - Nov-17-2019, 05:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sample random, unique string pairs from a list without repetitions walterwhite 1 465 Nov-19-2023, 10:07 PM
Last Post: deanhystad
  Error is finding mean of a list PythonBoy 4 928 Sep-11-2023, 02:38 PM
Last Post: PythonBoy
  Delete strings from a list to create a new only number list Dvdscot 8 1,555 May-01-2023, 09:06 PM
Last Post: deanhystad
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,258 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  Finding combinations of list of items (30 or so) LynnS 1 885 Jan-25-2023, 02:57 PM
Last Post: deanhystad
  List of random numbers astral_travel 17 2,725 Dec-02-2022, 10:37 PM
Last Post: deanhystad
  [split] why can't i create a list of numbers (ints) with random.randrange() astral_travel 7 1,530 Oct-23-2022, 11:13 PM
Last Post: Pedroski55
  Finding the price based on industry and number of transactions chandramouliarun 0 915 Jul-26-2022, 07:36 PM
Last Post: chandramouliarun
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,893 Jul-01-2022, 01:23 PM
Last Post: deanhystad
Question Finding string in list item jesse68 8 1,897 Jun-30-2022, 08:27 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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