Question

In: Computer Science

Exercise #3 python Write a program that could evaluate the relationship between two values. User is...

Exercise #3 python

Write a program that could evaluate the relationship between two values. User is to key in the two values, and it will be stored in variable, num1 and num2. The program will do a comparison between the two values. If num1 is greater than num2, a message will be display on screen to indicate that num1 is greater than num2. The program will also display appropriate messages when num2 is greater than num1; and num1 is equal to num2. Once user get to know the relationship between the two values, he/she should be prompted with an option to insert the next two values or terminate the program.

Solutions

Expert Solution

below is the code which takes the numbers as input from user and then uses the if elif else conditional statements to check the values of both the numbers.

Code and OUtput:

choice = 'y'

while(choice!='n' and choice!='N'):
num1 = int(input("Enter value of num1: "))
num2 = int(input("Enter value of num2: "))
  
if num2 > num1:
print("num2 is greater than num1")
elif num1 > num2:
print("num1 is greater than num2")
else:
print("num1 is equal to num2")
  
choice = input("try again? ")

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!


Related Solutions

Phyton Exercise 3 Write a program that could evaluate the relationship between two values. User is...
Phyton Exercise 3 Write a program that could evaluate the relationship between two values. User is to key in the two values, and it will be stored in variable, num1 and num2. The program will do a comparison between the two values. If num1 is greater than num2, a message will be display on screen to indicate that num1 is greater than num2. The program will also display appropriate messages when num2 is greater than num1; and num1 is equal...
In python. Projectile motion: Write a python program that will ask the user for      an...
In python. Projectile motion: Write a python program that will ask the user for      an initial height y0, initial velocity v, launch angle theta, and mass m.      Create two functions, one that will calculate max height      of the projectile, and one that will calculate the range. Ask the     user which one he/she would like to calculate, then present them with the answer. (use kg, m and m/s)
Calculating Delivery Cost Program in Python write a program in Python that will ask a user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user to enter the purchase total, the number of the items that need to be delivered and delivery day. Then the system displays the cost of delivery along with the total cost. Purchase total > $150 Yes Number of the items (N) N<=5 N>=6 Delivery day Same Day Next Day Same Day Next Day Delivery charges ($) 8 N * 1.50 N * 2.50 N...
In Python, write a program that allows the user to enter a number between 1-5 and...
In Python, write a program that allows the user to enter a number between 1-5 and returns the vitamins benefits based on what the user entered. The program should: Continue to run until the user quits and Validate the user’s input (the only acceptable input is 0, 1, 2, 3, 4, or 5), If the user enters zero “0” the program should terminate You can use the following facts: 1- Vitamin A protects eyes from night blindness and age-related decline...
In Python, write a program that allows the user to enter a number between 1-5 and...
In Python, write a program that allows the user to enter a number between 1-5 and returns the vitamins benefits based on what the user entered. The program should: Continue to run until the user quits and Validate the user’s input (the only acceptable input is 0, 1, 2, 3, 4, or 5), If the user enters zero “0” the program should terminate You can use the following facts: 1- Vitamin A protects eyes from night blindness and age-related decline...
Write a program that asks the user to type in two integer values. Test these two...
Write a program that asks the user to type in two integer values. Test these two numbers to determine whether the first is evenly divisible by the second and then display the appropriate message to the terminal. Objective C
Write a python program that will allow a user to draw by inputting commands. The program...
Write a python program that will allow a user to draw by inputting commands. The program will load all of the commands first (until it reaches command "exit" or "done"), and then create the drawing. Must include the following: change attributes: color [red | green | blue] width [value] heading [value] position [xval] [yval] drawing: draw_axes draw_tri [x1] [y1] [x2] [y2] [x3] [y3 draw_rect [x] [y] [b] [h] draw_poly [x] [y] [n] [s] draw_path [path] random random [color | width...
• Write a C++ program that asks the user to input two integer values, then calls...
• Write a C++ program that asks the user to input two integer values, then calls a void function "swap" to swap the values for the first and second variable. • As we mentioned before, in order to swap the valors of two variables, one can use the following: temp= variable1; variable1 = variable2; variable2 = temp; • Display the two variables before you call swap and after you call that function. Comment in code would be greatly appreciated to...
In Python write a program that asks the user to enter the monthly costs for the...
In Python write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance the program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. your program MUST have BOTH a main function AND a function named calcExpenses to calculate the expenses. DO NOT display the expenses inside of the calcExpenses function!!...
JAVA PROGRAM Write program that will prompt user generate two random integers with values from 1...
JAVA PROGRAM Write program that will prompt user generate two random integers with values from 1 to 10 then subtract the second integer from the first integer. Note, if the second integer is greater than the first integer, swap the two integers before making the subtraction.Then prompt user for the answer after the subtraction. If the answer is correct, display “Correct”otherwise display “Wrong”.You will need to do this in a loop FIVE times and keep a count of how many...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT