4. Concepts about variables and assignment

Activity: CodeLens 4.1 (cl_l05_4a_en)

4.1. Other alternatives

  • You may wonder why we create two variables, a and b, to add two numbers?

  • We could have achieved the same result in several ways.

Activity: CodeLens 4.1.1 (cl_l05_4b_en)

  • What is the difference between the first way and the last two?

  • The first case includes the logic we used to obtain the result

  • This way, we explicitly state the algorithm we used mentally to solve this problem

  • In the last two cases, we simply command the computer to print something specific, without making clear the logic to arrive at that result.

You have attempted of activities on this page