# ============================================== # Beginner Debugging Exercise: Simple Calculator # ---------------------------------------------- # This program is SUPPOSED to: # 1. Ask for your name # 2. Greet you # 3. Ask for two numbers # 4. Do addition, subtraction, multiplication, and division # 5. Print the results # # However... it's full of bugs! # Fix them one by one until it works correctly. # ============================================== print("Welcome to the Simple Calculator!" print("Let's do some math!") # Missing parenthesis above name = input("What is your name? ") print("Hi" name, "nice to meet you!") # Missing comma # Ask for two numbers num1 = input("Enter first number: ") num2 = input("Enter second number: ") # Convert to numbers (bug: conversion missing) # Fix: use float() or int() sum_result = num1 + num2 difference = num1 - num2 product = num1 * num2 quotient = num1 / num2 # Division by zero risk print("\n--- Results for", name, "---") print("Sum: " + sum_result) print("Difference:", difference) print("Product:", product) print("Quotient:", quotient) # Logic bug: incorrect average formula average = num1 + num2 / 2 print("Average of both numbers is:", average) # String formatting bug print("Thank you for using the calculator," name "!") # Hidden logic bug: comparing string to int if num1 > 10: print("Wow, that first number is big!") # Possible runtime bug: empty input check missing print("Goodbye")