Set 1 Set 2 Set 3 Set 4 Set 5 Set 6 Set 7 Set 8 Set 9
Question: 1
Write a python script to take input for a number check and print whether the number is +ve or not?
Sol:
a=int(input("Enter any no ")) if(a>0): print("Number is +ve") else: print("Number is not +ve")
Output:
Enter any no 25
Number is +ve
>>>
Enter any no -9
Number is not +ve
>>>
Question: 2
Write a python script to take input for a number check and print whether the number is -ve or not?
Sol:
a=int(input("Enter any no ")) if(a<0): print("Number is -ve") else: print("Number is not -ve")
Output:
Enter any no 65
Number is not -ve
>>>
Enter any no -25
Number is -ve
>>>
Question: 3
Write a python script to take input for a number check and print whether the number is even or not?
Sol:
a=int(input("Enter any no ")) if(a%2==0): print("Number is even") else: print("Number is not even")
Sol:
Enter any no 34
Number is even
>>>
Enter any no 7
Number is not even
>>>
Question: 4
WAP to take input for a number check and print whether the number is odd or not?
Sol:
a=int(input("Enter any no ")) if(a%2==1): #or if(a%2==1): print("Number is odd") else: print("Number is not odd")
Output:
Enter any no 5
Number is odd
>>>
Enter any no 34
Number is not odd
>>>
Question: 5
WAP to take input for a number check and print whether the number is zero or not?
Sol:
a=int(input("Enter any no ")) if(a==0): print("Number is zero") else: print("Number is not zero")
Output:
Enter any no 0
Number is zero
>>>
Enter any no 5
Number is not zero
>>>