Answer to Question #257534 in Python for Isabel Cortez

Question #257534

2. Squares

by CodeChum Admin


Instructions:


Using a do...while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line.

Once the inputted value is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept in making your loop condition.


Instructions


Using a while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line.

If the inputted integer is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept as your looping condition and don't forget to declare and initialize the variable you will be using for your loop condition and make sure the initial value will not make the condition false at first.


Input


Multiple lines containing an integer.


2

6



Output


Multiple lines containing an integer.


4

36



1
Expert's answer
2021-10-27T07:45:27-0400
i = 0
while True:
    inp_int = int(input('Enter integer here: '))
    if inp_int != i:
        print(inp_int**2)
    else:
        print(inp_int**2)
        break

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog