Skip to content

Commit

Permalink
update popcorn hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypernova101 committed Oct 9, 2024
1 parent ec95878 commit 737e885
Showing 1 changed file with 95 additions and 1 deletion.
96 changes: 95 additions & 1 deletion _notebooks/Foundation/2024-10-09-3_2_popcorn_hacks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hack 2\n",
"## OPTIONAL Popcorn Hack 2\n",
"\n",
"Try creating a dictionary for your github homepage that contains what was within each sprint. For example, in Sprint 1, we had frontend development, github pages playgroud, and javascript playground."
]
Expand Down Expand Up @@ -137,6 +137,100 @@
"# Call the function to display sprint details\n",
"print_sprint_details(sprints)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Popcorn Hack 3\n",
"Create a mix of list and dictionaries to represent a real world collection of data. I will do a car rental system."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model: Tesla Model 3\n",
"Manufacturer: Tesla\n",
"Rental Rate: $150 per day\n",
"Available: Yes\n",
"Renters:\n",
" - John Doe (Rented from: 2024-09-20 to 2024-09-25)\n",
" - Jane Smith (Rented from: 2024-10-01 to 2024-10-05)\n",
"\n",
"\n",
"Model: BMW X5\n",
"Manufacturer: BMW\n",
"Rental Rate: $120 per day\n",
"Available: No\n",
"Renters:\n",
" - Alice Brown (Rented from: 2024-09-15 to 2024-09-20)\n",
"\n",
"\n",
"Model: Toyota Corolla\n",
"Manufacturer: Toyota\n",
"Rental Rate: $80 per day\n",
"Available: Yes\n",
"No renters yet.\n",
"\n",
"\n"
]
}
],
"source": [
"# A list of dictionaries representing cars in a rental system\n",
"car_rental_system = [\n",
" {\n",
" \"model\": \"Tesla Model 3\",\n",
" \"manufacturer\": \"Tesla\",\n",
" \"rental_rate\": 150, # rate per day in USD\n",
" \"available\": True,\n",
" \"renters\": [\n",
" {\"name\": \"John Doe\", \"rental_date\": \"2024-09-20\", \"return_date\": \"2024-09-25\"},\n",
" {\"name\": \"Jane Smith\", \"rental_date\": \"2024-10-01\", \"return_date\": \"2024-10-05\"}\n",
" ]\n",
" },\n",
" {\n",
" \"model\": \"BMW X5\",\n",
" \"manufacturer\": \"BMW\",\n",
" \"rental_rate\": 120,\n",
" \"available\": False,\n",
" \"renters\": [\n",
" {\"name\": \"Alice Brown\", \"rental_date\": \"2024-09-15\", \"return_date\": \"2024-09-20\"}\n",
" ]\n",
" },\n",
" {\n",
" \"model\": \"Toyota Corolla\",\n",
" \"manufacturer\": \"Toyota\",\n",
" \"rental_rate\": 80,\n",
" \"available\": True,\n",
" \"renters\": []\n",
" }\n",
"]\n",
"\n",
"# Function to display information about each car in the rental system\n",
"def print_car_rental_info(rental_system):\n",
" for car in rental_system:\n",
" print(f\"Model: {car['model']}\")\n",
" print(f\"Manufacturer: {car['manufacturer']}\")\n",
" print(f\"Rental Rate: ${car['rental_rate']} per day\")\n",
" print(f\"Available: {'Yes' if car['available'] else 'No'}\")\n",
" if car['renters']:\n",
" print(\"Renters:\")\n",
" for renter in car['renters']:\n",
" print(f\" - {renter['name']} (Rented from: {renter['rental_date']} to {renter['return_date']})\")\n",
" else:\n",
" print(\"No renters yet.\")\n",
" print(\"\\n\")\n",
"\n",
"# Call the function to display the car rental system information\n",
"print_car_rental_info(car_rental_system)\n"
]
}
],
"metadata": {
Expand Down

0 comments on commit 737e885

Please sign in to comment.