In: Computer Science
Write a program that prompts the user for an even number from 2 to 100 until the number 90 is encountered. Not including the 90, calculate the minimum value.
In case you know what this means: DO NOT USE LISTS! We will look into the use of lists later.
This has to be done in the python program.
Here's what I have so far:
inp = 0
min = 0
while inp != 90:
inp = int(input("Please enter an even number from 2 to 100 (90 to stop): "))
print(inp)
if ((inp>= 2 and inp <= 100) and inp != 90):
min = inp
else:
print("No minimum value")
print("the minimum value is", min)
Python code:
#accepting first input
inp=int(input("Please enter an even number from 2 to 100 (90 to
stop): "))
#initializing minimum as 101
min=101
#looping till 101 is entered
while(inp!=90):
#checking if input is less than min
if(inp<min):
#assigning inp to min
min=inp
#accepting input
inp=int(input("Please enter an even number from 2 to 100 (90 to
stop): "))
#checking if min is not 101
if(min!=101):
#printing minimum value
print("the minimum value is",min)
else:
#printing no minimum value
print("No minimum value")
Screenshot:
Input and Output: