The Fish and Chips Puzzle

To complete this puzzle, we first need to investigate the following lines of code:

a = "chips"
b = "fish"



print(a + " and " + b)

What would be the output of this code if you executed it?

Your challenge:


Complete lines 3,4 and 5, so that line 6 outputs “fish and chips”. You must comply with the following rules:

  • You are only allowed to use 4 keys on your keyboard: a, b, c and =. You can use these keys as many times as necessary.
  • You are not allowed to change lines 1,2 or 6.

Trace Table

A trace table can be used to follow the steps of this algorithm one line of code at a time. This will help evaluate the impact of each steps on the different variables used in the code and on the predicted output of the program.

Complete the trace table below using your amended code to see if it produces the required output!

 Line NumberabcOUTPUT
1“Chips”
2“Fish”
3
4
5
6

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 2.7 / 5. Vote count: 41

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!