Programming Assignment Unit 2
Programming Assignment Unit 2
def print_circum(radius):
Explanation:
1. Function Definition:
o The print_circum function takes one argument, radius, which is the radius of
the circle.
o Inside the function, we use the formula for the circumference of a circle, C=2πr
o The result is printed using Python's formatted string feature, rounding the
2. Function Calls:
o The function is called three times, each with a different radius (5, 10, and 15).
Each call calculates the circumference for a circle with the given radius.
3. Output:
o The function prints the circumference for each radius passed to it. The output is
Part 2
def print_catalog():
"""
This function displays the catalog for Tsega's Online Store with the prices for individual items
and the discounted prices for combo packs and the gift pack.
"""
item_prices = {
# Discount calculations
combo_prices.items()}
print("=" * 50)
print("-" * 50)
# Print the prices of individual items
print(f"{item.ljust(40)}${price}")
print(f"{combo.ljust(40)}${discounted_price:.2f}")
{gift_pack_price_discounted:.2f}")
print_catalog()
References
Downey, A. (2015). Think Python: How to Think Like a Computer Scientist. Green Tea
Press. Link to book.
Python Documentation. https://docs.python.org.