In godot you have something like this
Do Something Here
In the project settings, there is an input map. You can set the button to press there and give it a name which you put in the "button" section. So if you go into the project settings, input map and create an input called First_Input and map it to the 2 key then write this code
num1 = 2
print("Enter a number: ", num1)
you will be able to change the variable with a button press.
Godot is similar to python but there are quite a few differences too. If you want to learn python I suggest downloading a standard IDE like geany for example. Hope this helps.