r/AskComputerScience • u/scholastic_noob • Feb 14 '21
How does a python program work?
Hi,
So sorry if this is a stupid question but I am trying to learn computer science and someone suggested I learn to code and they suggested the python language. So I do this exercise that is very simple and all I type in the code is:
print(“Hello World!”)
I then learned to maneuver to the program directory in the terminal and to run the program using the command:
python3 Hello.py
However, what I am confused about is how exactly the computer knows from python to display the text. What is the python3 command actually do here? Because if it isn’t used it does not work. Now my guess is that for other languages I need to use a command similar to python3 for each respective language. I am just not sure what the command is doing and I am hoping someone could explain it to me. Sorry if this is a dumb question, I am only thirteen and I am trying to get smarter.
29
u/[deleted] Feb 14 '21
python3 Hello.py runs the python interpreter on Hello.py. so it runs a program that goes through the text in Hello.py and inteprets it according to pythons syntax/rules. if you type python3 on its own it opens the python interpreter, and you can type python code and will do the stuff accordingly.
You are correct that every language has its own command, however not all work the same way pythons does. your computer comes with its own set of instruction and you can give it sequences of these instructions and it will go through them one by one and execute them. .this functionality is part of the computers actual circuit board see Assembly . some other languages commands run a program called a compiler which goes through the text and produces a program written in your computers basic list of instructions.