CH - 6 Making Decision in Phython Program Solution Copy Work-2
CH - 6 Making Decision in Phython Program Solution Copy Work-2
Logical operator :-
If we need to combine more than one condition then we use these operator (and , or , not ).
Program 1. Write a program to find that the given number is even or odd ?
Solution :- number = int(input(“Enter the number “))
If number%2==0:
print(“The number is even ”)
else :
print(“ The number is odd”)
Program 2. Write a program to add two numbers and print result (result = A+B)?
Solution :- A= int(input(“Enter number A”))
B = int(input(“Enter number B”))
Result = A+B
print= (“Result”,Result)
Program 3. Write a program to find out that number 1 is greater or smaller than number 2 ?
Solution :- number1= int(input(“Enter the number 1”))
number2 = int(input(“Enter the number 2”))
if (number1 > number2 ):
print(number1, “ is greater than”,number2)
else:
print(number1, “ is smaller than”,number2)
Program 4. Write a program to find out that the number is negative , positive or zero ?
Solution :- number = int (input(“Enter the number ”))
if (number >0):
print(“ The number is positive”)
elif( number<0):
print(“The number is negative”)
else :
print(“The number is zero”)
Program 5. Write a program to find out square root of the given number ?
Solution :- number = int(input(“Enter the number” ))
print(“The square root of the number entered is :”,number**2)
Program 6. Write a program to calculate the area of the square field , first enter the length of the
square?
Solution :- length = int(input(“enter the square”))
area = length*length
print(“area of a square :”, area)