Computer Science
Write a program to print one of the words negative, zero, or positive, according to whether variable x is less than zero, zero, or greater than zero, respectively
Python
Python Funda
53 Likes
Answer
x = int(input("Enter x: "))
if x < 0:
print("negative")
elif x > 0:
print("positive")
else:
print("zero")
Output
Enter x: -5
negative
Enter x: 0
zero
Enter x: 5
positive
Answered By
26 Likes
Related Questions
Find and write the output of the following python code:
for Name in ['Jay', 'Riya', 'Tanu', 'Anil'] : print (Name) if Name[0] == 'T' : break else : print ('Finished!') print ('Got it!')
Is the loop in the code below infinite? How do you know (for sure) before you run it?
m = 3 n = 5 while n < 10: m = n - 1 n = 2 * n - m print(n, m)
Write a program that returns True if the input number is an even number, False otherwise.
Write a Python program that calculates and prints the number of seconds in a year.