π Happy November π΅
Learn to create functions and use if/else
statements in Python to simulate the magical process of mixing potions with various effects.
As an apprentice in a mystical apothecary, your task is to mix potions with magical ingredients. Each ingredient affects the potion differently, and you must use your Python skills to achieve the desired magical results.
Create a function named mix_potion
that takes an ingredient
parameter. Depending on the ingredient, the potion will change color. Youβll use if
and elif
statements to check the ingredient and print
the potionβs color.
def
followed by the function name and parentheses ()
.if
for the first condition, elif
for additional conditions, and else
for the final condition when none of the if
or elif
conditions are met.Add special effects to the potions. Depending on the ingredients, the potion can have additional properties like sparkling, glowing, or even exploding.
if
statements to create sub-conditions within a condition.After completing the tasks, create a video where you reflect on the following:
if/else
statements help you control the flow of your potion-making function?