0% found this document useful (0 votes)
14 views2 pages

Worksheet 3 - FA

Uploaded by

prerana.arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Worksheet 3 - FA

Uploaded by

prerana.arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Subject: Computer Science Grade: XI

Conditional and Iterative Statement


Worksheet 3 – FA
Name: …………………...… Date: ………………….
MM: 25

Answer the following questions:


1. What is the purpose of range( ) function? Give one example. (1)
2. Why are break statements used in a while or for a loop? (1)
3. What is looping? (1)
4. Give the output for the following program statement given below. (1)
for i in range (-5,-7,-1):
print(i+1)
5. Find the output of the following code: (1)
i=1
while (i < 5):
Print(i)
i=i*2
6. Find the syntax error in the following program and underline after correcting them.
w=90: (1)
while (w > 60)
print(W)
w=w-50
7. Construct logical expressions to represent the following conditions. (1)
a) Weight is greater than or equal to 115 but less than 125.
b) Donation is in the range of 4000-5000 or Guest is 1.
8. Convert the following while loop into for loop (1)
a=1
b=20
sum=0
while(a < b):
x=int(input(“Enter the Number”))
sum+=x
a=a+2
print(“sum=”,sum)
9. Find the error(s) in the following code (if any) and correct it by rewriting the code and
underlining the corrections: (1)
x=int(“Enter value of x:”))
for in range [0,11]:
if x=y
print x+y
else:
Print x-y
10. What is the output of the following? (1)
i=1
while True:
if i%3 == 0:
break
print(i)
11. How many times the following loop will execute (1)
true = False
i = 10
while true:
print("DPS")
i -=2
12. What is invalid for, else statement used with a for loop-? (1)
a) It can also be used with a conditional control structure.
b) The statement under it will be executed when control is leaving the loop
as a result of a break statement
c) The else is executed when the control object’s values are not within the range.
d) The else part in a for statement can be omitted
13. Which numbers are printed? (1)
for i in range(2):
print (i)
for i in range(4,6):
print (i)
14. Complete the following code to reverse a number: (1)
n=int(input(“Enter the number:”))
rev=0
while :
x=
rev=
n=
print(“Reverse number=”,rev)
15. Draw a flowchart to enter a person's age and find whether he can cast a vote. The
minimum age limit is 18. (2)
16. Write a program to accept a number and display whether the number is a Even or
Odd (2)
17. Write a program to find the sum of all odd numbers from 1 to 30. (1)
18. Following code is meant to be an interactive grade calculation script that converts (2)
from a percentage into a letter grade:
90 and above is A+,
80-90 is A,
60-80 is A-,
and everything below is failed.
Write the program to display grade of a user?
19. Write a program to take an integer a as an input and check whether it ends with 4 or 8.
If it ends with 4, print “ends with 4”, if it ends with 8, print “ends with 8”, otherwise print
“ends with neither” (2)

20. Write a program to display all the prime numbers between a given range of
numbers entered by the user. (2)

*****

You might also like