You usually don’t have line numbers that are super important when something goes wrong, and Python tells you where to look. Using a plain text editor for programming is not ideal. For Example if your file is under C:\Users\yourname\Docments or /home/yourname/Documents on macOS or Linux enter: To navigate to a directory in the command line, use the cd command followed by the path you want to navigate to. Now open the command line again and navigate to the directory in which you have stored the file. Then save it on your computer in your user directory. py, which will identify this file as a Python file. To make things easier, give the file a name without spaces and make sure to give it the file extension. To run this program, you have to save it first. The indentation tells Python that print("Hello World!") is part of your main program. Make sure you use Tab to indent the second line. I will skip the long answer for why you should always use if _name_ = "_main_" when writing a Python program for now and will come back to it in another article. The first line tells Python that the code that is indented under it is part of the main program you would like to run. If _name_ = "_main_" : print ( "Hello World!" )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |