Read two integers from STDIN and print three lines where:The first line contains the sum of the two numbers.The second line contains the difference of the two numbers (first - second).The third line contains the product of the two numbers.
Question
Read two integers from STDIN and print three lines where:The first line contains the sum of the two numbers.The second line contains the difference of the two numbers (first - second).The third line contains the product of the two numbers.
Solution
Sure, here is a Python solution for your problem:
# Read two integers from STDIN
num1 = int(input())
num2 = int(input())
# The first line contains the sum of the two numbers.
print(num1 + num2)
# The second line contains the difference of the two numbers (first - second).
print(num1 - num2)
# The third line contains the product of the two numbers.
print(num1 * num2)
This script will read two integers from the standard input (STDIN), then it will print the sum, difference, and product of these two numbers.
Similar Questions
TaskThe provided code stub reads two integers from STDIN, and . Add code to print three lines where:The first line contains the sum of the two numbers.The second line contains the difference of the two numbers (first - second).The third line contains the product of the two numbers.ExamplePrint the following:8-215Input FormatThe first line contains the first integer, .The second line contains the second integer, .
Your task is to take two numbers of int data type, two numbers of float data type as input and output their sum:Declare variables: two of type int and two of type float.Read lines of input from stdin (according to the sequence given in the 'Input Format' section below) and initialize your variables.Use the and operator to perform the following operations:Print the sum and difference of two int variable on a new line.Print the sum and difference of two float variable rounded to one decimal place on a new line.
In this challenge, you must read integers from stdin and then print them to stdout. Each integer must be printed on a new line. To make the problem a little easier, a portion of the code is provided for you in the editor below.
Write a program to find the sum of two integers using an inline lambda expression.Input format :The input consists of 2 integers.Output format :The output prints the sum of two integers.Sample test cases :Input 1 :5 6 Output 1 :11Input 2 :-12 7Output 2 :-5Input 3 :-5 -7Output 3 :-12
Print the sum and difference of both integers separated by a space on the first line, and the sum and difference of both float (scaled to decimal place) separated by a space on the second line.Sample Input10 44.0 2.0Sample Output14 66.0 2.0
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.