Question

In: Computer Science

Write a program that prompts the user for an even number from 2 to 100 until...

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)

Solutions

Expert Solution

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:


Related Solutions

In Java: Write a program that prompts the user to enter a positive number until the...
In Java: Write a program that prompts the user to enter a positive number until the user input a negative number. In the end, the program outputs the sum of all the positive numbers. You should use do-while loop (not while, not for). You cannot use break or if statement in the lab. Hint: if the program adds the last negative number to your sum, you can subtract the last number from the sum after the loop.
JAVA Program Write a program that prompts the user for data until the user wishes to...
JAVA Program Write a program that prompts the user for data until the user wishes to stop (you must have a while loop) (You must read in at least 8 to 10 sets of voter data using dialog boxes) The data to read in is: The registration of the voter (Democrat, Republican or other) The gender of the voter The Presidential candidate the voter is choosing (Trump or Biden) Which candidate has done better to manage the economy? (Trump or...
First, write a program to loop asking for a number from the user until the user...
First, write a program to loop asking for a number from the user until the user inputs a zero or until the user has input 50 numbers. Store each value in an array except the values that are divisible by 5 and display all stored values. Determine how many of the values stored in the array were divisible by 10 and display result. Next, write a function getMinMax that accepts an array of floats and the size of the array,...
Write a program in C that prompts the user for a number of seconds and then...
Write a program in C that prompts the user for a number of seconds and then converts it to h:m:s format. Example: 5000 seconds should display as 1:23:20 (1 hour, 23 minutes, 20 seconds.) Test with several values between about 100 seconds and 10,000 seconds. use unint and remainders for this and keep it as simple as possible.
Write a program that prompts the user to input a decimal number and outputs the number...
Write a program that prompts the user to input a decimal number and outputs the number rounded to the nearest integer.
Write a complete C++ program that prompts the user for and takes as input, numbers until...
Write a complete C++ program that prompts the user for and takes as input, numbers until the user types in a negative number. the program should add all of the numbers together. Then if the result is less than 20 the program should multiply the result by 3, otherwise subtract 2 from the result. Finally, the program should printout the result.
IN C++ Write a program that prompts the user to enter the number of students and...
IN C++ Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score (display the student’s name and score). Also calculate the average score and indicate by how much the highest score differs from the average. Use a while loop. Sample Output Please enter the number of students: 4 Enter the student name: Ben Simmons Enter the score: 70 Enter the student name:...
C++ [2] Write a program that prompts the user to enter a non-negative decimal number and...
C++ [2] Write a program that prompts the user to enter a non-negative decimal number and a base in the range 2 <= base <= 16. Write a function multibaseOutput() that displays the number in the specified base. The program terminates when the user enters a number of 0 and a base 0. Run: Enter a non-negative decimal number and base (2 <= B <= 16) or 0 0 to terminate: 155 16     155 base 16 is 9B Enter...
Write a program that prompts the user for a grade (0-100), and asks if the student...
Write a program that prompts the user for a grade (0-100), and asks if the student is a graduate student or not. (Y/N).   If the student is a graduate student, the grade is reduced by 10%, because we have a higher expectation for graduate students, in an undergraduate class. The program then computes, and prints the letter grade based on the scale below. 90-100 A 80-89 B 70-79 C 60-69 D 0-60 F The program also provides feedback based on...
Write a JAVA program that prompts the user for the number of names they’d like to...
Write a JAVA program that prompts the user for the number of names they’d like to enter. Create a new array of the size chosen by the user and prompt the user for each of the names. Output the list of names in reverse order.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT