Professional Documents
Culture Documents
Assign CS
Assign CS
Page 1 of 9
b) Consider the following Python program: n=int(input(“Enter N:”) 2
i=1 sum=0 while(i<n):
if(i%2==0):
sum = sum+i
i=i+1 print(sum)
What will be the output when the input value is (i) 5 (ii) 0
(i) Write the SQL command to create the above table with constraints. 1
(ii) Insert 2 records with relevant information, in the table student 1
(iii) Display all the records of the table Student. 1
(iv) Delete the Student Whose Roll no is 100. 1
(v) Change the Stream of Student to ‘Computer’ Whose Roll no. is 536. 1
(vi) Add one column email of data type VARCHAR and size 30 to the table student. 1
Q7: Answer the question based on the table given below:
Page 2 of 9
(a) To list the names all the patients admitted after 15/01/98. 1
(b) To list the names of female patients who are in ENT department. 1
(c) To list names of all patients with their date of admission in ascending order. 1
(d) To display Patient’s Name, Charges, Age for only female patients. 1
(e )Find Out the Output of Following SQL Command:-
(i) Select COUNT(DISTINCT charges) from HOSPITAL; 1
(ii) (ii) Select MIN(Age) from HOSPITAL where Sex="F"; 1
Q8 (a) What is the difference between math.abs() and math.fabs()?
Give Example. 2
(b) What is String? How do you create a string in Python? 2
(c) Write a program to check whether entered string is palindrome or not. 3
(d)Refer the following code and predict the output [4x1/2=2]
a=[1,2,3]
b=[4,5,6]
c=a*b
d=c[0:3
]
e=d
a[5]=10
c[1]=20
e[0]=30
(i) Print e (ii) print a (iii) print d (iv) print c
e) Write a python program to receive the numbers from user through keyboard until user gives 0
(to end the input process), then the program calculate and display the sum of given odd numbers
and even numbers respectively.e.g.
if the user gives the following sequence of numbers: 7 5 10 14 3 9 11 12
Page 3 of 9
Then the output should be as follows:
The Sum of even numbers in given input sequence = 36
Page 4 of 9
g) What will be the output of the following?
def func(x):
print (x**3)
func(4) (1 mark)
h) Apply strip() to the following string:
s = ‘ aaa bbb ccc ddd ’ (1 mark)
i) If you are given the phone numbers of a class of students how would you store it and in what
datatype? (2 marks)
j) The following code is supposed to remove numbers less than 5 from list n, but there is a bug.
Fix the bug and underline each correction made by you. n =
[1,2,5,10,3,100,9,24]
for e of n:
if e>5:
n.remove(e)
print e (3 marks)
k) Demonstrate the use of exception handling in python. (4 marks)
10.Answer the following questions:
l) Differentiate between ceil( ) and floor( ). (1 mark)
m) Write the output produced by this program below.
x=3
if x!=2 :
print (‘First’)
else :
print (‘Second’)
if 2 > x:
print (‘Third’)
print (‘Fourth’)
print (‘Fifth’) (2 marks)
n) Find the error in the following program.
line = “its my world’
print (“You typed”, line)
line = line * “h”
num = int(line)
print (“You typed the number “, num) (3 marks)
o) Draw a flowchart to calculate greatest of three entered numbers. (4 marks)
11.Answer the following questions:
Page 5 of 9
p) Write one function performed by School Management System. (1 mark)
q) Define Booting. (1 mark)
r) Write three differences between Bluetooth and Infrared. (3 marks)
s) Write a short note on Third Generation of Computers. (3 marks)
Q12(a) How many types of strings are supported in Python. 1
(b) What are datatypes? 1
(c) What is the difference between a keyword and an identifier? 1
(d) Draw XOR gate using minimum number of NAND gate. 2
(e) What is a function call IN PYTHON? Give Example. 2
(f) Write the Python code to create the dictionary to include the list of following countries
and their capital. 2
Srilanka Colombo
Bangladesh Dhaka
India New Delhi
Pakistan Islamabad
Q13(a) Write a program in python to find out smaller of two numbers. 2
(b) What will be the output of the following- 1
(i) print(len(str(17//4)))
(ii) print(len(str(17/4)))
(c) Write pseudo-code / flowchart to input the year and to test and display whether the given
year is leap year or not? 3
(d)Write python program to calculate area of rectangle. 2
(e)Given the following python code what values are printed as output? 2
def afunc(B):
B=B%2
Print B
A=2
afunc(A)
afunc(A+5)
Print A
Q14: a) What is the significance of an empty statement? 1
b) Differentiate between compiler and interpreter. 2
c) Write a program to illustrate the difference between break and continue statements. 2
d) What are the benefits of using cloud computing (any two)? 2
e) Write a python script to generate divisors of a number. 2
Q 15: Answer the following questions-
(a)What is the function performed by len() and reverse() in the list module. 2
(b) Find error in the given SQL code: (Consider the table: ADM ) 1
insert into values {“admin”,”write”};
Q16: Answer the following Questions:
(a) Convert: 2
A) (434.05)10 = (?)16
B) (523)8 = (?)2
Page 6 of 9
TB , Byte, KB, Nibble, PB, MB, GB 1
(c) What is a database system? What is its need. 1
Q17: Answer the following Questions:
a) Describe following Cybercrimes:
(i) Cyber Bullying (ii) Cyber Stalking 2
b) What is Cracking? Suggest the ways to protect the computer from cyber attack. 2
c) Define eavesdropping and phishing . 2
d) What measures should one take to avoid and maintain confidentiality of personal
information? 2
e) What are the tips to safely browse the internet. 2
18 a) What is cyber stalking? 1
b) What do you understand by identity theft? 1
c) How is phishing different from pharming? 2
d) Explain the terms spyware and malware. 2
e) What is cybercrime? How can you report it? 2
f) What is eavesdropping? 2
Q19 (a) What is the length of the tuple shown below?
T = ((((‘a’,1) , ‘b’ , ‘c’), ‘d’, 2), ‘e’, 3) 2
(b) Write a program to check whether entered string is palindrome or not. 3
(c) Refer the following code and predict the output [4x1/2=2]
a=[1,2,3] b=[4,5,6]
c=a*b d=c[0:3]
e=d a[5]=10
c[1]=20
e[0]=30
(i) Print e (ii) print a (iii) print d (iv) print c
e) Write a python program rotates the element of a list so that the element at the first index moves
to the second index, the element in the second index moves to the third index, etc., and the element
in the last index moves to the first index..
[4]
Section-A
20. (a) What does a cross platform language mean? 1
(b) Which of the following are valid and invalid strings in python? 2
(i) “python” (ii) ‘python’ (iii) “python’ (iv) {python}
(c) What are Identifiers? 1
(d) What is the difference between == and =? Explain with example. 2
(e) What are mutable and immutable data types? Give two examples of each 2
(f) What is None literal in python? 1
21 (a) Differentiate between a syntax error and a semantic error with example. 2
(b) Which arithmetic operator(s) can be used with strings? 1
Page 7 of 9
(c) Find the output of the following code: x= “hello world” 3
print (x[ : 2], x[ : -2], x[-2 : ])
print (x[ 6 ], x[2 : 4])
print (x[ 2 : -3], x[ -4 : -2])
22 a) Write the name of the function used to calculate the length of list and tuples? 1
b) Write a program in python to find maximum element in the list entered by the user. 2
c) Write a program in python to create a dictionary containing names of competition 3
winner students as keys and number of medals as values.
Section-B
23 a) What is the difference between RAM and ROM? 1
b) What is a language processor? Write the name of two language processors. 2
c) How many possible code groups can be formed by ASCII code (ASCII is a 7 bit code) ? 1
d) Convert the following: 2
(i) (4A)16=( )2
(ii) (106)10=( )8
Table: SPORTS
Studno Class Name Game1 Grade1 Game2 Grade2
10 7 Sameer Cricket B Swimming A
11 8 Sujit Tennis A Skating C
12 7 Kamal Swimming B Football B
13 7 Venna Tennis C Tennis A
14 9 Archana Basketball A Cricket A
15 10 Arpit Cricket A Atheletics C
1) Display the names of the students who have grade ‘C’ in either Game1 or Game2
2) Display the names of students getting grade ‘A’ in Cricket.
3) Display the games taken up by the students, whose name starts with ‘A’.
4) Add a new column named ‘Marks’ of int type in the sports table.
5) Insert a new row in the table with the following data (16, 10, “Mohan”, “Cricket”,
“B”, “Tennis”, “A”)
6) Delete the row from the student table whose Studno is 12.
Page 9 of 9