Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

STELLA MARIS COLLEGE (AUTONOMOUS), CHENNAI – 600 086

MASTER OF SCIENCE (INFORMATION TECHNOLOGY)


(For candidates admitted during the academic year 2019 – 2020 and thereafter)
M.Sc. (Information Technology) DEGREE EXAMINATION
FIRST SEMESTER
SUBJECT CODE: 19CS/PC/PP14 MARKS: 50
SUBJECT: PROGRAMMING WITH PYTHON DURATION: 90 MINS

SECTION A (5 X 2 = 10)
ANSWER ALL THE FOLLOWING
1. What is the output of the following code?

Write the code to swap two numbers using simultaneous assignment.


2. Explain condition expression with the following example.
x, y, z = eval(input("Enter three numbers: "))
print("True" if x < y and y < z else "False")
3. Explain how to achieve data hiding in python.
4. Write the code to get the following output.

5. List the steps required to write a text to a file in python.


SECTION B (4 X 5 = 20 marks)
ANSWER ANY FOUR OF THE FOLLOWING
6. What are the results of the following expressions? Give the reasons for the results.

7. A. Explain the code given. Debug the errors if any and write the output.
b. Explain range function with appropriate examples.
8. Explain the concept involved in the following diagram with respect to classes and
objects.

9. Compare the performance of sets and lists.

10. Write a program for the following lottery game. The program randomly generates a two-
digit number(r), prompts the user to enter a two-digit number(u), and determines the amount
won by the user using the following rule:
a. If the user’s input matches the lottery in the reverse order, the award is Rs. 10,000.

11. Write the code to draw a square using turtle and explain.

SECTION C (2 X 10 = 20 marks)
ANSWER ANY TWO OF THE FOLLOWING
12. Explain the following with examples.
a) try except block b) mutable and immutable objects
13. Answer all the following.
a. Suppose a function header is as follows. (2.5 marks)
def f(p1, p2, p3, p4):
Which of the following calls is/are correct? Justify.
f(1, p2 = 3, p3 = 4, p4 = 4)
f(1, p2 = 3, 4, p4 = 4)
f(p1 = 1, p2 = 3, 4, p4 = 4)
f(p1 = 1, p2 = 3, p3 = 4, p4 = 4)
f(p4 = 1, p2 = 3, p3 = 4, p1 = 4)
b. Write the output of the following program and explain the output. (2.5 marks)
c. Explain call stack with an example program. (5 marks)
14. Write a program to count the number of occurrences of every word in a given string
“Python is easy and simple to learn. Python uses simple syntax. Everyone finds Py-
thon easy and fun to learn”

Expected sample output:


Python : 2,is : 1,easy : 2,and so on

You might also like