Part A: [Link]
assignment_url=HW2_A&embed=True
First I created a loop that includes numbers from 1 to 100. Then I created an if statement stating
that if the number Y is divisible by 3 then it should print FIZZBUZZ. Then I created another if
statement that checked if the number Y was not divisible by 3 but was divisible by 5 then it
would print BUZZ. My last if statement checked whether the number Y was divisible by both 3
and 5 then it would print FIZZBUZZ. If none of the previous conditions are true the program
prints the number Y itself.
Part B: [Link]
First I asked the user how many sides their poligon has. Then I validated the input by checking if
the number was between 4 and 16 and was even (divisible by 2). Once a valid number is entered,
it calculates the angle the turtle needs to turn at each corner. I used an angle of 360 after trying
different numbers when this one provided me with the full drawing of the shapes. Then I used a
loop that would result in the turtle moving forward and turning to repeat the process to draw each
side of the shape.
Part C: [Link]
First I initialized two variables, fb0 and , fb1 to represent the first two numbers of the Fibonacci
sequence. Then I printed these initial values to display the starting point of the sequence. Next I
set up a loop to calculate the Fibonacci numbers starting from the third number, fb2, and
continuing until I reached the 20th Fibonacci number. In each iteration of the loop, I calculated
the next Fibonacci number by adding the previous two numbers. The loop continues until the
20th Fibonacci number is reached and printed, using that each number is the sum of the two
before it.