Computer Science, asked by anantraj88, 8 months ago


Write a Python program to accept two integer numbers from the user. Find their product and if the product is greater than 1000, then print the sum of the nos., else print their product (3)​

Answers

Answered by VineetaGara
8

The Python program for the above-given question is as follows:

[Each line of the program is started from a new line and it is numbered.]

1. #python 2.7.15

2. num1=int(input("enter no. 1: " ))

3. num2=int(input("enter no. 2: "))

4. product = num1*num2

5. res= (num1+num2) if p > 1000 else product

6. print(res)

Description for the above python program:

Python is one of the programming languages of computers.

  • line 1: In this line, the version of python is given, here it is 2.7.15, (what I've used.)
  • line 2: the function int defines that the user will be asked to enter the first value that is an integer number.
  • line 3: again int defines and asks the user to give the second value which is also an integer.
  • line 4: product is defined as the result of the two integer values given by the user.
  • line 5: here, the res is defined as a result. A Conditional statement is used here. As per the question, if the result will be printed as the sum of the two integers if it is greater than 1000, or else the product will be printed.
  • line 6: in this function print is used to print the result(res).

Similar questions