Skip to content

Instantly share code, notes, and snippets.

@copocaneta
Last active December 9, 2024 23:03
Show Gist options
  • Save copocaneta/00901f6c1a7c293f45a608a34a51182d to your computer and use it in GitHub Desktop.
Save copocaneta/00901f6c1a7c293f45a608a34a51182d to your computer and use it in GitHub Desktop.
Improve this code by managing complexity
# 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