Assignment 2 U0P
Assignment 2 U0P
def print_circum(radius):
circumf = 2 * 3.14159 * radius
print ("The circumference of this circle with a radius of", radius, "is", circumf)
print_circum (5)
print_circum(10)
print_circum(2.5)
Output:
The circumference of this circle with a radius of 5 is 31.4159
The circumference of this circle with a radius of 10 is 62.8318
The circumference of this circle with a radius of 2.5 is 15.70795
>
Explanation: I created a function named print_circum() which holds a parameter called
‘radius'. I also created a local variable called ‘circumf' which holds the formula for
calculating the circumference of a circle using pi as 3.14159 and what ever argument passed
by the user as the radius. Finally I printed out an output which displays the result after
calculation.
I called my created function thrice passing 3 different arguments and it printed out the correct
answers of the circumference of each circle taking into consideration there various radius
Exercise 2:
def company_cat():
item_price1 = 200.00
item_price2 = 150.00
item_price3 = 300.00
mix_price1 = item_price1 + item_price2 - 0.1 * (item_price1 + item_price2)
mix_price2 =item_price2 + item_price3 - 0.1 * (item_price2 + item_price3)
mix_price3 =item_price1 + item_price3 - 0.1 * (item_price1 + item_price3)
gift_package_price = item_price1 + item_price2 + item_price3 - 0.25 * (item_price1 +
item_price2 + item_price3)
print("Online Store")
print("‐-------------------")
print("Product(s) Price")
print(f"Item 1", {item_price1})
print(f"Item 2", {item_price2})
print(f"Item 3", {item_price3})
. print(f"Combo 1. Item 1 + 2", mix_price1)
print(f"Combo 2. Item 2 + 3", mix_price2)
print(f"Combo 3. Item 1 + 3", mix_price3)
print(f"Combo 4. Item 1 + 2 + 3", gift_package_price)
print("---------------------")
print(" For delivery contact 98764678899")
company_cat()
Output:
Online Store
‐-------------------
Product(s) Price
Item 1 200.0
Item 2 150.0
Item 3 300.0
Combo 1. Item 1 + 2 315.0
Combo 2. Item 2 + 3 405.0
Combo 3. Item 1 + 3 450.0
Combo 4. Item 1 + 2 + 3. 487.5
---------------------
For delivery contact 98764678899
>