Skip to content

Files

Latest commit

a585e7f · Aug 28, 2022

History

History

Day 11

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Aug 28, 2022
Aug 28, 2022

Functions

Functions are a way to group code together to perform a specific task.

Functions are defined using the def keyword.

Functions can take parameters.

Functions can return a value.

Functions can be called recursively.

Functions can be anonymous.

Functions can be passed as parameters to other functions.

Functions can be returned from other functions.

Functions can be defined inside other functions.


Explanation of my code:

1. The food_item function is defined with the parameter preference.
2. The input function is used to ask the user for input.
3. The if statement is used to determine if the user's input is equal to the string "pizza".
4. If the user's input is equal to the string "pizza", then the print statement will print the string "I like pizza too and It's my favorite food if I had to choose one.".
5. The if statement is used to determine if the user's input is equal to the string "salad".
6. If the user's input is equal to the string "salad", then the print statement will print the string "I like salad too and It will be ready in 5 minutes with a side of dressing.".
7. The if statement is used to determine if the user's input is equal to the string "ice cream".
8. If the user's input is equal to the string "ice cream", then the print statement will print the string "I like ice cream too and we have 3 flavors and 2 toppings.".
9. The else statement is used to determine if the user's input is not equal to the string "pizza", "salad", or "ice cream".
10. If the user's input is not equal to the string "pizza", "salad", or "ice cream", then the print statement will print the string "I don't like that food but I will make it for you anyway.".
11. The main function is defined.
12. The food_item function is called with the parameter preference.
13. The main function is called.