0% found this document useful (0 votes)
0 views1 page

01 Basic Calculator

This document outlines a basic calculator program in Python that performs addition, subtraction, multiplication, and division using functions. It includes a code explanation and an example usage of the calculator function. The project is designed for beginners to learn about functions and conditional statements in Python.

Uploaded by

tannguyenne2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views1 page

01 Basic Calculator

This document outlines a basic calculator program in Python that performs addition, subtraction, multiplication, and division using functions. It includes a code explanation and an example usage of the calculator function. The project is designed for beginners to learn about functions and conditional statements in Python.

Uploaded by

tannguyenne2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Title: Mini Python Project – Basic Calculator

Description:
This document presents a simple calculator program in Python using functions. It
supports basic operations such as addition, subtraction, multiplication, and
division. Suitable for beginners learning how to use functions in Python.

---

Code Explanation:
The calculator function takes two numbers and a string indicating the operation.
Based on the operation, it returns the corresponding result.

---

Python Code:
def calculator(a, b, operation):
if operation == 'add':
return a + b
elif operation == 'subtract':
return a - b
elif operation == 'multiply':
return a * b
elif operation == 'divide':
return a / b
else:
return "Invalid operation"

# Example usage
print("Result:", calculator(10, 5, 'add'))

---

Conclusion:
This code is a good example to understand Python functions and conditional
statements.

You might also like