Question

COSC-1315 2807 12B Introduction to Computer Programming For this discussion, you saw in the chapter that...

COSC-1315 2807 12B Introduction to Computer Programming


For this discussion, you saw in the chapter that the while loop is a pretest loop. What is a post test loop and what example can you come up with? Lastly, what explanation can you find as to why Python does not have a post test loop?

Homework Answers

Answer #1

(1.)

Post Test loop, where the condition comes after the body. Using a while loop first checks the statement within the loop and then goes to check the condition to determine if the statement will run again or not.

Example: using c++

#include <iostream>

using namespace std;

int main()
{
    int i = 0;
    do {
        cout << i << endl;
        i++;
    } while(i<5);

    return 0;
}

(2.)

In Python, there is no structure made for do-while loop or post test loop, because if the post-test loop, it will give you value like an infinite loop and will never close the loop. That's why we use break to stop the while post-test loop.

Basically there is no logic built for post test loop.

In Python, we use while loop like this

i = 0

while True:
    print(i)
    
    if i >= 5:
        break
    i = i+1

Thumbs Up Please !!!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In Chapter 6 we learned about many different types of Elasticity. For this discussion question we're...
In Chapter 6 we learned about many different types of Elasticity. For this discussion question we're going to practice what some of these elasticities represent. For each of the following come up an example of a good that you believe has the property listed: A good that has own-price elasticity between 0 and 1 (in absolute value) A good that has own-price elasticity larger than 1 (in absolute value). Two goods that have negative cross-price elasticity. Two goods that have...
Choose 2 of the following questions and give your answers: Based on the brief introduction, the...
Choose 2 of the following questions and give your answers: Based on the brief introduction, the example and explanation provided, the video clip, and your current knowledge of statistics, create a list of factors that you think might influence how a communicator, such as a newspaper reporter or television analyst, decides to present a set of statistics. Why are absolute numbers and percentages, when one is presented without the other, so often misleading? Compare the mean, mode, and median. When...
Week 8 Discussion Consider the different post hoc tests discussed in the readings and respond to...
Week 8 Discussion Consider the different post hoc tests discussed in the readings and respond to the following: Describe the general rationale behind using post hoc tests (i.e., when they are used and why). One of the advantages of using an ANOVA (compared to using t-tests) is also a disadvantage—using an ANOVA makes it necessary to use post hoc tests if there is a significant main effect. We use a post hoc test because there is one specific advantage in...
Reply to the following Discussion Question with a substantive post - one that demonstrates that you...
Reply to the following Discussion Question with a substantive post - one that demonstrates that you understand the mathematical concepts and provides an explanation rather than just making a simple statement about the topic. The z-statistic is calculated with the formula z = (sample statistic - null parameter)/(standard error). Why do we subtract the null parameter from the sample statistic? In other words, what does subtracting achieve for us? Why do we then divide that value by the standard error?...
What assumptions do you have about unemployment? Have those assumptions been challenged by readings or videos...
What assumptions do you have about unemployment? Have those assumptions been challenged by readings or videos that further discuss unemployment, lay-offs, outsourcing, etc.? Why? Do you think that there can be positive outcomes for the unemployed after layoffs, downsizing, and outsourcing? You may look at a specific region (like Detroit, for example), or a specific industry, but you should find some examples to back your argument. Be sure to cite your sources while you write a post in the discussion...
Discussion 4.2: Harassment You are the director of a radiology department. During a routine individual meeting...
Discussion 4.2: Harassment You are the director of a radiology department. During a routine individual meeting with one of your male staff, the employee tells you that a female employee has been making suggestive remarks to him, and occasionally grabbed and fondled him in a sexual manner. He said he asked her several times to stop this behavior as he was married and did not appreciate the behavior, particularly in a work setting. The behavior continued anyway. The male employee...
For this discussion board, come up with an example of a hypothesis test that could be...
For this discussion board, come up with an example of a hypothesis test that could be conducted. State the null and alternative hpothesis. Then state what it would mean to have a type I vs. a type II error in the given situation. Explain which you think is "worse" given the circumstances. An example is given below using "the boy who cried wolf": Null hypothesis: Wolf is not present Alternative hypothesis: Wolf is present Type I error: The boy cries...
Introduction We are surrounded by people everyday but how does this affect our behavior? Would you...
Introduction We are surrounded by people everyday but how does this affect our behavior? Would you obey someone who you thought was in a position of authority even though you really did not want to? Let’s see what one of the significant studies in Social Psychology found out about the influence of others on our behavior. Milgram’s classic study of obedience is quite interesting. As you read about the study and research your Discussion answer, think of other instances in...
If you have not already done so, make sure to review the content covered in the...
If you have not already done so, make sure to review the content covered in the following sections. 6.1 Interactive Assignment Section 6.1 Homework 6.2 Interactive Assignment Section 6.2 Homework Now that you have had a chance to review the content covered so far, take a moment to reflect upon what you have learned and post in this discussion board below. Consider one or two of the following statements in your post: Provide a real life example that pertains to...
HIMT 345 Homework 06: Iteration Overview: Examine PyCharm’s “Introduction to Python” samples for Loops. Use PyCharm...
HIMT 345 Homework 06: Iteration Overview: Examine PyCharm’s “Introduction to Python” samples for Loops. Use PyCharm to work along with a worked exercise from Chapter 5. Use two different looping strategies for different purposes. Prior Task Completion: 1. Read Chapter 05. 2. View Chapter 05’s video notes. 3. As you view the video, work along with each code sample in PyCharm using the Ch 5 Iteration PPT Code Samples.zip. Important: Do not skip the process of following along with the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT