Answer:
B
Explanation:
the person at the very top said so :)
Answer:
The solution code is written in C++
- bool STATUS = true;
- bool alternator ()
- {
- if(STATUS){
- STATUS = false;
- return true;
- }else{
- STATUS = true;
- return false;
- }
- }
Explanation:
We need a global variable to track the status of true or false (Line 1).
Next, create the function alternator (Line 2) and then check if current status is true, set the status to false but return the previous status boolean value (Line 5-6). At the first time of function invocation, it will return true.
The else block will set the STATUS to true and return the false (Line 7-9).
Answer:
import turtle
my_turtle = turtle.Turtle()
my_turtle.speed(0)
my_turtle.pendown()
colours = ["yellow", "blue", "red", "orange", "cyan", "pink", "green", "brown"]
for sides in range(8):
my_turtle.pencolor(colours[sides])
my_turtle.forward(100)
my_turtle.left(45)
Explanation:
- The pencolor statement must be inserted before the forward() call otherwise you have no control over the color of the first line.
- You don't need the count variable, since the 'sides' variable is a perfect counter to index the colours array.