Write a user-define function, called checkNumber(x), that takes as an input an integer
number (read in the main function using input) and prints out positive, negative, or
zero according to whether the number is positive, negative, or zero.
def check_number(number):
if number > 0:
return 'Positive'
elif number == 0:
return 'Zero'
elif number < 0:
return 'Negative'
def main():
number = int(input('Number: '))
print(check_number(number))
if __name__ == '__main__':
main()
Comments
Leave a comment