CST283 Python For Machine Learning, December 2022
CST283 Python For Machine Learning, December 2022
PART A
I Write the rules to be followed for naming any variables in python. (3)
3 illustrate the concept of local and global variables in python with example. (3)
4. Writd a program that uses lambda function to multiply two numbers. (3)
5 What is a tuple? Explain the mutability of a tuple with suitable example. (3)
8 What is the difference between multiple and multilevel inheritance? Give an (3)
example. .-i
import numpy as np
array 1
=rp.array
(Il0,l2,l 4,1 6,18,20,22))
print(anayl [:5:2])
print(arrayl [-4:])
l0 Write a program to plot a range from I to 30 with step value 4. Use following (3)
algebraic expression to show data y :5*x*2.
Page lof3
0800csT283122102
PART B
t
Answer any onefull questionfrom each module. Each question carries 14 marks
Module I
l l a) examples.
Write the various logical and bitwise operator with (6)
12 a) Describe the arithmetic, identity and membership operators in Python with (7)
an examPle.
b) What is the difference between type conversion and type coercion? Give
suitable example. Also, write a program to convert temperature in degree (7)
* 9= Celsius))
Fahrenheit to Celsius. ((farenheit- 32) 5I
Module 2
13 a) Explain the use of return statement in function. Write a Python program (7)
using function to find the sum of first 'n' even numbers and return the
.
result to main Program.
b) Write python Program to reverse a number and also find the sum of digits (7)
Module 3
15 a) What is the difference between append and extend function of python (7)
lists? Write a python code to input n numbers and calculate sum of cubes
"
of each number and store it in a list.
b) Define dictionary with an example. What is the use of all0, anyO, cmpo (7)
Page 2of3
0800csr283t22r02
17 a) Describe the use of try and except block in python with example. Write a (6)
program to handle a divide by zero exception. Also add a finally block.
b) Create a class student with name, roll number, marks of 3 subjects and
19 a) Explain Data Analysis and Visualization in Python with suitable example. (8)
b) What are binary files? Write the different file opening modes.
(6)
module.
..;
Page 3of3