Python exercise c2 q4
Sam wants to write a code that will produce the following:
000
001
010
011
100
101
110
111
He doesn’t know where to start so he starts with the basic:
00
01
10
11
However, he also has trouble finishing this code. He only has a basic idea. Help him to complete the basic version first:
for i in range (0, 2):
for j in range (0, ): (1 mark)
print( i , ) (1 mark)
Now that you know the basic, complete the code that will print the chart 000, 001….all the way to 111 (Hint: look at the code you just complete. This time you probability need 3 for loops, one within another)
for i in range (0, 2):
for j in range ( , ): (2 mark)
for k in range ( , ): (2 marks)
print( , , k ) (1 mark)