Ask Question
22 April, 13:08

Write an algorithm that read a number from the user "assuming the number entered is always between 1-100", when the number entered is greater than 50, a variable X is incremented by 1, otherwise, a variable Y is incremented by 1. After that check the value of X and Y, if X is greater than Y then print (Most of your numbers are greater than 50), otherwise print (Most of your numbers are less than or equals to 50), Hint: the program stops when the user entered number 0

+1
Answers (1)
  1. 22 April, 16:05
    0
    import sys

    number = int (input ("Enter a number between 1 to 100 : "))

    x = 0

    y = 0

    if number = = 0:

    sys. exit ()

    if number > 50:

    print ("Increment x value")

    x=x+1

    else:

    print ("Increment y value")

    y=y+1

    if x > y:

    print ("Most of your numbers are greater than 50")

    else

    print ("Most of your numbers are less than or equals to 50")

    Explanation:

    In this algorithm the User is asked to input the number.

    If the input number is 0 then the user will exit the algorithm

    If the input number is greater than 50 then X variable is incremented by 1

    If the input number is less than 50 then the variable Y is incremented by 1

    Then X and Y values are compared, if the value of x is greater than y then

    and print command will print Most of your numbers are greater than 50

    If the value of Y is greater than X then print command will print Most of your numbers are less than or equal to 50
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write an algorithm that read a number from the user "assuming the number entered is always between 1-100", when the number entered is ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers