2018年1月11日 星期四

Python: Input two integers in a single line

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
>>> 


沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...