Page 625 - ComputerScience_Class_11
P. 625
32. Write a budget calculator program to calculate the monthly budget based on the income and expenses.
Program 32.py
File Edit Format Run Options Window Help
income = float(input("Enter your monthly income: "))
expenses = float(input("Enter your total monthly expenses: "))
balance = income - expenses
print("Your monthly balance is: ", balance)
if balance >= 0:
print("You're within your budget!")
else:
print("You're exceeding your budget!")
The output of the preceding program is as follows:
Output
Enter your monthly income: 24300
Enter your total monthly expenses: 15000
Your monthly balance is: 9300.0
You're within your budget!
33. Write a program to create simple calculator.
Program 33.py
File Edit Format Run Options Window Help
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
operation = input("Enter the operation (+, -, *, /): ")
if operation == "+":
result = num1 + num2
print("Result: ", result)
elif operation == "-":
result = num1 - num2
print("Result: ", result)
elif operation == "*":
result = num1 * num2
print("Result: ", result)
elif operation == "/":
if num2 != 0:
result = num1 / num2
print("Result: ", result)
else:
print("Error! Division by zero.")
else:
print("Invalid operation!")
Internal Assessment 623

