---
# System prepended metadata

title: D. Tutoring - Month 1

---

# D. Tutoring - Month 1 

## Project to complete for the Month 1

### Introduction

In this project, you will be building a basic calculator using Python. The calculator will be able to perform basic arithmetic operations such as addition, subtraction, multiplication, and division. By working on this project, you will learn how to:

* Use Python's built-in arithmetic operators
* Use input() and print() to interact with the user
* Use if-elif-else statements to control the flow of the program

### Problem Set

1. Create a Python function called "calculator" that keeps running until the user chooses to exit.

2. Use input() to ask the user for the operation they want to perform (e.g. addition, subtraction, etc.). Store the user's input in a variable called "operator".

3. Use another input() call to ask the user for the two numbers they want to perform the operation on. Store these values in variables called "num1" and "num2".

4. Use an if-elif-else block to determine which operation the user wants to perform based on the value of "operator". Inside the block, use Python's built-in arithmetic operators to perform the corresponding calculation and store the result in a variable called "result".

5. Use the print() function to display the "result" to the user.

6. Add support for more advanced mathematical operations such as exponentiation, square root, and logarithms using a library such as math, numpy, or scipy.

7. Implement error handling for invalid input such as non-numeric input for numbers, or invalid operation selections. Allow the user to retry input in case of invalid input

8. Create a GUI for the calculator using a library such as Tkinter or PyQt to make the calculator more user-friendly.

9. Add the ability to perform calculations with variables. Allow the user to store and recall the result of previous calculations

10. Create and utilize a class that represent the calculator. Add a subclass that represent each operation and add the corresponding method to it

11. Implement the ability to chain multiple operations together, and evaluate the final result.

12. Allow the user to choose the number of decimal places to display in the result.

13. Your code must follow PEP 20 – The Zen of Python

### Python pre-requisite knowledge

Before attempting this project, it is important to have a basic understanding of the following concepts in Python:

* Variables: You should understand how to create and assign values to variables, as well as the different types of data that can be stored in variables (e.g. integers, floats, strings).

* Input and Output: You should know how to use the input() and print() functions to interact with the user and display information on the screen.

* Control Flow: You should have a basic understanding of control flow statements such as if-elif-else statements, and how they are used to control the flow of the program based on certain conditions.

* Loops: You should know how to use while loops in Python, and how they can be used to execute a block of code repeatedly until a certain condition is met.

* Basic arithmetic operations: You should know how to use the basic arithmetic operators (i.e +, - , *, /) in python, and understand their basic meaning

* Basic understanding of function: You should know how to define and call a function, and understand the purpose of a function in terms of breaking code down to smaller and reusable pieces.

* Familiarity with advanced mathematical operations, and how to perform them in Python using libraries such as numpy, scipy.

* Experience with creating graphical user interface using library such as Tkinter, PyQt

* Understanding of error handling in Python, and how to use try-except blocks to handle exceptions.

* Experience with classes, subclass, encapsulation, inheritance in OOP.

* Experience with operator overloading and use of magic methods

* Knowledge on how to chain operations using the chaining technique

* Knowledge of string formatting and the usage of "%.xf" where x is a number to set the number of decimal places.

* Knowledge of PEP 20 – The Zen of Python