Concept explainers
I've been given this problem and I need to use a loop to create these patterns. I remember using a while loop and im not very familiar with a for loop. the
i'm more familiar with python and even with that language i struggled to do this.
how do i use a loop to create these patterns?
was the while loop the wrong idea and maybe i should've for looped it?
here are the instructions i was given, i cant seem to create the pattern
Printing a single character at a time create loops to Print the following patterns:
*
**
***
****
*
***
*****
***
*
Pattern 3
1010101
10101
101
1
Use of for loop: We use for loop when we know how many times the loop will going to execute.
Use of while loop: We use while loop when don't know the number of the times loop will going to execute.
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images
- For this question you must design and implement a postcondition loop in Python that will display the following numbers (one on each line) to the terminal: 29, 41, 53, 65, 77, 89, 101, 113, 125, 137, 149, 161, 173, 185, 197, 209, 221, 233, 245, and 257. Although a counter-controlled loop is ideal for this task, you are not permitted to use a FOR loop in your program - you must use a postcondition loop that has been implemented using WHILE instead.Furthermore, your postcondition loop must be implemented using a Boolean flag variable.arrow_forward. In debugging a program, We are searching for availability of errors We want to see whether a program executes with A errors We want to prove that the program is working without erors We are correcting errorsarrow_forwardSorry I asked this question earlier and forgot to include the programming language. I needed it to be written in Python making use of the "while loop" A junior magician has picked a secret number. He has hidden it in a variable named secret_number. He wants everyone who run his program to play the Guess the secret number game, and guess what number he has picked for them. Those who don't guess the number will be stuck in an endless loop forever! Unfortunately, he does not know how to complete the code.arrow_forward
- What are three different approaches that you may use if you've completed the debugging procedure but are still unable to solve the problem?arrow_forwardWrite a program in python for the the following problem. Follow program style requirementsarrow_forwardPython 1. Give an example from your real life that would work well with a Python if statement. 2. Provide an example each of the use of a while loop, a do while loop and a for loop in everyday lifearrow_forward
- It is required from you to write a program in c language for switch light with two buttons that are connected to two lights. The first situation you can chose either to switch ON one of these lights separately and printing out a message saying that, the light is switch ON. The second situation you can switch ON the two lights at the same time and the output message will say the 1st and the 2nd light are ON.arrow_forwardCreate your own examples of java program that use do while loop Requirements: Print Screen of source codes and output Explanationarrow_forwardNeed help programming using Python. The goal is to program a triangle consisting of values (see image) inside a triangle. This would really benefit me in learning Python. Thank you experts!arrow_forward
- What's the difference between Loop Structure and Selection?arrow_forwardJava Code 4. Gathering Positivity by CodeChum Admin I always want to look at the positive side of things, so I decide to seriously look at positive numbers, too! Will you code along with me? Instructions: Using the do…while() loop, continuously scan for integers, but add up only all the positive integers and store the total in one variable. The loop shall only be terminated when the inputted integer is zero. Afterwards, print out the total of all inputted positive integers. Instructions Using the do…while() loop, continuously scan for random integers, but add up only all the positive integers and store the total in one variable. The loop shall only be terminated when the inputted integer is zero. Afterwards, print out the total of all inputted positive integers. Input Multiple lines containing an integer on each. 2 3 4 -1 -5 1 0 Output A line containing an integer. 10arrow_forward-1.pdf Program Input/Output The table below shows sample test cases with input prompts and corresponding output in Turtle canvas that can be used to debug/test your program. It is recommended to test your program thoroughly and not depend only on the provided test cases. Input Prompts Output (Turtle canvas) Enter number of cells in board: 2 Enter the width of each cell: 30 Enter the color (black or red or green or blue): black Enter number of cells in board: 5 Enter the width of each cell: 15 Enter the color (black or red or green or blue): blue Enter number of cells in board: 8 Enter the width of each cell: 25 Enter the color (black or red or green or blue): red Enter number of cells in board: 1 Enter the width of each cell: 5 Enter the color (black or red or green or blue): yettOw Marning: Invalid number for the cells: 1 Us ind default value of8 cells instead! Warning: Invalid number tor the celts width:S Using default vatue of 25 ansteadf warning Invalid color yettow USing detault…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education