Проблема состоит в том, что у меня есть платформа для работы, в которой мне нужно вычислить и расчет вручную, настолько утомительна, поэтому я создал Код в Python, который работает хорошо, как я хочу, но я хочу показать его графически, поэтому я изменил код на JavaScript, чтобы показать в таблице, в отличие от списков Python, но это создает ресурс для 11 рядов, но мне нужно минимум 50 раундов
** Другими словами, мне нужен расчет, который покажет мне, что добавить дальше от первого до 50 в форме таблицы. ** < /p>
Я попробовал ниже html -код и хотел получить ресурс кода Python, который в конце I суммирует форму через html. < /p>
Код: Выделить всё
Calculator
body {
font-family: Arial, sans-serif;
}
h1 {
text-align: center;
}
.input {
background-color: #f7f7f7;
padding: 2em;
border: 1px solid #ddd;
box-shadow: 0 0 10px rgba(0, 0, 0, 1);
}
.output {
background-color: #f7f7f7;
padding: 2em;
border: 1px solid #ddd;
box-shadow: 0 0 10px rgba(0, 0, 0, 1);
}
< /code>
Calculator
Calculate
Round no.
Amount
Total in
Status
Total out
Profit
< /code>
function CanculateInningsandprofit () {< /p>
const amountForCalculation = parseInt(document.querySelector('input[type="number"]').value);
const amount = 20;
const addingAmount = 20;
let totalInF = 0;
let roundsNo = [];
let amountsIn = [];
let totalsIn = [];
let profits = [];
let round = 1;
let addRow = true;
while (addRow) {
let maxProfitIn = amount * 11.4;
let totalIn = totalInF + amount;
let profit = maxProfitIn - totalIn;
if (totalIn > amountForCalculation) {
addRow = false;
} else {
totalsIn.push(totalIn);
profits.push(profit);
amountsIn.push(amount);
totalInF = totalIn;
if (totalIn < maxProfitIn) {
// do nothing
} else {
amount += addingAmount;
}
round++;
}
}
roundsNo = Array.from({length: totalsIn.length}, (_, i) => i + 1);
const outputTableBody = document.getElementById('output-table-body');
outputTableBody.innerHTML = '';
for (let i = 0; i < roundsNo.length; i++) {
const row = document.createElement('tr');
row.innerHTML = `
${roundsNo[i]}
${amountsIn[i]}
${totalsIn[i]}
${profits[i]}
`;
outputTableBody.appendChild(row);
}
Код: Выделить всё
Суммы_вход = []
Итоги_вход = []< /p>
Прибыль = []
сумма_для_расчета = 1000000
сумма = 20
adding_amount = 20
total_in_f = сумма
Totals_in.append(total_in_f)
Profits.append(amount*11.4-total_in_f)
Amounts_in.append(amount)
while total_in_f < сумма_для_расчета:
Код: Выделить всё
last_total_in = Totals_in[-1]
max_profit_in = amount * 11.4
total_in = last_total_in + amount
profit = max_profit_in - total_in
if total_in > amount_for_calculation:
break
if total_in < max_profit_in:
Totals_in.append(total_in)
Profits.append(profit)
Amounts_in.append(amount)
else:
amount += adding_amount
max_profit_in = amount * 11.4
total_in = last_total_in + amount
profit = max_profit_in - total_in
if total_in < max_profit_in:
Totals_in.append(total_in)
Profits.append(profit)
Amounts_in.append(amount)
total_in_f = total_in
print ("rounds_no:", rounds_no)
print ("uments_in:", uments_in) < /p>
print ("totals_in:", totals_in) < /p>
print (" «Прибыль:», прибыль)
Подробнее здесь: https://stackoverflow.com/questions/793 ... reates-for