Professional Documents
Culture Documents
ICT - 107
LOGPROG
1. What are the different control structures? (3) Briefly explain each, and give an
example on how each control structure is used.
• A Boolean variables are variables that can have only two possible
values: true, and false, while a Boolean expression is a logical statement
(that uses 2 Boolean variable) that is either TRUE or FALSE.
4. What are the 2 different loops we’ve discussed so far? Give an example on when
they’re used, and the differences of the two.
• while loop – a condition-controlled loop. In order for a loop to stop
executing, something has to happen inside the loop to make the
condition is false (example: while z = < 10: z = z + 5 print (z))
• for loop – a count-controlled loop. by using range or list, it continuously
repeats the argument until the number of range or list is done.
accumulator = 0
print (accumulator)
7. Use the range function to create an iterable of even numbers between 1 and
1337.
for num in range (2, 1337, 2):
print (num)