r/AskComputerScience • • 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.

35 Upvotes

16 comments sorted by

View all comments

7

u/slashcom Feb 14 '21

It's actually a super super deep question. Others have done a good job explaining, but just want you to know it's a very good question.

3

u/scholastic_noob Feb 14 '21

Oh that is such a relief. I am trying to be smarter because I am tired of being the “dumb kid” in my class. So I am glad this was a good question. I was worried people were going to think I was dumb lol.

2

u/[deleted] Feb 14 '21

Trust me this question can go as deep as you want. From the simple answers they gave you above on how python is interpreting your code, to the whole branch of computer science related to compilers, programming languages, language processing and more, and that’s an area where some of the smartest minds work, it’s complex.