Skip to main content

Project Based Engineering Instrumentation High Level Coding and Microcontrollers

Section 5.3 Extra Help

If extra help is needed with this assignment there is a youtube video on how to install Thonny as well as a youtube video on how to install Spyder. There is also a pretty comprehensive youtube video on how to plot in matplotlib [50].

Subsection 5.3.1 Built-In Help Function and dir()

Running code will always create syntax errors. Typing your syntax error into Google will yield so many results you might get lost. Sometimes it helps to know how to learn things just from your computer. For example, type in the commands below in the IPython console or the Shell.
import numpy as np
dir(np)
Figure 5.3.1. Output of dir(numpy)
I included a photo of the output from the dir function. Youโ€™ll notice there are a ton of functions in numpy. Every function in Python has a
__doc__
function. Thatโ€™s two underscores followed by โ€œdocโ€ and then another two underscores. If youโ€™re ever curious about what a particular function does you can just run the command below again in the IPython console or Shell. In this example Iโ€™m looking at what arctan2 does.
print(np.arctan2.__doc__)
Figure 5.3.2. Output of print(np.arctan2.__doc__)
Youโ€™ll see that arctan2 takes 2 input arguments โ€œx1โ€ and โ€œx2โ€. I didnโ€™t include the entire output but if you continue to scroll through the output it will even include examples on how to use the function.
Another way to learn certain functions is by visiting the appropriate documentation. The Numpy Docs website for example has all the documentation you need for Numpy [51]. Navigating that website you can find the same documentation for arctan2.
As a last resort you can always Google โ€œhow to compute the inverse tangent 2 function in Pythonโ€. Note though that there is so much content out there on Google that you could easily get lost. Still, thereโ€™s also so much information that the answers are out there for just about anything.
So you have three methods for finding out how to program in python. The dir and __doc__ functions in Python, using the appropriate documentation online and of course Google. Iโ€™m lumping Youtube in with Google which is also another way to learn information although when I want to find information quickly I just use the documentation. Itโ€™s the best in my opinion.