To save a program in Raspberry Pi, you typically use the Thonny Python IDE. Here's how:
-
Open Thonny: Access Thonny by navigating to the Raspberry Pi icon in the top-left corner of the screen, then selecting "Programming," and finally "Thonny Python IDE."
-
Write Your Program: Type your Python code into the upper pane of the Thonny window.
-
Save the File: Click on "File" in the menu bar, and then select "Save As...". This will open a file dialog box.
-
Choose a Location: Navigate to the directory where you want to save your program. A common location is the "Pi" folder, which is your home directory. You can also create new folders to organize your projects.
-
Name Your File: Enter a descriptive name for your program in the "File name" field. Be sure to include the ".py" extension at the end of the name to indicate that it is a Python file (e.g., "my_program.py").
-
Click "Save": Click the "Save" button to save your program to the chosen location.
Once your program is saved, you can run it by clicking on "Run" in the menu bar and selecting "Run current script." The output of your program will appear in the lower pane of the Thonny window, which is the interpreter.