Difference between revisions of "SymPy/Initialization and Documentation"

From PrattWiki
Jump to navigation Jump to search
(Created page with "==Documenting Your Work== Use a docstring set off with triple quotes at the start of your code to give your name, NetID, and any other useful information about the code in gen...")
 
Line 1: Line 1:
 
==Documenting Your Work==
 
==Documenting Your Work==
Use a docstring set off with triple quotes at the start of your code to give your name, NetID, and any other useful information about the code in general.  You can use #, #%%, or docstring comments throughout your code to make it easier to follow.
+
Use a docstring set off with triple quotes at the start of your code to give your name, NetID, and any other useful information about the code in general.  You can use #, #%%, or docstring comments throughout your code to make it easier to follow.  If you are using a notebook, you can also add a text section with the information.
  
 
==Clearing the Variables==
 
==Clearing the Variables==
 
Remember that when Python runs a script, it "remembers" everything that it has done in the
 
Remember that when Python runs a script, it "remembers" everything that it has done in the
session.  For that
+
session.  For that reason, it is good programming practice to clear the variables in Python  
reason, it is good programming practice to clear the variables in Python  
+
on occasion to make sure your script is actually doing everything it needs to work.  The trash can icon above the variable explorer will clear the session.  If you are running a notebook, you will occasionally want to restart the kernel.
on occasion to make sure your script is actually doing everything it needs to work.  The trash can icon above the variable explorer will clear the session.
 
  
 
==Saving Your Work==
 
==Saving Your Work==
If you hit "play" or F5 to save and run your work, your work will be saved to whatever file name you give it.  Note that if you are just running parts of your code by selecting code or a cell and clicking the run current line or run current cell button, that will '''''not''''' save the code!
+
For a script, if you hit "play" or F5 to save and run your work, your work will be saved to whatever file name you give it.  Note that if you are just running parts of your code by selecting code or a cell and clicking the run current line or run current cell button, that will '''''not''''' save the code!
 +
 
 +
If you are working with Jupyter Notebook, you will need to save your files.  If you are working with Google Colab, your files will be automatically saved when you make changes - just be sure to give the system enough time to synchronize before closing the window!
  
 
== Questions ==
 
== Questions ==

Revision as of 17:43, 21 January 2023

Documenting Your Work

Use a docstring set off with triple quotes at the start of your code to give your name, NetID, and any other useful information about the code in general. You can use #, #%%, or docstring comments throughout your code to make it easier to follow. If you are using a notebook, you can also add a text section with the information.

Clearing the Variables

Remember that when Python runs a script, it "remembers" everything that it has done in the session. For that reason, it is good programming practice to clear the variables in Python on occasion to make sure your script is actually doing everything it needs to work. The trash can icon above the variable explorer will clear the session. If you are running a notebook, you will occasionally want to restart the kernel.

Saving Your Work

For a script, if you hit "play" or F5 to save and run your work, your work will be saved to whatever file name you give it. Note that if you are just running parts of your code by selecting code or a cell and clicking the run current line or run current cell button, that will not save the code!

If you are working with Jupyter Notebook, you will need to save your files. If you are working with Google Colab, your files will be automatically saved when you make changes - just be sure to give the system enough time to synchronize before closing the window!

Questions

Post your questions by editing the discussion page of this article. Edit the page, then scroll to the bottom and add a question by putting in the characters *{{Q}}, followed by your question and finally your signature (with four tildes, i.e. ~~~~). Using the {{Q}} will automatically put the page in the category of pages with questions - other editors hoping to help out can then go to that category page to see where the questions are. See the page for Template:Q for details and examples.

External Links

References