Today we are going to
- explore a little bit deeper into arange, linspace, lists.
- Learn a bit more about strings.
- Today’s files are located in
Second, we are going to look at strings (pdf=strings)in more detail. You can read more about strings here http://www.tutorialspoint.com/python/python_strings.htm and this website goes into more detail on the formatting we did. https://mkaz.com/2012/10/10/python-string-format/
VIDEO
Make sure to take your Quiz on Courseworks!
HOMEWORK
Homework 3 Due Next Class (Wednesday February 5, 2025)
- Code.org intro course through stage 15 to stay on pace
- Write 50-100 letters of nonsense in a string. But in that nonsense have a secret code that spells your name with every x letter (e.g. every 5th letter).
- print the whole string
- use slicing to print your name
- use slicing to print your name and then make it upper case
- Repeat the same thing with a list but only do your first name. This is different as you are using a list. #2 above uses a string and this uses a list. It is a subtle difference but make sure to do it correct for each. Making a list is more annoying. So you only need to do your first name.
- print the list.
- Use slicing to print your name
- Print your name in reverse using slicing (for this to easily work the last letter of the list needs to be the last letter of your name)
- reverse the list
- print your name backwards using slicing on the reversed list.
- with the list reversed print your name forward with slicing.
- Final 10% today. Practice some more plotting and make the graph at the bottom of the page. Your graph should be your first initial. Not a B. You should be able to put together your line plotting and cosine plotting to make it. The graph below shows cosine. I am okay with an ugly letter but it should be legible. You will need to create two and only two numpy arrays to make your letter if you set all the different coordinates correctly. Think back to your lists and line to think about how to make your letter.
My Answers
My secret coded string!
Boerrianion4an6nn09 i Jkaj.hif ksfMifnasgmi30flbn-lniao238uasdx
My name in the string using slicing!
Brian J. Mailloux
My name in the string all in upper case
BRIAN J. MAILLOUX
The list
[‘B’, ‘o’, ‘e’, ‘r’, ‘r’, ‘i’, ‘a’, ‘n’, ‘i’, ‘o’, ‘n’, ‘4’, ‘a’, ‘n’, ‘6’, ‘n’, ‘n’]
my name using slicing
[‘B’, ‘r’, ‘i’, ‘a’, ‘n’]
my name backwards using slicing
[‘n’, ‘a’, ‘i’, ‘r’, ‘B’]
I reversed the list
[‘n’, ‘n’, ‘6’, ‘n’, ‘a’, ‘4’, ‘n’, ‘o’, ‘i’, ‘n’, ‘a’, ‘i’, ‘r’, ‘r’, ‘e’, ‘o’, ‘B’]
my name backwards using slicing
[‘n’, ‘a’, ‘i’, ‘r’, ‘B’]
my name using slicing
[‘B’, ‘r’, ‘i’, ‘a’, ‘n’]