Chapter 5 Introduction to loops – while loop

In this chapter we go over the basics of while loops and why they simplify a task for us. We learn the importance of while loops in making a program efficient for us. Using while loops we design a simple number game where the user gets to enter random numbers and guess what the answer is, using a nested if statement in a while loop we ensured the loop only works 5 times and then it breaks if there is a correct answer within the 5 chances the user is given. You can try and edit the code in order to increase the number of trials the user has or even start a count to allow the user to see how many tries they have taken in order to guess the number.