1. How to detect Positive and Negative Numbers| 5 Simple projects of python |alltechinfo


1. How to detect Positive and Negative Numbers

Code : -

x = float(input("Insert any number: "))

if x>0:
    print("This is a POSITIVE number")
elif x < 0:
    print("This is a NEGATIVE number")
else:
    print("The number is ZERO")





Output :-



2. How to check for Even and odd Numbers


Code:-

x = int(input("Insert any number: "))

if x%2 == 0:
    print("This is an EVEN number!")
else:
    print("This is an ODD number!")


Output:-




3. How to check for Greatest of 3 Numbers.


Code:-

x = int(input("Insert first number: "))
y = int(input("Insert second number: "))
z = int(input("Insert third number: "))

print("The maximum number is : ", end="")
if y<= x >=z:
    print(x)
elif x <= y >=z:
    print(y)
elif x<= z >= y:
    print(z)

Output:-




4. How to check for divisibility of a Number.

Code:-

x = int(input("Insert the numerator: "))
y = int(input("Insert the denomiator: "))

if x%y == 0:
    print(x, " is divisible by ", y)
else:
    print("No! ", x, " is not divisible by ", y)


Output :-




5. How to convert from Celsius to Fahrenheit.


Code:-

x = int(input("Insert a value in Celcius: "))

x = round(x*(9/5) + 32 )
print(str(x) + 'F')


Output :-



Post a Comment

0 Comments