Question

When using Python, what exactly is printed when the following program is run? counter = 4...

When using Python, what exactly is printed when the following program is run?

counter = 4

sum = 0

while counter < 7:

sum = sum + 2

counter = counter + 1

print ("Value is", sum)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

counter = 4
sum = 0
while counter < 7:
    sum = sum + 2
    counter = counter + 1
print("Value is", sum)



Value is 6

Add a comment
Know the answer?
Add Answer to:
When using Python, what exactly is printed when the following program is run? counter = 4...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose the PYTHON program below is run on your computer: expenses = 0 while True: answer...

    Suppose the PYTHON program below is run on your computer: expenses = 0 while True: answer = input("Give the price of the next item ordered?") if answer == "end": break else: price = float(answer) expenses = expenses + price print "Total value of orders is:", expenses What changes should I make to the PYTHON program above so that it is clear that the values are all printed in pounds?

  • [10pts] 7) What is the output of the following program? In other words, what is printed...

    [10pts] 7) What is the output of the following program? In other words, what is printed to the screen when you run it? #include <iostream> #include <queue> using namespace std int main) char qu[5] ('a, 'b',c'd','e' queue <char> q int N = 4; char ch for(int í - 0:ì < 5;++1) q.push(qu (]) for (int ǐ 0;i < N;++i) { = ch q.front); q push(ch): q.pop while(!q.emptyO) f cout << q.front ) <<endl; q.pop )

  • Need in Python! Consider the following program and expected output. Rewrite it using a for loop...

    Need in Python! Consider the following program and expected output. Rewrite it using a for loop and a conditional break statement such that it has the same output.   HINT: Stay with i as the main loop counter and let j control the break behavior.   i = 0 while i < 10 and j < 10 : j = i * 2 print(i, j) i += 1 # Output below, for reference - not part of the program! 0 0 1...

  • Need in Python! Consider the following program and expected output. Rewrite it using a for loop...

    Need in Python! Consider the following program and expected output. Rewrite it using a for loop and a conditional break statement such that it has the same output.   HINT: Stay with i as the main loop counter and let j control the break behavior.   i = 0 while i < 10 and j < 10 : j = i * 2 print(i, j) i += 1 # Output below, for reference - not part of the program! 0 0 1...

  • (in python please) What is printed by the following program? Suppose the input is: Miller 34...

    (in python please) What is printed by the following program? Suppose the input is: Miller 34 62.5 CONVERSION = 3.5 TEMP = 23 name = input('Enter last name:') id = input('Enter a two digit integer: ') num = (int(id) * TEMP) % CONVERSION decNum = input('Enter a decimal number: ') mysteryNum = float(decNum) / CONVERSION - TEMP print('Name: ' + name) print('Id: ' + id) print('Mystery number: ' + str(mysteryNum)) Note: There are 3 lines of printed information; enter the...

  • Program using Python. This program will draw a user-defined grid on the screen. When run the...

    Program using Python. This program will draw a user-defined grid on the screen. When run the program will prompt the user for a positive (not 0) number to use for the grid spacing. Make sure to provide a reasonable default, and reasonable max value. Demo1 Demo1 Grid Grid Grid Enter grid spacing Cance 00:03 1I 00:03

  • Part 1: Python code; rewrite this code in C#, run the program and submit - include...

    Part 1: Python code; rewrite this code in C#, run the program and submit - include comments number= 4 guesscount=0 guess=int(input("Guess a number between 1 and 10: ")) while guess!=number: guesscount=guesscount+1 if guess<number: print("Your guess is too low") elif guess>number: print("Your guess is too high") else: print("You got it!!") guess=int(input("Guess again: ")) print("You figured it out in ",guesscount," guesses") Part 2: C++ code; rewrite the following code in C#. Run the program and submit. - include comments #include <iostream> using...

  • what will be printed when you run below code in python? age=6 age=(age**2)//2 print(age) if (age...

    what will be printed when you run below code in python? age=6 age=(age**2)//2 print(age) if (age >25) print("You will pay $120 per month") print("check date:") elif(age >=16) print("You will pay $90 per month") else: print("You will pay $50") print("Check payment due date") print(" Your payment is due by Oct 2019")

  • Write, save, and run a Python program that will do the following when run: Let’s consider...

    Write, save, and run a Python program that will do the following when run: Let’s consider the following assignment: a = 1 * 2 + 38 / 8 You want to change the precedence of the operators so that the addition operations are executed first. How would you re-write the assignment? Write a print statement to show the output. Let’s consider the following assignments: x = 'z' y= ['x', 'z', 'q'] Now, apparently x is a member of y. Write...

  • Lab 4.2 1.Construct a program that will print out the value of the counter variable until...

    Lab 4.2 1.Construct a program that will print out the value of the counter variable until the counter variable reaches 7 2.Include an if statement that will stop the loop once the counter variable reaches 4 3.Restart the loop so that the count continues until 7 is reached 4.Save the program as lab4.2 and submit it (Use repl.it and use Python language Display: 1 2 3 5 6 7

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT