If you haven't installed Python yet, I recommend this article because it is easy to understand and short. By the way, the version of my Python is 3.8.0, but there is no problem if it is a Python3 system.
First, copy and paste the following script into a text editor, etc., and save it with the extension .py. Here, the file name is sample.py and the save destination is in the Desktop folder.
sample.py
print("Hello World!!")
In Python3 series, if you write print (), the one in parentheses will be output. If you want to output a character string, enclose it in double quotation marks "".
In Windows 10, you can easily find the command prompt by pressing this magnifying glass at the bottom left of the screen and searching for cm. cm is an acronym for command. If the magnifying glass is not at the bottom left of the screen, right-click on the taskbar to display the search icon.
Did you start the command prompt? When you start it, you should see the following screen. Hidden in blue is my name.
If you can start it, type the command cd desktop
here to move to the folder containing the Python files.
If you can move to the folder where the Python files are, type the command python sample.py
.
If Hello World !! is displayed like this, you are successful!
In fact, Python files can also be run by double-clicking them directly.
However, this method closes the window after the program has been processed to the last line. To see the output, you need to write ʻinput ()` on the last line of your program.
Also, even if you write ʻinput ()`, if there is an error in the program, the window will be forcibly closed at that point, so you will not know the error content (at the command prompt, tell me the error content and location. Will do it).
Therefore, for ease of debugging, run Python files at the command prompt.
Recommended Posts