LearnPy Hub
← Classes & Objects problems
Medium

Scale a Recipe

Write class Recipe with servings and a dictionary of ingredients (grams), and scaled(n) returning a new Recipe for n servings. Read the servings, ingredient lines name grams until END, and a new number of servings; print each ingredient of the scaled recipe with grams rounded to 1 decimal.

Input

Servings, lines, END, new servings.

Output

Lines.

Sample 1

Input
4
rice 400
lentils 200
END
6
Output
rice 600.0
lentils 300.0

Sample 2

Input
2
flour 100
END
1
Output
flour 50.0
solution.py
Output appears here
Scale a Recipe · Python practice problem · LearnPy Hub