You are on page 1of 1

APEEJAY SCHOOL PANCHSHEEL PARK

SUBJECT: COMPUTER SC. CLASS : XI


CHAPTER : Python - Conditional statements
1. Evaluate the following logical conditions assuming that a=10, b=20, c=’three’, d=’four’
(i) a>b/2, (ii) a<=b/2 (iii) a!=b (iv) b==a**2 (v) a+b > -b*-a (vi) b*2 > ord(‘2’)
2. What are the three ways of using if statement in Python?
3. What are relational operators? What relational operators are available in Python?
4. What are logical operators? What logical operators are available in Python?
5. What is pseudocode? Write the pseudocode to input two numbers from the user and find their
sum.
6. Write Python expression for each of the following conditions (assuming that num1, num2 are
numbers):
(i) To check whether num1 is equal num2.
(ii) To check whether num1 is unequal to num2.
(iii) To check whether num1 is a factor of num2.
(iv) To check whether num1 is a multiple of num2.
(v) To check that both num1 and num2 are even.
7. Find syntax error(s), if any, in each of the following scripts:
(i) n1,n2=5,4
if n1=n2:
print("Equal")
(ii) n1=n2=12/5
if n1!=n2 print"Not
equal" else
print"Equal"

(iii) 12=age
if age=<10:
print(Primar)
elseif age=<13: print(Middle)
elseif age<=15:
print(Secondary)
else age<=17: print(SrSecondary)

8. Find output generated by each of the following scripts:


(i) n=1980
if n%100!=0 and n%4==0 or n%400==0:
print("Leap year")
else: print("Not a Leap year")
(ii) n1=n2=12/5
if int(n1)==n2:
print("Integer")
else: print("Non integer")
(iii) age=12
if not age<18:
print("Eligible to vote")
else: print("Not eligible to vote")
9. Write a script to input a number and check whether it is even or odd, and then display an
appropriate message.
10. Write a script to input a number. If the number is even, print its square, otherwise print its cube.
11. Write a script which inputs two numbers from the user and checks if first number is divisible by the
second or not. The script should then display an appropriate message.
12. Gunjan wants to write a script to input the number of students of a class and perform some
processing. She knows that sometimes the user may enter a negative number for the number of
students. In such a case, she wants to take the positive value of the number (e.g., if user enters -
35, she wants to take 35). Help Gunjan by writing the part of the script which inputs the number of
students in a class and converts it into a positive number if it is negative.

You might also like