
Помогите пожалуйста написать коды Phyton,даю 100 балов С клавиатуры вводим цену за 1 кг яблок и
груш. Вводим вес приобретенных яблок и груш. Найти стоимость покупки (общая стоимость и стоимость отдельно груш и яблок) Алгоритм работы 1. Вводим цену за 1 кг яблок и груш (целое число) 2. Вводим вес яблок и груш (действительное число) 3. Находим стоимость яблок и груш 4. Находим общую стоимость покупки 5. Выводим данные на экран Программа «Ученик» Ученик выполнял уроки 3 часа. Из них x мин он использовал на чтение естествознания, y мин использовал на заполнение тетради, z мин использовал на изучение слов по английскому языку. Все остальное время учащийся выполнял примеры по математике. Сколько примеров выполнил ученик, если для решения одного примера он использует 2 минуты? Подсказка. Результат должен быть целым числом.

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

Код1:
prise1 = int(input("Цена яблок: "))
prise2 = int(input("Цена груш: "))
mass1 = float(input("Вес яблок: "))
mass2 = float(input("Вес груш: "))
sum1 = prise1 * mass1
sum2 = prise2 * mass2
sum = sum1 + sum2
print("Стоимость: ", sum)
print("Стоимость яблок: ", sum1)
print("Стоимость груш: ", sum2)
Код2:
time = 3 * 60
x = int(input())
y = int(input())
z = int(input())
res = int((time - x - y - z) / 2)
print(res)



Ответ:
Задача 1:
apple_price = int(input("Введите цену за 1кг яблок: "))
pears_price = int(input("Введите цену за 1кг груш: "))
apple_weight = int(input("Введите вес яблок: "))
pears_weight = int(input("Введите вес груш: "))
sum_apple = apple_price * apple_weight # стоимость яблок
sum_pears = pears_price * pears_weight # стоимость груш
print(f"Стоимость яблок {sum_apple}, а груш {sum_pears}")
print("Общая стоимость покупки:", sum_apple + sum_pears)
Задача 2:
time = 180 # переводим часы в минуты
x = int(input("Введите минуты потраченные на естествознание: "))
y = int(input("Введите минуты потраченные на заполнение тетради: "))
z = int(input("Введите минуты потраченные на английский язык: "))
time_spent = x + y + z # определяем потраченное время
examples_math = (time - time_spent) // 2 # определяем кол-во примеров
print(f"Ученик выполнил {examples_math} примеров") # выводим итог на экран
Объяснение:
В комментариях



To calculate the cost of purchasing apples and pears, you can use the following Python code:
```python # Step 1: Input the price per kilogram of apples and pears apple_price = int(input("Enter the price per kilogram of apples: ")) pear_price = int(input("Enter the price per kilogram of pears: "))
# Step 2: Input the weight of apples and pears apple_weight = float(input("Enter the weight of apples in kilograms: ")) pear_weight = float(input("Enter the weight of pears in kilograms: "))
# Step 3: Calculate the cost of apples and pears apple_cost = apple_price * apple_weight pear_cost = pear_price * pear_weight
# Step 4: Calculate the total cost of the purchase total_cost = apple_cost + pear_cost
# Step 5: Display the results print("Cost of apples: ", apple_cost) print("Cost of pears: ", pear_cost) print("Total cost of purchase: ", total_cost) ```
This code prompts the user to input the price per kilogram of apples and pears, as well as the weight of the purchased apples and pears. It then calculates the cost of the apples and pears separately and the total cost of the purchase. Finally, it displays the results on the screen.
To calculate the number of math problems a student solved, given the time spent on various activities, you can use the following Python code:
```python # Step 1: Input the time spent on different activities total_time = 180 # Total time in minutes reading_time = int(input("Enter the time spent on reading natural science in minutes: ")) notebook_time = int(input("Enter the time spent on filling the notebook in minutes: ")) english_time = int(input("Enter the time spent on learning English words in minutes: "))
# Step 2: Calculate the time spent on math problems math_time = total_time - reading_time - notebook_time - english_time
# Step 3: Calculate the number of math problems solved problems_solved = math_time // 2
# Step 4: Display the results print("Number of math problems solved: ", problems_solved) ```
This code prompts the user to input the time spent on reading natural science, filling the notebook, and learning English words. It assumes that the total time spent is 180 minutes. It then calculates the time spent on math problems by subtracting the time spent on other activities from the total time. Finally, it calculates the number of math problems solved by dividing the math time by 2 (since each problem takes 2 minutes) and displays the result on the screen.
Please note that the code assumes valid inputs and does not include error handling.


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







Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili