Python: Input two integers in a single line
Python Basic: Exercise-134 with Solution
Write a Python program to input two integers in a single line.
Sample Solution:-
items = [1, 2, 3, 4, 5]
squared = []
for i in items:
squared.append(i**2)
items = [1, 2, 3, 4, 5]
squared = list(map(lambda x: x**2, items))
def multiply(x):
return (x*x)
def add(x):
return (x+x)
funcs = [multiply, add]
for i in range(5):
value = list(map(lambda x: x(i), funcs))
print(value)
# Output:
# [0, 0]
# [1, 2]
# [4, 4]
# [9, 6]
# [16, 8]
print("Input the value of x & y")
a1,a2=list(map(int, input().strip().split()))
print("The value of x & y are: ",a1,a2)
print("Input the value of x & y")
a3,a4=map(int, input().strip().split())
print("The value of x & y are: ",a3,a4)
========= RESTART: F:/Python_APSC/py-ex-basic-134.py ==========
[0, 0]
[1, 2]
[4, 4]
[9, 6]
[16, 8]
Input the value of x & y
12 45
The value of x & y are: 12 45
Input the value of x & y
56 78
The value of x & y are: 56 78
>>>
沒有留言:
張貼留言