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...
For this discussion, you will need to do a bit of research. Look up the serial...
For this discussion, you will need to do a bit of research. Look up the serial killer Charles Manson. Find out about his childhood. Was there abuse in his background? Did he have a familial history of criminal activity? Did he show signs of Conduct Disorder and/or Oppositional Defiant Disorder earlier in their childhood? Were there warning signs of his pathology? Be as thorough as possible in your research of them. Lastly, finish your post with suggestions for intervention for...
Discussion Questions Read: A) Review van Cleave (2016) Chapter 3. If we need to make complex...
Discussion Questions Read: A) Review van Cleave (2016) Chapter 3. If we need to make complex inferences, what intellectual virtues does Van Cleave argue we should employ? Discuss an example from your professional or personal life where these virtues would help strengthen your ability to make logical inferences. Reflect: B) What misconceptions often rise around the idea of a scientific “theory”? What are the characteristics of good scientific theories? C) Review Van Cleave (2016) Chapter 3. Look at the example...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT