Sie sind auf Seite 1von 6

Worksheet

1. Draw a flowchart for finding the sum of n numbers

2.Write a pseudo- code to check if the number is positive or


negative or zero and display an appropriate message.
Ans:
Input a number
If number is greater than and equal to zero then check,
if number is ‘zero’ then display zero otherwise display
‘positive number’
Otherwise display negative number
3. What is the significance of an empty statement
Ans: An empty statement does nothing. In python , an empty
statement is a pass statement.
4. What is the difference between break and continue
statement?
Ans: Break and continue statements ae JUMP statements,
and can be used to alter he flow of loop.
Break statement terminates the loop and resumes execution
in the statement.
Continue statement skips the rest of the code inside a loop
and resumes execution in the statement.
5. Convert the following while loop into for loop:
x=5
while (x<10):
print (x+10)
x+=2
Ans:
for x in range (5,10,2):
print (x+10)
6. Write a python script to print the following pattern:
1
1 3
1 3 5
1 3 5 7

Ans:
for b in range (3,10,2):
for a in range(1,a,2):
print(b, end =’ ‘)
print( )

7. Which numbers are printed


for i in range(2) :
print i
for i in range( 4, 6):
print i
Ans:
0
1
4
5
8. Write SQL commands for questions on the basis of table
Library

a) Select all the PROG type published by BPB from Library.

b) Display a list of all books with Price more than 130 and
sorted by Qty.

c) Display all books sorted by Price in ascending order.

d) Count the number of books in above table. Fill all the


column with values.

e) Insert a new book in Library table. Fill all column with


valus.
f) Give the output of following SQL command on the basis
of table Library

1. Select MIN(Price) from Library where Price<150;

2. Select AVG(Price) from Library where Qty<3;

3. Select COUNT(DISTINCT Pub) from Library;


Ans:
Queries:
a) SELECT Type
FROM Library

WHERE(Type=”PROG” AND Pub=”BPB”);

b) SELECT Title “BOOKS”,

FROM Library

WHERE Price>130

ORDER BY Qty;

c) SELECT Title “BOOKS”,

FROM Library

ORDER BY Price ASC;

d) SELECT Count(Title)
FROM Library
WHERE Pub=‟PHI‟;

e) INSERT INTO Library

VALUES(“Exploring C”,”Yashwant”,”PROG”,”BPB”,3,230);

f) 1. 40

2. 145

3. 6

Das könnte Ihnen auch gefallen