You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
Version 1
Next »
Work/discuss with a partner!
Remember to log into rivanna to begin!
Important: Refer to the getting_started page for instructions on connecting to your rivanna account.
Announcements
Goals
- Learn about lists, tuples, conditionals and loops. More challenging programming exercise with prime numbers.
0) Get the GitHub repository for class05 and clone it to your area in Rivanna.
Use this link to accept the assignment and create your repository for class05 on GitHub: https://classroom.github.com/a/r0IrNdhL
After you accept the assignment and the repository and it exists in your GitHub clone the class05 repository into your working area on Rivanna.
>>> git clone git@github.com:PHYS1655S24/class05-<userid>.git
Navigate into that directory via usage of the 'cd' command.
1) Work through Jupyter Notebook.
Work through the FlowControl.ipynb JupyterLab Notebook. It is in your repository. Complete the exercises within.
→ Add, commit, and push your FlowControl.ipynb to GitHub and make sure it is updated there.
2) Fun with strings. (if time remains- Prof. Group -make sure input.py is in classo5 repo and that you talk some about strings in the slides)
Copy over input.py to a file named string_fun.py. Make sure to update the header information at the top of the file.
In this program request an input string from the user (hint: use the input function). Your program should:
- Check how many words are in the string (use strip and split - check documentation for how to do it), and print info to the screen.
- Count how many characters are in the string, and print info to the screen.
- print the first 2 characters to the screen.
- print the last 2 characters to the screen.
- Request an integer from the user (use input). Check to make sure it is an integer. Hint: use try/except (Google it if you need to) to make sure. Input validation!
- Use a for loop (example in reading) to print the string to the screen the number of times of the integer that they input can count them. It should look like this:
1 : this is my string
2 : this is my string
3 : this is my string
4 : this is my string
5 : this is my string
Include documentation/comments to string_fun.py and add, commit, and push it to your repository on GitHub . .