Skip to content

Samik14/Calculator-Using-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculator-Using-Python

Designed a calculator as a mini-project using Python

Problem Statement: Write a program to create a calculator which can perform arithmetic operations like addition, subtraction, multiplication, division etc, depending upon input from the user. Create lists, functions, conditions, and loops to execute the program.

We were divided into a group of 3 students and were told to design a project using Python. We used object-oriented programming. We defined a function for each arthic operation and called it in the final while loop. Used try & except statements, to make sure the calculator is error-free.

We used to try & except in all functions; In addition, subtraction, & multiplication to remove ValueError and make sure that the user only enters integer or float values. In division we used the lambda operator along with try & except, to remove ZeroDivisionError to make sure the user does not enter the denominator as 0. For the square root operation, we used basically the if else statement to avoid the square root of negative numbers. Similarly in the power function, we used nested if-else statements to avoid negative numbers being raised to values within -1< raise_to <1.

In the final while loop statement, we used nested if-else statements to ask the user about the arithmetic operator they want to use. If the user enters any operator outside the given options, the program will give an error and remind the user to select an operator from the given choices only.

I have also provided a basic code for Calculator using C with the help of switch cases. However, focusing on the Python project and trying our best to make the project more and more efficient and error-free. I wish to continue and keep working on the project and build a GUI-based calculator around the same. I am also open to any suggestions, so please do!

About

Desgined a calculator as a mini-project using python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors