It's a problem that implements functions without sum, max, and min!
import random
def randStat(n):
rand_list=random.sample(range(0,100),n)
# 0 : sum sum like variable declaration
For val in range (0, len (rand list)) : # rand counts replace them.. factors _ list
= + sum rand list the [val] # sum (_ rand list) alternative.
High=rand_list[0]
Low rand _ list, [0] # low high like variable declaration.
if High < rand_list[val]:
High rand _ list [val] # is more a big factor is a big factor in updates.
else:
Low rand _ list [val] # the smaller update as is smaller, low
Avg = Sum/len(rand_list)
print(rand_list)
print(Sum, Avg, High, Low)
randStat(10)
I made it like this and printed it out It's printed out like below.
Minimum value The maximum value cannot be read properly. Masters, please help me.
list python
else
Partial logic is incorrect.
That if
is executed only when the current value is maximum, and vice versa, else
is always executed when the current value is not maximum. That could be the case even when the current value is the minimum value, but it could be the case even if it's not.
You'll have to change where else
is now and burn a separate conditional branch.
if Low > rand_list[val] :
High=rand_list[0]
Low rand _ list, [0] # low high like variable declaration.
This phrase must exist before entering the for statement.
© 2024 OneMinuteCode. All rights reserved.