2018年1月11日 星期四

Python: Filter the positive numbers from a list

Python: Filter the positive numbers from a list

Python Basic: Exercise-114 with Solution

Write a Python program to filter the positive numbers from a list.
Sample Solution:-
nums = [34, 1, 0, -23]
print("Original numbers in the list: ",nums)
new_nums = list(filter(lambda x: x >0, nums))
print("Positive numbers in the list: ",new_nums)

========== RESTART: F:/Python_APSC/py-ex-basic-114.py ===========
Original numbers in the list:  [34, 1, 0, -23]
Positive numbers in the list:  [34, 1]
>>> 

沒有留言:

張貼留言

ESP32 遠端感應控制系統

ESP32 遠端感應控制系統 目前的架構設計(結合了 ESP32、RFID、MQTT、Node-RED 與 Telegram 遠端雙向控制 ),這個系統的核心價值在於 即時感應、雲端中繼、智慧自動化與即時通訊回報 。 整個架構透過無線網路(Wi-Fi),將現場的硬體感測端、雲端訊...