

Figures 1-1, 1-2, and 1-3 show what it looks like in Anaconda Spyder, Notepad++ (Windows), and TextWrangler (macOS), respectively.įigure 1-4. However, in this case you want to save it as a.

In the past, you’ve probably saved a text file as a. In the Save As box or File Name box, type “first_script.py”. In the format box, select All Files so that the dialog box doesn’t select a file type.

In the location box, navigate to your Desktop so the file will be saved on your Desktop. This line will print the text between the double quotes to the Command Prompt (Windows) or a Terminal window (macOS). The second line is a simple print statement. Because Windows machines ignore this line and Unix-based systems such as macOS use it, including the line makes the script transferable among the different types of computers. However, Unix computers use the line to find the version of Python to use to execute the code in the file. The # precedes a single-line comment, so the line of code isn’t read or executed on a Windows computer. Notice that the first character is the pound or hash character ( #). The first line is a special line called the shebang, which you should always include as the very first line in your Python scripts. Write the following two lines of code in the text file: #!/usr/bin/env python3 print ( "Output #1: I'm excited to learn Python." ) Open the Spyder IDE or a text editor (e.g., Notepad, Notepad++, or Sublime Text on Windows TextMate, TextWrangler, or Sublime Text on macOS).
