COMP 1250 โ Introduction to Programming
A menu-driven Python console application that demonstrates foundational programming concepts through an interactive, user-facing interface. The program greets the user by name and presents a persistent main menu with five options, each targeting a different core concept from the COMP 1250 curriculum โ conditionals, loops, arithmetic, data types, and output formatting. The project was developed as a personal programming challenge to consolidate all topics covered in the course.
Persistent Menu Loop
A while True loop keeps the program running until the user selects Exit, demonstrating infinite loop control.
Arithmetic Calculator
Accepts two numbers and an operator (+, โ, ร, รท), evaluates the expression using nested conditionals, and prints the result.
Number Comparator
Compares two integer inputs and returns whether the first is greater, lesser, or equal โ with an invalid-input guard.
While & For Loops
Demonstrates both loop types with predetermined and user-defined ranges, including countdown and increment logic.
Input Validation
Handles invalid operator input and type conversions with int() casting, guarding against incorrect user entries.
Personalised Greeting
Prompts for a username before entering the menu loop, demonstrating string input and concatenation.
# Interactive Python Program โ COMP 1250 | Rohail Bhatti # Personalised greeting on launch username = input("Enter your username: ") print("Hello " + username + "!") while True: print("\nWelcome to the main menu") print("1. Print Hello, World!") print("2. Work with conditionals") print("3. Work with loops") print("4. Work with data types") print("5. Exit") decision = int(input("Please choose from 1 to 5: ")) if decision == 1: print("Hello World!") elif decision == 2: choice1 = input("Math expression or bigger number? ") if choice1.lower() == "math": number1 = int(input("Enter first number: ")) number2 = int(input("Enter second number: ")) operator = input("Select operator (+, -, *, /): ") if operator == "+": print("Sum:", number1 + number2) elif operator == "-": print("Diff:", number2 - number1) elif operator == "*": print("Product:", number1 * number2) elif operator == "/": print("Quotient:",number1 / number2) else: print("Invalid operator") elif choice1.lower() == "bigger": num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) if num1 > num2: print("First number is greater") elif num1 < num2: print("First number is lesser") else: print("Numbers are equal") elif decision == 3: choice2 = input("While or for loops? ") if choice2.lower() == "while": while_num = 10 while while_num >= 2: while_num -= 1 print(while_num) elif choice2.lower() == "for": for num in range(1, 11): print(num) elif decision == 5: print("Goodbye, " + username + "!") break