You are on page 1of 6

REG.

NO
SRM Institute of Science and Technology
Mode of Exam
College of Engineering and Technology
OFFLINE
School of Computing
DEPARTMENT OF COMPUTING TECHNOLOGIES
SRM Nagar, Kattankulathur – 603203, Chengalpattu District, Tamil Nadu
Academic Year: 2022-2023(ODD)

Test: CLAT- 3
Course Code & Title: 21CSS101J / Programming for Problem Solving Duration:20 min
Year & Sem:I / I Max. Marks20
Course Learning Rationale (CLR)
CLR-5: Create basic Abstract Data Types with python, create applications using suitable python library
functions for solving data science problems.
Course Learning Outcomes (CLO):
CLO-5: To create programs using the python data types, loops, control statements for problem solving.
To implement the suitable python library based solutions for solving statistical problems
COURSE ARTICULATION MATRIX (CAM)
PO1 PO2 PO3 PO4 PO PO6 PO7 PO8 PO9 PO10 PO1 PO12
5 1
C0 2 3 2
5
Part – A

(20 x 1 = 20 Marks)

Answer all the questions.

Q.N Questions Mark BL C P PI


o s O O

1. Choose the correct statement? 1 1 5 1 1.6.3

A. Python programs can be executed only by writing them into files.


B. Python source code is written and saved in a file with .py ex-
tension.
C. Runtime errors are like grammatical errors in English.
D. Python is a middle-level programming language.

2. Identify the false statement in python? 1 1 5 1 2.6.1

A. Python is an interpreted language.


B. A Python program can execute C and C++ programs also.
C. Sending an email is not possible by using Python.
D. A Python program written on Windows operating system will also
execute on Linux operating system as it is portable.

3. Select the correct statements 1 1 5 1 1.6.3

A. Python is a cross platform language.


B. In Mathematics we are unable to use Python.
C. Python is not sufficient to implement web based development.
D. By using Python we cannot implement GUI.

4. Relate the argument specifiers for integers in hexadecimal. 1 2 5 1 2.6.1

A. %s
B. %f
C. %x or %X
D. %o

5. Find the statement wrong about Identifier in python? 1 1 5 1 1.6.3


A. Identifiers are used for identifying entities in a program.
B. 1st_string is a valid identifier.
C. string_1 is valid identifier.
D. Identifiers can be of any length.

6. Choose the wrong statement about Keywords in python? 1 1 5 1 2.6.1

A. The keyword nonlocal does not exist in Python 2.


B. A programmer can easily modify the keywords.
C. Interpreter raises an error when you try to use keyword as
a name of an entity.
D. Python version 3.5 has 33 keywords.

7. The association of a value to a variable is called 1 1 5 1 2.6.1


as _____________________

A. Assignment statement
B. Iterative statement
C. Function declaration statement
D. Binding

8. _____________________ is a combination of an arithmetic or a binary 1 2 5 1 2.6.1


operation and an assignment operation in a single statement.

A. Simple assignment statement


B. Augmented assignment statement
C. Basic assignment statement
D. None of the above

9. Select the symbol used to represent the start of indentation in python? 1 3 5 1 2.6.1

A. #
B. &
C. :
D. %

10.Numpy provides support to ___________ dimensional arrays. 1 2 5 1 2.6.1

A. Three
B. Two
C. Multi
D. One

11.Fill the syntax for complex function 1 3 5 1 1.6.3

A. complex(x)
B. complex(real,imag)
C. complex (x,base)
D. complex()

12.Choose the correct statement for import Numpy? 1 3 5 1 1.6.3

A. import numpy as mp

B. import numpy as um

C. import numpy as np

D. import numpy as py

13.The most frequently occurring value is called as _____________ 1 1 5 1 1.6.3

A. arithmetic mean

B. percentile

C. mode
D. Median

14.Find the quartiles to calculate the distribution? 1 3 5 1 1.6.3

A. 5

B. 3

C. 4

D. 2

15.____________ is the process of retrieving elements from one index to 1 2 5 1 1.6.3


another.

A. Slicing

B. Binding

C. Indexing

D. Reverting

16.Google Colaboratory is mostly not suitable for _______________ 1 2 5 1 1.6.3

A. Machine Learning

B. Artificial Intelligence

C. Data Analytics

D. Large datasets

17.Inspect length of an array 1 3 5 3 2.5.2

import numpy as np

arr = np.array([[10,20,30], [40,50,60]], dtype=np.int64)

print(len(arr))

A. 5

B. 2

C. 3

D. 1

18.Mentionthe library used for scientific computations? 1 3 5 1 1.6.3

A. Pandas

B. Numpy

C. SciPy

D. Scikit-learn

19.Amongst which Python library is similar to Pandas? 1 2 5 1 1.6.3

A. Npy

B. Rpy

C. NumPy

D. None of these
20.Match the output for the given code. 1 3 5 2 2.6.1

print("where", "there", "is", "a", "will,", "there", "is", "a", "way")

A. Where there is a will there is a way.


B. Where there is a will There is a way
C. where there is a will, there is a way
D. where there is a will, there is a way.

Part – B
(10 x 2 = 20 Marks)
Answer all the questions.
Q.No Questions Marks BL CO PO PI
21. Sketch the code to print the magic word Abracadabra, 7 times, using the 2 3 5 2 2.6.1
repeat character (*).
print("Abracadabra" * 7);
22. Add the print statements in the below code to print the one-line 2 3 5 3 2.6.1
docstring for add() method and the multi-line
docstring of power() method.
def add(a, b):
"""Return sum of given arguments."""
return a + b
def power(b, e):
"""Return the power value.
b -- is the base
e -- is the exponent
"""
return b ** e
# print docstring of add method
print(add.__doc__)
# print docstring of power method
print(power.__doc__)
23. Fill in the missing code as per the instructions given in comments 2 3 5 2 1.6.3
#in the below line, initialize a variable called length with
value 18
length=18
#in the below line, initialize a variable called snake with
text "King Cobra"
snake="King Cobra"
#Make no changes to the below line
print(snake, "can grow up to a length of", length, "feet")
24. Build the code to assign the integer 999, float 24.789 and string "Python 2 3 5 3 2.6.1
Interpreter" to three variables using multiple assignment and print them
individually.
value1, value2, value3=999,24.789,"Python
Interpreter"
print(value1)
print(value2)
print(value3)

25. Design a python program to do the following. 2 3 5 3 1.6.3


i) Create a variable message and assign "Welcome to Python"
to it.
ii) Print the variable message.
iii) Create a variable number and assign 45 to it.
iv) Add 5 to the variable number by using number = number +
5.
v) Print the variable number.
name="Hello Programmer! Welcome to the Python
world."
print(name)
num=45
num=num+5
print(num)
26. Explain indexing and slicing in Numpy array? 2 3 5 2 2.6.1
Indexing:
Contents of ndarray object can be accessed and
modified by indexing or slicing, just like Python's in-
built container objects. Items in ndarray object follows
zero-based index. Three types of indexing methods are
available − field access, basic slicing and advanced
indexing.
Basic slicing is an extension of Python's basic concept of
slicing to n dimensions. A Python slice object is
constructed by giving start, stop, and step parameters
to the built-in slice function. This slice object is passed
to the array to extract a part of array.
Slicing:
Slicing in python means taking elements from one
given index to another given index.
We pass slice instead of index like this: [start:end].
We can also define the step, like this: [start:end:step].
If we don't pass start its considered 0
If we don't pass end its considered length of array in
that dimension
If we don't pass step its considered 1
27. Find the output of the following program? 2 4 5 2 2.6.1
import numpy as np
arr = np.array([[10,20,30,40,50],[60,70,80,90,100]])
print(arr[:,-1:-3:-1])
Output:
[[ 50 40]
[100 90]]
28. Identify the output of the below program? 2 4 5 3 2.6.1
import pandas as pd
import numpy as np
data = np.array([10,30,20])
series = pd.Series(data)
print(series[0])
print(series[2])
print(series[1])
Output:
10
20
30
29. Detect the output of the below code to clip the max_limit and 2 4 5 3 2.6.1
min_limit?
import numpy as np
a = [1,2,7]
b = [4,3,6]
limiting_a = np.clip(a,0,9)
limiting_b=np.clip(b,0,5)
print("Limiting a between 0 and 9:",limiting_a)
print("Limiting b between 0 and 5:",limiting_b)
Output:
Limiting a between 0 and 9: [1 2 7]
Limiting b between 0 and 5: [4 3 5]
30. Script the program to create an array range of 10 from python using 2 4 5 3 2.6.1
Numpy.
import numpy as np
arr = np.array(range(10))
print(arr)
Output: [0 1 2 3 4 5 6 7 8 9]
Part –C
(1x10=10)
Answer all the question
1. Take two inputs from the user using the input() function, one is the gender 10 4 3 10 2.5.2
of the person either M or F in string format and another one is the age of the
person in integer format. Write a simple program to see whether the given
person is eligible for concession or not and print the result as shown in the
constraint:
(i) If the person is male and age >=65, Eligible for concession.
(ii) If the person is female and age >= 60, Eligible for concession.
(iii) In all other cases, the person is not eligible for concession.
Expected Output:
Sample Input and Output 1:M(male) or F: F
age: 70
Eligible for Concession
Sample Input and Output 2:M or F: M
age: 63
(iv) Not Eligible for Concession
Answer:
g=input("M or F: ")
age=input("age: ")
if((g == 'M')and(age >= '65')):
print("Eligible for Concession")
elif((g == 'F')and(age >= '60')):
print("Eligible for Concession")
else:
print("Not Eligible for Concession")
OR
2. Use the following functions appropriately in your program to implement the 10 4 3 10 2.6.1
statistical operations
i) Aggregate function
ii) Minimum, maximum & sum function
iii) Standard Deviation
iv) Variance
v) Quartile (Q1, Q2, Q3)

You might also like