-2

Ask the user for two positive numbers and add them together. If the answer is 50 or more then display the answer in a user friendly format. If the answer is below 50, ask the user to continue to select more numbers until the answer is 50 or above.

2 Answers2

0
    sum = 0
    while sum <=50: 
        val1 = int(raw_input("Enter the first number: "))
        val2 = int(raw_input("Enter the second number:"))
        sum = val1+val2
        if sum >= 50:
            print "The sum is: "+sum

Use the above code. Hope it works. But this is an infinite loop, until the sum becomes 50.

Vikram Sharma
  • 199
  • 2
  • 2
  • 13
0

please try this

 sum=0;
 while sum <= 50:
  num1=input("enter first value ");
  num1=float(num1);
  num2=input("enter second value ");
  num2=float(num2);
  sum=num1+num2;
  print("sum of ",num1," and ",num2," is ",sum);