mardi 21 septembre 2021

Creation of list with random value pairs

I want to create a list with 500 or more value pairs with the following outcome and some boundaries, but I stuck a lot with the correct syntax.

The outcome should look like following:

SiO2 = 35, Al2O3 = 12, CaO = 41, MgO = 12, T = 1498
SiO2 = 38, Al2O3 = 7, CaO = 46, MgO = 9, T = 1512
...

and so on.

I got the following code snippet so far:

from random import randint

CaO = randint(34, 40)
SiO2= randint(30, 40)
MgO = randint(5, 15)
Al2O3 = randint(5, 15)
T = randint(1400, 1550)

liste = []

for i in range(1000):
    if not CaO + SiO2 + MgO + Al2O3 == 100:
        continue
    elif CaO / SiO2 > 1.3 & CaO / SiO2 < 0.85:
        continue
    elif (CaO + MgO) / (SiO2 + Al2O3) < 0.84 & (CaO + MgO) / (SiO2 + Al2O3) > 1.25:
        continue
    else: 
        liste.append(CaO, SiO2, MgO, Al2O3, T)
        
    print(liste)

If anybody could give me some hints it would be great.

Cheers




Aucun commentaire:

Enregistrer un commentaire