Posts

University Question Papers and Answer Keys Programming in Python CST 362 KTU

BTech Examinations S6 May 2026 QP    

numpy assignment

  1.Create a NumPy array of integers from 10 to 50. Print: shape data type size 2.Create a 5×5 matrix filled with zeros, then set the border elements to your roll number . 3.Create a 4×4 identity matrix and multiply it by 5. 4.Create two random arrays of size (3,3) and: ( use np.random.randint() function) add them subtract them multiply element-wise 5.Create a 1D array of numbers from 1–20. Reshape it into: (4,5) (5,4) 6.Create a 6×6 matrix with numbers from 1 to 36. Extract: first 2 rows last 2 columns center 2×2 block 7.From the above matrix, extract all even numbers. 8.Replace all values greater than 20 with 0. ( use np.where) 9.Reverse a 1D array using slicing (no loops). 10.Create a matrix and swap its first and last rows. 11.Generate 50 random numbers. Find: mean median standard deviation minimum & maximum 12.Create a 5×4 random matrix. Find: row-wise mean column-wise mean 13.Normalize a 1D array using: ( x − m e a n ) / s t d (x - mean) / std 14. Find the index of: l...

Assignment- plotting-1

Create a single pdf file with question and output and share it in group. File name rollno-name  1.Create a matplotlib plot with two lines representing the functions y=sin(x) for 0≤x≤2π (use a solid line) and y=cos(x) for 0≤x≤2π (use a dashed line). Customize the plot by adding appropriate ticks, labels for the x and y axes, and a legend to distinguish between the two functions. Set the title   “RollNo   Name”.   2.Plot the function y=x^2 and y=sig(x)     as two separate graphs with suitable legends, labels and a Title with your roll number and name. Lean about sigmoid function. Popular function used as activation function in machine learning https://en.wikipedia.org/wiki/Sigmoid_function   3.Write a Python program to plot the bar graph to depict the popularity of various programming languages. Label the graph with x-axis, y-axis, x-ticks,y-ticks, legend and title your roll number and name. Data : Programming languages: Python, C++, ...

Interfaces in Python

An abstract class and interface appear similar in Python. The only difference in two is that the abstract class may have some non-abstract methods, while all methods in interface must be abstract, and the implementing class must override all the abstract methods. Rules for implementing Python Interfaces We need to consider the following points while creating and implementing interfaces in Python  Methods defined inside an interface must be abstract. Creating object of an interface is not allowed. A class implementing an interface needs to define all the methods of that interface. In case, a class is not implementing all the methods defined inside the interface, the class must be declared abstract. Ways to implement Interfaces in Python We can create and implement interfaces in two ways − Formal Interface Informal Interface Formal Interface Formal interfaces in Python are implemented using abstract base class (ABC). To use this class, you need to import it from the abc module. Examp...