Notes - Sunday 01/17/21
Today I'm working on some practice problems. I'm going to take some notes on what I learned while I go through these problems. Unfortunately the solutions include things we've never gone over in the lectures. Reference this link for the questions and this link for the answers.
- Remember to read over the notes carefully and don't rush to solve a problem for no reason.
If you're using string.split() function, remember that the resulting list will have index positions based on the entire string. Then you can breakdown the string further. For example:
my_list_of_words = some_words.split() = ['Hello World'](this isn't perfect syntax, just go with it) yields
This means that
Then you can break this down further to get just individual letters. For example
.join()method: So you can use this method to combine or join strings. The basic syntax is:
So let's look at a practice problem to explain it:
MASTER YODA: Given a sentence, return a sentence with the words reversed master_yoda('I am home') --> 'home am I' master_yoda('We are ready') --> 'ready are We'
- You can find the absolute value of a number by using abs. The syntax would be
- Assignment operators exist. Here's a list of them. Things like += and = can help. I didn't know they existed.
- Remember that you can get the sum of numbers using
- When you have a loop, order the loop matters. It will literally execute the logic line by line so if you're not setting up the loop in the order you want it to check in, it won't output what you want.