Hej, zrobiłem w pythonie prosty kalkulator i chciałbym aby po zakończeniu działania była możliwość np. poprzez wpisanie "start", uruchomienie programu ponownie. Czy wie ktoś jak coś takiego zrobić ? Próbowałem trochę z funkcjami ale nic z tego nie wyszło :/
import math
def dodawanie(x,y):
print("RESULT:" , x+y)
def odejmowanie(x,y):
print("RESULT:" , x-y)
def dzielenie(x,y):
print("RESULT:" , x/y)
def mnozenie(x,y):
print("RESULT:" , x*y)
def potegowanie(x,y):
print("RESULT:" , x**y)
def pierwiastekkwadrat(x):
print("RESULT:" , math.sqrt(x))
print("-----------------------------------------------------")
print(" | CALCULATOR | 7.leave")
print("-----------------------------------------------------")
print(" | 1.addition 2.substraction 3.division |")
print(" | 4.multiplication 5.exponent 6.square root | ")
print("-----------------------------------------------------")
wybor = input(">>>")
wybor = int(wybor)
#dodawanie
if wybor== 1:
print("Type first number")
x = input(">>>")
x = float(x)
if x>-999999999999999999999999999999999999999999:
print("Type second number | your action:" , x , "+" , "|__|")
y = input(">>>")
y = float(y)
print("-----------------------------------------------------")
print("your action:" , x , "+" , y)
print("-----------------------------------------------------")
print("Type 'calculate' to calculate the action ")
dodawanieoblicz = input(">>>")
dodawanieoblicz = str(dodawanieoblicz)
if dodawanieoblicz=="calculate":
print("-----------------------------------------------------")
dodawanie(x, y)
print("-----------------------------------------------------")
#odejmowanie
if wybor== 2:
print("Type first number")
x = input(">>>")
x = float(x)
if x>-999999999999999999999999999999999999999999:
print("Type second number | your action:" , x , "-" , "|__|")
y = input(">>>")
y = float(y)
print("-----------------------------------------------------")
print("your action:" , x , "-" , y)
print("-----------------------------------------------------")
print("Type 'calculate' to calculate the action ")
odejmowanieoblicz = input(">>>")
odejmowanieoblicz = str(odejmowanieoblicz)
if odejmowanieoblicz=="calculate":
print("-----------------------------------------------------")
odejmowanie(x, y)
print("-----------------------------------------------------")
#dzielenie
if wybor== 3:
print("Type first number")
x = input(">>>")
x = float(x)
if x>-999999999999999999999999999999999999999999:
print("Type second number | your action:" , x , "/" , "|__|")
y = input(">>>")
y = float(y)
print("-----------------------------------------------------")
print("your action:" , x , "/" , y)
print("-----------------------------------------------------")
print("Type 'calculate' to calculate the action")
dzielenieoblicz = input(">>>")
dzielenieoblicz = str(dzielenieoblicz)
if dzielenieoblicz=="calculate":
print("-----------------------------------------------------")
dzielenie(x, y)
print("-----------------------------------------------------")
#mnozenie
if wybor== 4:
print("Type first number")
x = input(">>>")
x = float(x)
if x>-999999999999999999999999999999999999999999:
print("Type second number | your action:" , x , "*" , "|__|")
y = input(">>>")
y = float(y)
print("-----------------------------------------------------")
print("your action:" , x , "*" , y)
print("-----------------------------------------------------")
print("Type 'calculate' to calculate the action")
mnozenieoblicz = input(">>>")
mnozenieoblicz = str(mnozenieoblicz)
if mnozenieoblicz=="calculate":
print("-----------------------------------------------------")
mnozenie(x, y)
print("-----------------------------------------------------")
#potegowanie
if wybor== 5:
print("Type first number")
x = input(">>>")
x = float(x)
if x>-999999999999999999999999999999999999999999:
print("Type second number | your action:" , x , "^" , "|__|")
y = input(">>>")
y = float(y)
print("-----------------------------------------------------")
print("your action:" , x , "^" , y)
print("-----------------------------------------------------")
print("Type 'calculate' to calculate the action")
potegowanieoblicz = input(">>>")
potegowanieoblicz = str(potegowanieoblicz)
if potegowanieoblicz=="calculate":
print("-----------------------------------------------------")
potegowanie(x, y)
print("-----------------------------------------------------")
if wybor== 6:
print("Type number")
x = input(">>>")
x = float(x)
if x>-999999999999999999999999999999999999999999:
print("-----------------------------------------------------")
print("your action: √",x,)
print("-----------------------------------------------------")
print("Type 'calculate' to calculate the action")
pierwiastekkwadratoblicz = input(">>>")
pierwiastekkwadratoblicz = str(pierwiastekkwadratoblicz)
if pierwiastekkwadratoblicz=="calculate":
print("-----------------------------------------------------")
pierwiastekkwadrat(x)
print("-----------------------------------------------------")
if wybor==7:
print("The Program was successfully ended")
exit()
if wybor>7:
print("Undefined command, please restart the program")