Y
Y
Yukov2020-09-08 11:43:21
Python
Yukov, 2020-09-08 11:43:21

How to multiply a number by a percentage in Python?

There is a task # (while loop)

# The student's monthly stipend is educational_grant roubles, and living expenses exceed the stipend
# and amount to expenses roubles. per month. Rising prices increase costs by 3% every month, except for the first month
# Program to calculate the amount of money you need to ask your parents at a time
# so that you can live through the school year (10 months) using only this money and a scholarship.
# Output format:
# The student should ask for XXXX.XX rubles
How to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Chichak, 2020-09-18
@ilya_chch

taking into account the comment by Sergey K , provided that you need to indicate how much money he will ask for at once:

educational_grant = float(input("Введите месячную стипендию: ")) # месячная стипуха
expenses = float(input("Введите месячный расход: ")) # расходы в месяц
i = 0
delta = 0
while i < 9:
    delta += educational_grant - (expenses + (expenses) * 0.03 * i)  # на первой итерации при i = 0, повышения цен аффектит значение
    i += 1
if delta < 0:
    print(f'нужно просить {-delta} на учебный год')
else:
    print('денег просить не надо, может еще и останется')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question