0% found this document useful (0 votes)
4 views2 pages

Python Exercises QA

The document contains multiple Python programs for various calculations including an electricity bill calculator, absolute value calculator for complex numbers, employee salary slip generator, number guessing game, and movie ticket cost calculation with GST. Each program prompts the user for input and displays the respective results based on the calculations performed. The programs demonstrate basic input handling, arithmetic operations, and conditional logic.

Uploaded by

arrowakashcoc
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)
4 views2 pages

Python Exercises QA

The document contains multiple Python programs for various calculations including an electricity bill calculator, absolute value calculator for complex numbers, employee salary slip generator, number guessing game, and movie ticket cost calculation with GST. Each program prompts the user for input and displays the respective results based on the calculations performed. The programs demonstrate basic input handling, arithmetic operations, and conditional logic.

Uploaded by

arrowakashcoc
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/ 2

Electricity Bill Calculator

units = int(input("Enter number of units consumed: "))


bill = 50 # fixed meter charge

if units <= 100:


bill += units * 1.5
elif units <= 200:
bill += 100 * 1.5 + (units - 100) * 2.0
else:
bill += 100 * 1.5 + 100 * 2.0 + (units - 200) * 3.0

print("\n--- Electricity Bill ---")


print(f"Units Consumed: {units}")
print(f"Total Amount : Rs.{bill:.2f}")

Absolute Value Calculator


num = complex(input("Enter a number (real or complex): "))
print("Absolute value:", abs(num))

Employee Salary Slip


name = input("Enter employee name: ")
emp_id = input("Enter employee ID: ")
hours = float(input("Enter hours worked: "))
wage = float(input("Enter hourly wage: "))

gross = hours * wage


tax = gross * 0.10
net = gross - tax

print("\n--- Salary Slip ---")


print(f"Name : {name}")
print(f"ID : {emp_id}")
print(f"Gross Pay : Rs.{gross:.2f}")
print(f"Tax (10%) : Rs.{tax:.2f}")
print(f"Net Salary : Rs.{net:.2f}")

Guess a Number
import random
num = random.randint(1, 9)
guess = int(input("Guess a number between 1 and 9: "))
print("Correct!" if guess == num else f"Wrong! It was {num}")

Movie Ticket Cost with GST


category = input("Enter ticket category (Silver/Gold/Platinum): ").lower()
count = int(input("Enter number of tickets: "))

prices = {"silver": 120, "gold": 180, "platinum": 250}


base_cost = prices.get(category, 0) * count
gst = base_cost * 0.18
total = base_cost + gst

print("\n--- Movie Ticket Bill ---")


print(f"Category : {category.capitalize()}")
print(f"Tickets : {count}")
print(f"Base : Rs.{base_cost:.2f}")
print(f"GST (18%): Rs.{gst:.2f}")
print(f"Total : Rs.{total:.2f}")

You might also like