Search code examples
pythonexeapplication-shutdown

Why my python program that I converted into exe file always shutdown when result should have discovered


I created a small program that calculates the volume and content of a couple of bodies like cube and others. I have converted it into exe but when I type like some sizes of sides after it the program will shutdown, any help with that?

from telesa import *

ahoj = ["1)krychle","2)kvádr","3)válec","4)kužel","5)koule","6)hranol","7)jehlan"]

print(*ahoj,sep='\n')
cisla = int(input("Napiš číslo 1-7 pro výběr "))

        
# Výpočet objemu a povrchu krychle
if cisla == int(1) and ahoj[0]:

        print("Výpočet objemu a povrchu krychle")
        print("")
        a = float(input("Napiš kolik má strana a cm "))
        objem = Objem_krychle(a)
    
        povrch = Povrch_krychle(a)

        print(f"Krychle s délkou hrany {a} cm má objem V={objem} cm^3 a povrch S={povrch} cm^2.")


# Výpočet objemu a povrchu kvádru     
if cisla == int(2) and ahoj[1]:
    print("Výpočet objemu a povrchu kvádru")
    print("")
    a = float(input("Napiš kolik má strana a cm " ))
    b = float(input("Napiš kolik má strana b cm " ))
    c = float(input("Napiš kolik má strana c cm " ))
    objem = Objem_kvádr(a, b, c)
    povrch = Povrch_kvádr(a, b, c)
    print(f"Kvádr s rozměry a={a} b={b} a c={c} cm má objem V={objem} cm^3 a povrch S={povrch} cm^2.")


# Výpočet objemu a povrchu válce 
if cisla == int(3) and ahoj[2]:
    print("Výpočet objemu a povrchu válce")
    print("")
    r = float(input("Napiš kolik má válec poloměr v  cm " ))
    v = float(input("Napiš kolik má výška v cm " ))
    objem = Objem_válec(r, v)
    povrch = Povrch_valec(r, v)
    print(f"Válec s poloměrem r={r} cm a výškou v={v} cm má objem V={objem} cm^3 a povrch S={povrch} cm^2.")

there are a few other bodies similar to this,


Solution

  • The program does exactly what you told it to through the code. It prints a bunch of text and then ends (shuts down). If you want the program to keep doing something after it is done printing, you need to tell it. The easiest way to do it is to put an input() call at the end of your script. When you do that, after printing the program will wait and only terminate after you hit enter.