Skip to content

rida09Heythere/calculator-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Simple calculator

def calculator(): print("Calculator") print("Operations:+,-,*,/") print("Type 'exit' anytime to quit\n")

first=input("Enter the first number (or 'exit'):")
if first.lower()=="exit":
    print("Goodbye!")
    return
result=float(first)

while True:
    op=input("enter operation(+,-,*,/ or 'exit'):")
    if op.lower()=="exit":
        print("Final Result:", ressult)
        print("Goodbye!")
        break
    next_num=input("Enter next number (or 'exit'):")
    if next_num.lower()=="exit":
        print("Final Result:")
        break
    next_num=float(next_num)
    if op=="+":
        result+=next_num
    elif op=="-":
        result-= next_num
    elif op=="*":
        result*= next_num
    elif op=="/":
        if next_num !=0:
            result/= next_num
        else:
            print("Error:Division by zero not allowed")
            continue
    else:
        print("Invalid operation!")
        continue
    print("Current Result:",result)

calculator()

About

a simple code using basics of python without OOPS here u can calculate endless numbers whether +,-,*,/ this is my first ever code done by me after completion of my basics of python hoping to build more projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors