Back to teaching portfolio

Chapter 2 · Input, Processing & Output

CSBP119 Practical Questions

This chapter emphasizes gathering user input, storing it in well-named variables, and emitting formatted output that decision-makers trust. The prompts below are tuned for console applications and reinforce numeric operations plus f-string reporting.

Problem 1 · Semester Budget

Housing & Living Costs Calculator

Prompt for monthly rent, utilities, and food costs, then calculate monthly and semester totals (use 5 months). All numbers should render with two decimals.

  1. Collect three float values.
  2. Compute monthly and semester totals in variables.
  3. Print both totals with currency formatting.
rent = float(input("Monthly rent (AED): "))
utilities = float(input("Monthly utilities (AED): "))
food = float(input("Monthly food budget (AED): "))

monthly_total = rent + utilities + food
semester_total = monthly_total * 5

print(f"Monthly total: {monthly_total:.2f} AED")
print(f"Semester total: {semester_total:.2f} AED")
Problem 2 · Sensor Snapshot

Greenhouse Temperature Reporter

Read minimum, maximum, and target temperature settings for a controlled greenhouse. Display a summary line that shows the range and whether the target is centered.

  1. Read integer inputs for min_temp, max_temp, target_temp.
  2. Compute the midpoint and difference between target and midpoint.
  3. Print a structured report.
min_temp = int(input("Minimum °C: "))
max_temp = int(input("Maximum °C: "))
target_temp = int(input("Target °C: "))

midpoint = (min_temp + max_temp) / 2
offset = target_temp - midpoint

print(f"Range: {min_temp}°C - {max_temp}°C")
print(f"Target {target_temp}°C is {offset:+.1f}°C from midpoint ({midpoint:.1f}°C)")
Problem 3 · Utility Monitor

Energy Cost Estimator

Collect appliance wattage and daily usage hours, then estimate the monthly cost using a fixed price per kilowatt-hour.

  1. Prompt for wattage and daily hours.
  2. Convert watts to kilowatts and multiply by hours × 30 days.
  3. Apply the tariff and print the total.
watts = float(input("Appliance wattage: "))
hours = float(input("Daily usage hours: "))
tariff = 0.32  # AED per kWh

kilowatts = watts / 1000
monthly_kwh = kilowatts * hours * 30
cost = monthly_kwh * tariff

print(f"Estimated monthly cost: {cost:.2f} AED")