Question: 11:23 Tutorial%2006%20Loops.pdf COMP1753 Programming Foundations Tutorial 06- Loops This tutorial is aimed at familiarising you with using and creating loops. Do not worry if


11:23 Tutorial%2006%20Loops.pdf COMP1753 Programming Foundations Tutorial 06- Loops This tutorial is aimed at familiarising you with using and creating loops. Do not worry if you can't do all the exercises, especially the difficult ones. Give them a try and if you are stuck, ask your tutor. For each exercise you should make a copy of the example you are working on before you modify it. In that way you will have both your new version and the original version to compare it with. You should make a record all of your work in your COMP1753 logbook. 1. Download the examples and last week's solutions. Check through the solutions and make sure you could do them all. Unzip this week's examples. Q 2. Make a copy of 09LineNumbers and modify it to use a while loop rather than a for loop. [Hint: look at the lecture notes and in particular the slide which compares the two types of loop.] Tutorial Sheet 3. Look at the Quick Check slide about halfway through the lecture. Make a program which tests some of these loops by printing out the value of i each time the loop is executed. You do not have to do all of them but make sure you do at least 3. 4. Make a copy of 13StarSquare_nested Loops and modify it to produce the following output. [Hint: this involves one very small change to the code.] What size square? 4 5. Make a copy of 14StarRectangle_nested Loops and modify it to produce the following output. [Hint: you will need two inner loops, one after the other.] How many rows? 4 How many columns? 5 *****-==== *****===== COMP1753 Programming Foundations = 6. Make a copy of 06Randoms_forLoop and modify it so that it ignores the value 7 (i.e. it does not include the value 7 in the output string even if it is one of the random values. Now modify it so that if the number O happens to be one of the random values it changes the output string to "Bad luck, no random values for you" and jumps out of the loop. U 7. Modify 06bHelloLucky from "L03 Decisions solutions" so that it runs inside a while loop (like the Concessions example from the lecture). The code should prompt the user for their name before the loop starts and at the end of the loop and the while loop should terminate if the user doesn't enter any input at this prompt. D Tutorial Sheet 11:23 Tutorial%2006%20Loops.pdf COMP1753 Programming Foundations 9. Read the w3schools pages mentioned in the lecture: a. https://www.w3schools.com/python/python b. https://www.w3schools.com/python/python ||| 8. [Quite hard] Can you modify 08Concessions_whileLoop so that there is only one line of code which prompts the user for their name? U D Q while loops.asp for loops.asp Tutorial Sheet
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
