0% found this document useful (0 votes)
12 views4 pages

CHP 3 Remaining

Chapter 3, solved exercise pdf python

Uploaded by

hamzamughal1549
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

CHP 3 Remaining

Chapter 3, solved exercise pdf python

Uploaded by

hamzamughal1549
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

5/3/23, 10:20 AM Untitled10 - Jupyter Notebook

Python Chp # 3(Exercise)

Question # 3.19
In [1]: amount = int(input("Enter the amount deposited: "))

if amount < 5000:
interest_rate = 0.03
elif amount < 10000:
interest_rate = 0.04
elif amount < 20000:
interest_rate = 0.05
else:
interest_rate = 0.06

interest = amount * interest_rate

print("Interest earned for one year: Rs.", interest)

Enter the amount deposited: 10000


Interest earned for one year: Rs. 500.0

Question # 3.20
In [4]: # ask the user for the item name, previous price, and current price
item_name = input("Enter the item name: ")
previous_price = float(input("Enter the previous price: "))
current_price = float(input("Enter the current price: "))

price_difference = current_price - previous_price
price_change_percent = (price_difference / previous_price) * 100

if price_difference > 0:
print(f"The price of {item_name} has increased by {price_change_percent:.2f
elif price_difference < 0:
print(f"The price of {item_name} has decreased by {price_change_percent:.2f
else:
print(f"The price of {item_name} has not changed.")

Enter the item name: Mangoes


Enter the previous price: 500
Enter the current price: 800
The price of Mangoes has increased by 60.00%.

localhost:8889/notebooks/Desktop/jupyter notebook/Untitled10.ipynb 1/4


5/3/23, 10:20 AM Untitled10 - Jupyter Notebook

In [29]: # ask the user for the item name, previous price, and current price
item_name = input("Enter the item name: ")
previous_price = float(input("Enter the previous price: "))
current_price = float(input("Enter the current price: "))

price_difference = current_price - previous_price
price_change_percent = (price_difference / previous_price) * 100

if price_difference > 0:
print(f"The price of {item_name} has increased by {price_change_percent:.2f
elif price_difference < 0:
print(f"The price of {item_name} has decreased by {price_change_percent:.2f
else:
print(f"The price of {item_name} has not changed.")

Enter the item name: Mangoes


Enter the previous price: 500
Enter the current price: 300
The price of Mangoes has decreased by -40.00%.

Question # 3.21
In [11]: units = int(input("Enter the number of units consumed: "))

# Calculate the electricity charges
if units <= 100:
charges = units * 7.74
elif units <= 200:
charges = 100 * 7.74 + (units - 100) * 10.06
elif units <= 300:
charges = 100 * 7.74 + 100 * 10.06 + (units - 200) * 12.15
elif units <= 700:
charges = 100 * 7.74 + 100 * 10.06 + 100 * 12.15 + (units - 300) * 19.55
else:
charges = 100 * 7.74 + 100 * 10.06 + 100 * 12.15 + 400 * 19.55 + (units - 7

# Print the electricity charges
print("The electricity charges are Rs.",charges)

Enter the number of units consumed: 200


The electricity charges are Rs. 1780.0

Question # 3.23

localhost:8889/notebooks/Desktop/jupyter notebook/Untitled10.ipynb 2/4


5/3/23, 10:20 AM Untitled10 - Jupyter Notebook

In [13]: income = int(input("Enter annual income: "))



if income <= 400000:
tax = 0
elif income <= 600000:
tax = (income - 400000) * 0.05
elif income <= 1200000:
tax = 10000 + (income - 600000) * 0.1
elif income <= 2400000:
tax = 70000 + (income - 1200000) * 0.15
elif income <= 3000000:
tax = 250000 + (income - 2400000) * 0.2
elif income <= 4000000:
tax = 370000 + (income - 3000000) * 0.25
elif income <= 6000000:
tax = 620000 + (income - 4000000) * 0.3
else:
tax = 1220000 + (income - 6000000) * 0.35

print("Income tax payable: ", tax)

Enter annual income: 500000


Income tax payable: 5000.0

Question # 3.24
In [27]: gain = float(input("Enter the gain amount in Rs.: "))

if gain <= 0:
tax = 0
elif gain <= 5000000:
tax = gain * 0.035
elif gain <= 10000000:
tax = 175000 + (gain - 5000000) * 0.075
elif gain <= 15000000:
tax = 575000 + (gain - 10000000) * 0.1
else:
tax = 1075000 + (gain - 15000000) * 0.15

print("The tax on a gain of Rs.",gain,"is Rs.",tax)

Enter the gain amount in Rs.: 400000


The tax on a gain of Rs. 400000.0 is Rs. 14000.000000000002

Exercise # 3.25

localhost:8889/notebooks/Desktop/jupyter notebook/Untitled10.ipynb 3/4


5/3/23, 10:20 AM Untitled10 - Jupyter Notebook

In [28]: holding_period = float(input("Enter the holding period of the immovable propert


original_gain = float(input("Enter the original gain on selling the immovable p

if holding_period <= 1:
taxable_gain = original_gain * 1
elif holding_period <= 2:
taxable_gain = original_gain * 0.75
elif holding_period <= 3:
taxable_gain = original_gain * 0.5
elif holding_period <= 4:
taxable_gain = original_gain * 0.25
else:
taxable_gain = 0

print("The taxable gain on the immovable property is:", taxable_gain)

Enter the holding period of the immovable property (in years): 2


Enter the original gain on selling the immovable property: 47
The taxable gain on the immovable property is: 35.25

localhost:8889/notebooks/Desktop/jupyter notebook/Untitled10.ipynb 4/4

You might also like