import random
import numpy as np
print("How many times would you like to simulate it?">> ")
n = int(input())
# Enter the number of simulations
print("How many products do you have?>> ")
q = int(input())
# Enter the number of products
print("How many do you want to pick?">> ")
t = int(input())
# Enter the number of peaking tote
A1 = (1,2,3,4,5,6,7,8,9,10,6,7,8,10,11,21,22,24,25,26,27,28,29,30,31)
arr1, arr2, arr3 = [], [], []
For i in range(n): # Set the number of simulations
For i in range(q): # Repeat as many as the number of products
x = generate random numbers between int(random.randrange(1,11)) #(1~10)
if x <= 7: # 7 or less (70%)
ax = int(random.choice(A1)) # Select score in A1 interval
arr1.append(ax) #Sort selected scores to arr1
if x >7 and x<= 9: # Exceeds 7 and 9 and less (20%)
ax = int(random.choice(B1) # Select score in B1 interval
arr2.append(ax) #Sort selected scores into arr2
if x>9 and x<=10: # Exceeds 9 and 10 or less (10%)
ax = int(random.choice(C1)) # Select score in C1 interval
arr3.append(ax)
arr1.sort(), arr2.sort(), arr3.sort()
a = np.array(arr1)
charr1 = np.where(a==22,20,a)
The question is only at the bottom, but I want to change it to 20 when the value in arr1 is 22, but I want to add more conditions like 18 on the 24th and 16 on the 17th and 26th on the 25th.
python
>>> l = list(range(1, 40, 5))
>>> l
[1, 6, 11, 16, 21, 26, 31, 36]
>>> replace_dict = { 21:18, 26:109, 33:11 }
>>> replace_dict
{21: 18, 26: 109, 33: 11}
>>> l = [ replace_dict.get(e, e) for e in l ]
>>> l
[1, 6, 11, 16, 18, 109, 31, 36]
>>>
© 2024 OneMinuteCode. All rights reserved.