Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.Write a while loop that lets the user enter a number. The number should be mul

ID: 3557383 • Letter: 1

Question

1.Write a while loop that lets the user enter a number. The number should be multiplied by 2, and the result assigned to a variable named "product" The loop should iterate as long as "product" is less than 1000.

2.Write a while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user if he or she wishes to perform the operation again. If so, the loop should repeat, otherwise it should terminate.

3.Write code that prompts the user to enter a positive nonzero number and validates the input (user must continue to enter a number until it is positive and nonzero).

Explanation / Answer

1.
a=int(raw_input())
product = a*2
while product < 1000:
print "Product: "
print product
product = product * 2

2.
while True:
a=int(raw_input())
b=int(raw_input())
c = a + b
print c
print "Press 1 if you wish to continue or 2 to terminate"
d=int(raw_input())
if d==1:
continue
else:
break


3.
while True:
a=int(raw_input())
if a>0:
continue
else:
break

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote