Question

Write a Python program that prompts a user for two integers and stores the two integers...

Write a Python program that prompts a user for two integers and stores the two integers the user types into the shell. Print the product, float division, integer division, remainder, sum, and difference of the two integers to the console. The entire equation must be printed (see below for formatting). Only display 2 digits after the decimal place for results that are floats. Include a module docstring that summarizes the program..

Sample Run 1:

Enter an integer: 5
Enter another integer: 4
5  *  4  =  20
5  /  4  =  1.25
5  //  4  =  1
5  %  4  =  1
5  +  4  =  9
5  -  4  =  1 

Sample Run 2:

Enter an integer: 1
Enter another integer: 3
1  *  3  =  3
1  /  3  =  0.33
1  //  3  =  0
1  %  3  =  1
1  +  3  =  4
1  -  3  =  -2

Homework Answers

Answer #1

SOURCE PROGRAM:

num1=int(input("Enter an integer:"))
num2=int(input("Enter another integer:"))
product=num1*num2
float_div=num1/num2
int_div=num1//num2
rem=num1%num2
add=num1+num2
sub=num1-num2
print(num1,"*",num2,"=",product)
print(num1,"/",num2,"= %.2f "%(float_div))
print(num1,"//",num2,"=",int_div)
print(num1,"%",num2,"=",rem)
print(num1,"+",num2,"=",add)
print(num1,"+",num2,"=",sub)

Note: % .2f means it will print only two decimal points

Sample input and output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
(Python Programming) Write a program that prompts a user for a positive integer and then uses...
(Python Programming) Write a program that prompts a user for a positive integer and then uses a loop to calculate and display the sum of specific fractions as follows: Let's say the user enters 5, then your program will compute: 1/5 + 2/4 + 3/3 + 4/2 + 5/1 which is 8.7.
In Python only. Write a program that prompts the user to enter a hex character and...
In Python only. Write a program that prompts the user to enter a hex character and displays its corresponding decimal integer.
Python programming Write a program that prompts the user to input the three coefficients a, b,...
Python programming Write a program that prompts the user to input the three coefficients a, b, and c of a quadratic equationax2+bx+c= 0.The program should display the solutions of this equation, in the following manner: 1. If the equation has one solution, display ONE SOLUTION:, followed by the solution, displayed with4 digits printed out after the decimal place. 2. If the equation has two real solutions, display TWO REAL SOLUTIONS:, followed by the two solutions, each displayed with4 digits printed...
design a program that prompts the user to enter a positive integer number and reads the...
design a program that prompts the user to enter a positive integer number and reads the user’s input. If the user input is not a positive number, the program should prompt them repeatedly until they enter a valid input. Once a valid input is received ,the program uses a loop to calculate the sum of the digits of the user’s input and displays the sum. For example, if the user enters the number 94311, the program should print the sum...
Write an application that prompts a user for two integers and displays every integer between them....
Write an application that prompts a user for two integers and displays every integer between them. Display There are no integers between X and Y if there are no integers between the entered values. Make sure the program works regardless of which entered value is larger. This is a java assignment. Pls help
Write a program that prompts the user to enter an integer number between 1 and 999....
Write a program that prompts the user to enter an integer number between 1 and 999. The program displays the sum of all digits in the integer if the input is valid; otherwise, it displays a message indicating that the integer is not between 1 and 999 and hence, is invalid. Name the program file Q1.cpp Example: if the user enters 12, sum of digits is 3. If the user enters 122, sum of digits is 5.
Write a python program that does the following: Prompts the user for three numbers in one...
Write a python program that does the following: Prompts the user for three numbers in one request. Be sure to specify the “delimiter” by which a user enters those three numbers. Divides the first number by the second number and add that result to the third number. Prints output that shows in one line the formula applied and the result of the calculation. Validate input by: •    Checking the user entered 3 values •    Appropriately checking for the following errors:...
Write an application that prompts a user for two integers and displays every integer between them....
Write an application that prompts a user for two integers and displays every integer between them. Display There are no integers between X and Y if there are no integers between the entered values. Make sure the program works regardless of which entered value is larger. ------------------------------------------------------------------------------------------------- import java.util.Scanner; public class Inbetween {     public static void main (String args[]) {         // Write your code here     } }
Write a C program, called logic_abc.c, that prompts the user to enter three integers a, b,...
Write a C program, called logic_abc.c, that prompts the user to enter three integers a, b, c, and then computes the results of the following logical operations, in sequence: !a || !b++ && c (a-1 || b/2) && (c*=2) (a-- || --b) && (c+=2) a || !(b && --c)
Python: Write a program that prompts the user to enter a positive integer value, and compute...
Python: Write a program that prompts the user to enter a positive integer value, and compute the following sequence: • If the value is even, halve it. • If it's odd, multiply by 3 and add 1. • Repeat this process until the value is 1, printing out each value. • Then print out how many of these operations you performed. If the input value is less than 1, print a message containing the word Error and exit the program....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT