2018年1月11日 星期四

Python: Check if a number is positive, negative or zero

Python: Check if a number is positive, negative or zero

Python Basic: Exercise-109 with Solution
Write a Python program to check if a number is positive, negative or zero.
Sample Solution:-
num = float(input("Input a number: "))
if num > 0:
   print("It is positive number")
elif num == 0:
   print("It is Zero")
else:
   print("It is a negative number")

================= RESTART: F:/Python_APSC/py-ex-basic-190.py =================
Input a number: 12.3
It is positive number
>>> 
================= RESTART: F:/Python_APSC/py-ex-basic-109.py =================
Input a number: -5.3
It is a negative number
>>> 

沒有留言:

張貼留言

經由MQTT協定的2個WOKWI ESP32 雙向通訊 (ESP32 to ESP32 MQTT Communication )

 經由MQTT協定的2個WOKWI ESP32 雙向通訊  (ESP32  to ESP32 MQTT Communication ) 使用兩個 ESP32 建立一個遠端控制系統。 MQTT Broker: mqtt-dashboard.com Topic (主題): ale...