Skip to content

Instantly share code, notes, and snippets.

@omarbassam88
Last active December 7, 2024 13:46
Show Gist options
  • Select an option

  • Save omarbassam88/897533e207d0c7af7d23607145127d3a to your computer and use it in GitHub Desktop.

Select an option

Save omarbassam88/897533e207d0c7af7d23607145127d3a to your computer and use it in GitHub Desktop.
Python Programming Exercise: Functions
# Write the definition of the function print_attendance below this line
students = ["Hassan", "Morkos", "Layla", "Sara", "Sherif"]
attedance = { "Hassan": True, "Morkos": False, "Layla": False, "Sara": True, "Sherif": False }
print_attendance(students, attendance)
# print the names of every student and whether they were absent like the example below
# 1: Hassan attended
# 2: Morkos didn't attend
######################################################################
# Write the definition of the balance_after function below this line
cart = ["apple", "banana", "banana", "orange", "apple"]
prices = {"apple": 3.5, "banana": 25, "orange": 17.5}
wallet = 50
# You only have 50 EGP in your wallet. Only but the items that you can pay for
# Return what is left from the wallet after buying the items
balance_after(cart, prices, wallet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment