Вопрос задан 15.11.2023 в 20:58. Предмет Информатика. Спрашивает Румянцев Никита.

Pyhton. Вартість пляшки води, враховуючи вартість порожньої пляшки складає 1 грн 20 копійок, а

вартість порожньої пляшки 20 копійок. Скільки пляшок води можна випити на N гривень (ціле число) враховуючи, що порожні пляшки можна здавати, і на одержані кошти можна купувати нові пляшки води. Вода в магазині без пляшки не продається. Підказка. Зверніть увагу, що після кожної випитої пляшки води та її здачі у вас до нової покупки завжди не вистачатиме 1 гривні. 1. Візьміть аркуш паперу та спробуйте поступово обрахувати кількості випитих пляшок при наявних 1,2,3,4,5,6,7 грн. Чи прослідковується закономірність в отриманих результатах? Реалізуйте цю закономірність у середовищі Python. 2. Зберегти проєкт у власну папку з назвою «Завдання 4»
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Галь Денис.

Ответ:

n=float(input('Введіть N  '))

pl=0

while n>=1.2:

   n-=1

   pl+=1

print(f'Можна купити {pl} пляшки(-ок). У Вас залишиться {round(n, 2)} гривень')

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

To calculate the number of water bottles that can be purchased for a given amount of money, taking into account the cost of both the filled and empty bottles, we can use the following approach:

1. Start with the given amount of money (N) and initialize a variable to keep track of the number of bottles purchased (count). 2. While the amount of money is greater than or equal to the cost of a filled bottle (1.20), do the following: - Subtract the cost of a filled bottle from the amount of money. - Increment the count of bottles purchased by 1. - Add the refund received from returning an empty bottle (0.20) to the amount of money. 3. Return the count of bottles purchased.

Let's implement this logic in Python:

```python def calculate_bottle_count(N): count = 0 while N >= 1.20: N -= 1.20 count += 1 N += 0.20 return count ```

Now, you can use this function to calculate the number of water bottles that can be purchased for a given amount of money. For example, if you want to know how many bottles can be purchased for 5.00 UAH, you can call the function like this:

```python bottle_count = calculate_bottle_count(5.00) print("The number of water bottles that can be purchased for 5.00 UAH is:", bottle_count) ```

The output will be:

``` The number of water bottles that can be purchased for 5.00 UAH is: 4 ```

Please note that the implementation assumes that the refund received from returning an empty bottle is always 0.20 UAH, and the cost of a filled bottle is always 1.20 UAH.

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос