Skip to content

Mwanjury/Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Simple Python Calculator

This is a basic command-line calculator built in Python. It allows users to perform the four fundamental arithmetic operations: addition, subtraction, multiplication, and division.

💻 Features

  • Add two numbers
  • Subtract one number from another
  • Multiply two numbers
  • Divide one number by another (with division-by-zero handling)

🧠 How It Works

The program asks the user to choose an operation (1–4), inputs two numbers, and then displays the result of the selected operation.

🧾 Code Example

def add(x, y):
    return x + y

def subtract(x, y):
    return x - y

def multiply(x, y):
    return x * y

def divide(x, y):
    if y == 0:
        return "Error: Division by zero"
    return x / y

print("Simple Calculator")
print("Select operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages