Generateurv2/backend/api/api/Generateur/Generateur_special/multplication.py

54 lines
1.6 KiB
Python

from .modules.roundUp import rounder
import random
import csv
def Multiplication(step, number=5):
if step == 1:
calcul_list = []
for i in range(number):
terme1 = random.randint(10, 9999)
terme2 = random.randint(2, 9)
calcul_list.append({
'calcul': f'{terme1} x {terme2} = ',
'result': f'{terme1} x {terme2} = {terme1 + terme2}'
})
return calcul_list
if step == 2:
calcul_list = []
for i in range(number):
terme1 = random.randint(10, 999)
terme2 = random.choice(['10','100', '1000'])
calcul_list.append({
'calcul': f'{terme1} x {terme2} = ',
'result': f'{terme1} x {terme2} = {int(terme1) * int(terme2)}'
})
return calcul_list
if step == 3:
calcul_list = []
for i in range(number):
terme1 =rounder( random.randint(10, 900), 10)
terme2 = random.randint(10, 999)
calcul_list.append({
'calcul': f'{terme2} x {terme1} = ',
'result': f'{terme2} x {terme1} = {terme1 * terme2}'
})
return calcul_list
if step == 4:
calcul_list = []
for i in range(number):
terme1 = rounder(random.randint(10, 999), 10)
terme2 = rounder(random.randint(10, 999), 10)
calcul_list.append({
'calcul': f'{terme1} x {terme2} = ',
'result': f'{terme1} x {terme2} = {terme1 * terme2}'
})
return calcul_list