Last active
December 9, 2024 23:03
-
-
Save copocaneta/00901f6c1a7c293f45a608a34a51182d to your computer and use it in GitHub Desktop.
Improve this code by managing complexity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Global variables for a product | |
product_name = "Product X" | |
product_price = 100 | |
def display_product(): | |
print(f"{product_name} costs ${product_price}") | |
def apply_discount(discount): | |
global product_price | |
product_price -= discount | |
# Using the functions and global variables | |
display_product() | |
apply_discount(10) | |
display_product() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment