Python Day 5
Today we warm up by completing Exercise 25. This is even more practice with functions and variables!
To run the program we call python in the terminal and import ex25 from there.
As I was working through calling the different functions in the terminal I realized that I missed a function - specifically the one that sorted a sentence. I called it and ended up getting a mess of individual letters. After bug hunting I found the issue to be that I called sort_words(sentence) instead of sort_words(words)
After fixing those issues I finished running through the function calls in the terminal and it went great!
Up next is Exercise 26! We are halfway through the book and it is time for a test. We are given broken code that we copy paste into a file. Our job is to fix it and get the program running! As I went through the program I left comments wherever I was fixing code. Below is my finished and fixed program.
And here is the output in the terminal:
Exercise 27 went over different booleans as well as a chart to memorize. The next practical was exercise 28 where you type in different statements then guess if they will be true or false. With my previous experience in programming I already knew a lot - the only thing that tripped me up was NOT OR booleans. Here's the output of the terminal!
Chugging right along to Exercise 29! ex29 introduced if statements. I already know lots about if statements from Javascript so this is more of a refresher than anything.
And then the output:
Exercise 30 introduces Else If statements.
And the output:
Exercise 31 combines everything that we've learned about If/Elif statements with the new concept of Nested statements. Using nested statements we are able to write a very simple Choose Your Own Adventure text game.
Here are a couple different runs I did with this program. My first try was not the best - I ended up having my mind turned into Jello!
My second run went better! I ran into a bear but I survived.
For the study drill it challenged me to write my own text game. I made a very simple one and got about halfway through where I want it to be.
That's it for today folks!












