For week 3 I spent time working on control structures including conditional statements and loops. Control structures are important because they allow you to tell what code needs to be put into place. There are two loops which are for loops and while loops. For loops are used by working through a sequence executing a block of code for each item in the sequence (Data Toolkit: Python+ Hands-On Math). While loops are used when a given condition remains true throughout the block of code. Conditional statements include if statements and if-else statements. If statements occur when only one condition is met, while if-else statements occur when one condition is met, and the other condition is not met. I spent time working on these control structures on google collab and while some of it was plug and chug, I realized that just having one wrong indentation can affect you.
The first exercise I completed was printing numbers 1-10 using a for loop. This exercise was pretty simple, but the next one was where I had my first bump. When I tried to create a while loop, I came across an error and my error was that my indentation was wrong. Indentation is key when using python. If it is not used correctly this is when you run into errors. After indenting for the while loop, my processing was correct, and the numbers were printed out. The next exercise was trying conditional statements. I successfully completed the first if statement and also tried it out using different numbers than the one that was given. I also completed an if-else statement and had no problems with indentation on this as well. The next exercise was setting up code to guess a word. This tripped me a little bit, but after pasting the code and fixing the indentations, I was able to set it up.
I learned quite a bit about control structures after going through the exercises in the book on google collab. The biggest thing I learned was how important indentation was and if you didn't have it correctly put in then you were going to have errors occur when put into place. Overall, I feel a little more comfortable with python and I am ready to see what else I am able to do complete and achieve with it.