Math and intro to random numbers
Find a partner - or I will do it for you. I mean it!! THIS IS IMPORTANT. If you don't do it, your score will be penalized. If you don't like to work with a partner, then it is even more important for you to do it.
You may need to refer to this week's reading assignment throughout the exercises.
Announcements
You are off to a great start! Keep it up!
Goals
- Learn how to import modules (and figure out how to use them)
- Introduce Random numbers and the random number seed
Use the Python math module (review - time permitting)
0) Get the GitHub repository for class06 and clone it to your area in Rivanna.
Note: Ignore (0) if using Google Drive.
Use this link to accept the assignment and create your repository for class06 on GitHub: https://classroom.github.com/a/e80Kacfe
After you accept the assignment and the repository and it exists in your GitHub, as we did in class02, clone the class06 repository into your working area on Rivanna.
>>> git clone git@github.com:PHYS1655Su24/class06-<userid>.git
Navigate into that directory via usage of the 'cd' command.
1) Play with random numbers
1a) Work through the Random.ipynb JupyterLab Notebook. It is in your repository. Complete the exercises within.
→ Add, commit, and push your Random.ipynb to GitHub and make sure it is there.
(or, if we had to use Google Drive, download it to your computer and upload using the GitHub interface.
1b) Based on what you learned in the Notebook. Write a Python program (a script) called random10.py that prints 10 random x,y (two each time through the loop for a total of 20 random numbers) float values to the screen where each value is between -1 and +1.
→ Design your algorithm and implement the code in random10.py.
→ Add, commit, and push your random10.py to GitHub and make sure it is there.
NOTE: part 1b is useful in HW03, so make sure you get it done!
2)More with the math module. (time remaining - probably there won't be!)
Open Google and type "Python math module examples". Look at a few. You can do this with any module that you want to use to understand simple things that can be done. When we know a little more Python, we can better understand the Python module documentation - for now, looking at examples will do. A major part of learning to program is learning how to read the documentation. We will continue to work on that this semester...
Now, modify the program: Calculate and print the length of the long side of the triangle to the screen. Calculate and print the values of the two remaining angles. You will need to use the trig functions that come with the math module. Your program should add the angles and make sure they equal 90 degrees, and print to the screen that it either did or did not, pass the check.
Remember what else is available to you in the math module? Have a look at the documentation.
→ Comment, add, commit, and push your triangle.py to GitHub and make sure it is there.
Done? Did you document your code? If not, add some documentation to your programs, and re-post them to GitHub: triangle.ipynb, and Random.ipynb.