# Not able to solve simple python programming question

## Recommended Posts

Question-

``````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.
Example
Print the following:
8 -2 15
``````

``````if __name__=='__main__':
a=input(int())
b=input(int())

if 1<=a<=10**10 and 1<=b<=10**10:
summation = a+b
diff = a-b
multiply = a*b

print(summation)
print(diff)
print(multiply)
``````

error

``````Traceback (most recent call last):
File "Solution.py", line 6, in <module>
if 1<=a<=10**10 and 1<=b<=10**10:
TypeError: '<=' not supported between instances of 'int' and 'str'``````
##### Share on other sites

3 minutes ago, gugtenterf said:

Question-

``````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.
Example
Print the following:
8 -2 15
``````

``````if __name__=='__main__':
a=input(int())
b=input(int())

if 1<=a<=10**10 and 1<=b<=10**10:
summation = a+b
diff = a-b
multiply = a*b

print(summation)
print(diff)
print(multiply)
``````

error

``````Traceback (most recent call last):
File "Solution.py", line 6, in <module>
if 1<=a<=10**10 and 1<=b<=10**10:
TypeError: '<=' not supported between instances of 'int' and 'str'``````

`https://pythondev.online/`

thanks in advance for any help

Edited by gugtenterf
##### Share on other sites

• 1 month later...

a = [4,5,6]
b = [1,2,3]

answer_list = [(x[0]+x[1],x[0]-x[1], x[0]*x[1]) for x in zip(a,b)]

print()

************************

```add 5
subtract 3
product 4

subtract 3
product 10

subtract 3
product 18```
##### Share on other sites

with numpy:

**********************************

import numpy as np

arr1 = np.array(range(1,4))      # [1,2,3]
arr2 = np.array(range(4,7))     # [4,5,6]

sub_arr = arr2 - arr1
print("differences",sub_arr)
multi_arr = arr2 * arr1
print("products",multi_arr)

***************************

```sums [5 7 9]
differences [3 3 3]
products [ 4 10 18]```

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.