CBSE Class 11 Python @ Home

# Class 11: if condition 7

Question: 16

Write a python script to take input for a number if the number is <=10 calculate and print its square?

Sol:

```a=int(input("Enter any no "))
if(a<=10):
b=a*a
print("Square = ",b)```

Output:

Enter any no 5
Square = 25
>>>

Question: 17

Write a python script to take input for a number is the number is <=10 calculate and print its cube otherwise print its square?

Sol:

```a=int(input("Enter any no "))
if(a<=10):
b=a*a*a
print("Cube = ",b)
else:
b=a*a
print("Square = ",b)```

Output:

Enter any no 5
Cube = 125
>>>
Enter any no 12
Square = 144
>>>

Question: 18

Write a python script to take input for a number check and print whether the number is +ve , -ve or zero?

Sol: (1st method)

```a=int(input("Enter any no "))
if(a==0):
print("number is zero")
else:
if(a>0):
print("number is +ve")
else:
print("number is -ve") ```

Sol: (2nd method):

```a=int(input("Enter any no "))
if(a==0):
print("number is zero")
elif(a>0):
print("number is +ve")
else:
print("number is -ve") ```

Output:

Enter any no 25
number is +ve
>>>
Enter any no -96
number is -ve
>>>
Enter any no 0
number is zero
>>>