Skip to content

Commit

Permalink
Modules variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadelmalah committed Apr 20, 2024
1 parent d46d820 commit 26b6804
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 13 additions & 2 deletions Modules/making_pizzas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pizza import make_pizza as mp

# or
# import pizza as p
# p.make_pizza(16, 'pepperoni')
Expand All @@ -7,5 +8,15 @@
# from pizza import *


mp(16, 'pepperoni')
mp(12, 'mushrooms', 'green peppers', 'extra cheese')
mp(16, "pepperoni")
mp(12, "mushrooms", "green peppers", "extra cheese")

# We can also get variables from the module
from pizza import pizza_ingriedients

print(pizza_ingriedients)

# To list all functions and variables in a module, use the dir() function
import pizza

print(dir(pizza))
5 changes: 4 additions & 1 deletion Modules/pizza.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ def make_pizza(size, *toppings):
"""Summarize the pizza we are about to make."""
print(f"\nMaking a {size}-inch pizza with the following toppings:")
for topping in toppings:
print(f"- {topping}")
print(f"- {topping}")


pizza_ingriedients = ["pepperoni", "mushrooms", "green peppers", "extra cheese"]

0 comments on commit 26b6804

Please sign in to comment.