I need help with my code (in a .py file)

app = input("app: ")
app = app.lower()
if app != "teorema de pitágoras":
	print("App desconhecida")
	input("Toca no enter para saír ")
elif app == "teorema de pitágoras":
	tr = input("O triângulo é reto?: ")
	if tr == "sim":
		tr = true
		c1 = int(input("Qual é a medida do cateto 1?: "))
		c2 = int(input("Qual é a medida do cateto 2?: "))
		h = (c1**2+c2**2)**0.5
		print("O comprimento da hipotemusa é",h)
		input("Toca no enter para saír ")

well, i am portuguese so the questions are in portuguese, but when i say “sim” the file simply closes

1 thing that would also help me was know how to end a if
i alr tried using return but, i dont know how to use it, so it doesnt work

What do the expect “ending an if” to do?
A “return” is used to provide the result of a function and not directly part of “if”.

I see one potential problem

tr = true

Did you mean tr = True? Unless you have defined the variable true that is a syntax error.

It will help if you translate the questions into English so that I could get an idea of what the code is trying to do.

When I run the code

app: sim
App desconhecida
Toca no enter para saír 

It will close whatever is entered at the second prompt.

Changing true to True (or just deleting that line entirely, as tr is never used thereafter) makes it work for me:

py porto_pythag.py
app: teorema de pitágoras
O triângulo é reto?: sim
Qual é a medida do cateto 1?: 3
Qual é a medida do cateto 2?: 4
O comprimento da hipotemusa é 5.0
Toca no enter para saír

but the user interface could be greatly improved.

Firstly you require as a hard condition, the user to type exactly “teorema de pitágoras” for your program to do enter the main block. The user’s already chosen to run your program, and the program doesn’t do anything more dangerous than high school Geometry. So why’re you making them type something long in again, and require a precise match, to confirm what they already told their computer they want to do? Also I’m all for internationalisation, but on my keyboard set to gb-en, I’d have to Google the extended ascii code or how to type á on it (I just copy and pasted the string from your source code - do you intend to force international users with different keyboard setups to do that?)

If you must require an exact string to be entered, print it out as part of the prompt, so the user can select it and copy and paste it from the shell.

In summary, delete the first 6 lines. They don’t add value, and if anything they make the program worse.

Secondly, even when the program runs and is far less annoying, it’s still useless in anything other than the special cases it supports. Why is the user restricted to apply Pythagoras theorem for integer sided triangles only? Change int to float.

Thirdly, get rid of all the input statements entirely, and require the user to supply the adjacent and opposite as arguments to the same command line they launch your script from in the first place:

import sys

c1, c2 = float(sys.argv[1]), float(sys.argv[2])
h = (c1**2+c2**2)**0.5
print("O comprimento da hipotemusa é",h)
py porto_pythag.py 4.5 7.6
O comprimento da hipotemusa é 8.832326986700616

ok, i have already corrected that (sorry if i write any errors, im portuguese), but to make it for many languages i need help with how to close the if, like, when i have the elif and then if, i want to end that if to make another elif, to make another app and another language
if u dont understand what i mean, i mean this

if 1 == 1:
 if 2 == 2:
 print("2+1=3")
 return
elif 3 != 3:
 ...

De-indentation. Just write the code after the if block you want to close, at the same indentation level as (or a shallower one than) the starting if (with the same number of spaces before it, as the if or a previous statement).

sorry but bc im portuguese i didnt understand it
can u explain a bit more?
or give a example?

It would be better to read an introduction to Python written by someone primarily in Portugese, or ask some Portugese Python users for help.

i understand english very well, there are just some words i dont understand, i alr searched a lot but i cant understand what it does and how it works

can u give like… a example?
im good at learning from examples

well, i made a very big change…

lingua = input("what is your language?: ")
lingua = lingua.lower()
if lingua == "português":
	app = input("app: ")
	app = app.lower()
	if app == "teorema de pitágoras":
		tr = input("O triângulo é reto?: ")
                tr = tr.lower()
		if tr == "sim":
			c1 = int(input("Qual é a medida do cateto 1?: "))
			c2 = int(input("Qual é a medida do cateto 2?: "))
			h = (c1**2+c2**2)**0.5
			print("O comprimento da hipotenusa é",h)
			input("Toca no enter para saír ")
		elif tr == "não":
			print("Então não posso ajudar :P")
			input("Toca no enter para saír ")
		elif tr == "cateto":
			c1 = int(input("Qual é a medida do cateto conhecido?: "))
			h = int(input("Qual é a medida da hipotenusa?: ")
			c2 = (h**2+c1**2)**0.5
			print("O comprimento do cateto desconhecido é de",c2)
			input("Toca no enter para saír ")
		else:
			print("app desconhecida")
			input("Toca no enter para saír ")

there is just a problem now…
now it doesnt even ask anything and just closes immediately

ok, i alr made 2 changes and it still won’t work, whats the problem with it?

i alr tried it manually, and it gave file "<stdin>", line 2 at app = input("app: ")

LIke this? Set a = 1 and two lines print.
set a = 2 and only the second line prints.
The if ended when the indentation (amount of spaces) of the lines became the same
as the if

a = 1
if a == 1:
    print('In the 1 branch of the if')

print('after the if ends')

so it works as a file but it doesnt work manually?

but what about it not oppening now?

Please quote the comment you are replying to.
Without that context I do not know what you are questioning.

im talking about this

it doesnt even ask anything