11:23 Tutorial%2006%20Loops.pdf COMP1753 Programming Foundations Tutorial 06- Loops This tutorial is aimed at familiarising you with...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
Valuing Preferred Stock Best Rate Bank just issued some new preferred stock. The issue will pay a $10 annual dividend in perpetuity, beginning 10 years from now. If the market requires a 7 percent...
-
Refer to the 'Real life scenario describing the cost of Australian wine. Do you think Australian winemakers use job costing, process costing or a combination of these two product costing systems?...
-
Why are the basic financial statements of a governmentmore so than those of a businessinadequate as a basis for assessing the entitys fiscal health?
-
Explain the difference between the Address and Addresses classes.
-
The following table contains information about four projects in which Andrews Corporation has the opportunity to invest. This information is based on estimates that different managers have prepared...
-
1.Discuss what the Bible says about private ownership and trade. 2.How are they different from the understanding of their economic roles? 3.What are the differences between the roles of government in...
-
Kelly Pitney began her consulting business, Kelly Consulting, on April 1, 20Y5. The accounting cycle for Kelly Consulting for April, including financial statements, was illustrated in this chapter....
-
Find the complexity of given nested loops, where n is the input. for (int i=n; i>1; i-i/2) for (int j-i; j
-
Write each system in augmented matrix form. a. \(\left\{\begin{array}{l}4 x+5 y=-16 \\ 3 x+2 y=5\end{array}\\ ight.\) b. \(\left\{\begin{array}{l}x+y+z=4 \\ 3 x+2 y+z=7 \\ x-3 y+2 z=0\end{array}...
-
Write \([\mathrm{A}][\mathrm{X}]=[\mathrm{B}]\), if possible, for the matrices given in Problems 17-18. \([\mathrm{A}]=\left[\begin{array}{rrr}4 & 1 & 0 \\ 3 & -1 & 2 \\ 2 & 3 & 1\end{array}...
-
To manufacture a certain alloy wheel, it is necessary to use \(33 \mathrm{oz}\) of metal A and \(56 \mathrm{oz}\) of metal B. It is easier for the manufacturer to buy and mix two products that come...
-
Clint Eastwood is fifteen years older than fellow actor Goldie Hawn. If the sum of their birth years is 3,875 , in what year was Hawn born?
-
Solve the systems in Problems 15-26 by the substitution method. \(\left\{\begin{array}{l}y=5-3 x \\ 2 x+3 y=1\end{array} \quad ight.\)
-
A consumer lives three periods, called the learning period, the working period, and the retirement period. Her income is 50 during the learning period, 1000 during the working period, and 300 again...
-
Software Solution is family-owned business that has been in operation for more than 15 year. The board of directors is comprised of mainly family members, plus a few professionals such as an...
-
What are the criteria for the number of iterations such that Jacobis method is faster than Gauss elimination for solving a linear problem that is not banded?
-
Perform the first two iterations of GaussSeidel for the system of equations using an initial guess x = 0. 6 1 03 -28 2 3 16 10 -2 2 1 3 9 2 X3 X4 || -9 9 17 13
-
In heat transfer the heat transfer from a slab of thickness 2w initially at a uniform temperature T 0 can sometimes be modeled by a lumped parameter analysis where is the density of the slab, Cp is...
-
The following are summaries of the cash book and bank accounts of J. Duncan who does not keep his books using the double entry system. You are required to: (a) Calculate the value of J. Duncan's...
-
Read the following and answer the questions below. On 31 December 2015 the bank column of C. Tench's cash book showed a debit balance of 1,500. The monthly bank statement written up to 31 December...
-
The bank columns in the cash book for June 2016 and the bank statement for that month for D. Hogan are as follows: You are required to: () Write the cash book up to date to take the above into...
Study smarter with the SolutionInn App