Monday, 7 November 2022

CS3351 Digital Principles and Computer Organisation Question Bank

 CS3351 Digital Principles and Computer Organisation 

CS3351 Digital Principles and Computer Organisation Question Bank


CS3351 Digital Principles and Computer Organization Study Materials

Anna University – CS3351 Digital Principles and Computer Organization Regulation 2021 Syllabus, Notes, Important Questions, Question Paper with Answers, Previous Year Question Paper.

UNIT I COMBINATIONAL LOGIC CS3351 Digital Principles and Computer Organization Syllabus

Combinational Circuits – Karnaugh Map – Analysis and Design Procedures – Binary Adder – Subtractor – Decimal Adder – Magnitude Comparator – Decoder – Encoder – Multiplexers – Demultiplexers

UNIT II SYNCHRONOUS SEQUENTIAL LOGIC CS3351 Digital Principles and Computer Organization Notes

Introduction to Sequential Circuits – Flip-Flops – operation and excitation tables, Triggering of FF, Analysis and design of clocked sequential circuits – Design – Moore/Mealy models, state minimization, state assignment, circuit implementation – Registers – Counters.

UNIT III COMPUTER FUNDAMENTALS CS3351 Digital Principles and Computer Organization Important Questions

Functional Units of a Digital Computer: Von Neumann Architecture – Operation and Operands of Computer Hardware Instruction – Instruction Set Architecture (ISA): Memory Location, Address and Operation – Instruction and Instruction Sequencing – Addressing Modes, Encoding of Machine Instruction – Interaction between Assembly and High Level Language.

UNIT IV PROCESSOR CS3351 Digital Principles and Computer Organization Questions Paper

Instruction Execution – Building a Data Path – Designing a Control Unit – Hardwired Control, Microprogrammed Control – Pipelining – Data Hazard – Control Hazards.

UNIT V MEMORY AND I/O CS3351 Digital Principles and Computer Organization Question Bank

Memory Concepts and Hierarchy – Memory Management – Cache Memories: Mapping and Replacement Techniques – Virtual Memory – DMA – I/O – Accessing I/O: Parallel and Serial Interface – Interrupt I/O – Interconnection Standards: USB, SATA

Monday, 3 October 2022

Ex2. Working with Numpy arrays

 Ex2. Working with Numpy arrays

Aim:

         Working with different instructions used in Numpy array

Procedure

ü Do the following function

ü To print the array print(a)

ü To print the shape of the array print(a.shape)

ü To the function return the number of dimensions of an array. print(a.ndim)

ü This data type object (dtype) informs us about the layout of the array. print(a.dtype.name)

ü This returns the size (in bytes) of each element of a NumPy array print(a.itemsize)

ü This is the total number of elements in the ndarray. print(a.size)

 

Program

import numpy as np

a = np.arange(15).reshape(35)

To print the array

print(a)

To print the shape of the array

print(a.shape)

To the function return the number of dimensions of an array.

print(a.ndim)

This data type object (dtype) informs us about the layout of the array

print(a.dtype.name)

This returns the size (in bytes) of each element of a NumPy array

print(a.itemsize)

 This is the total number of elements in the ndarray.

print(a.size)

 

 

arr = np.array([12345678])

x = np.where(arr%2 == 1)

print(x)

Slice elements from index 1 to index 5 from the following array

print(arr[1:5])

Get third and fourth elements from the following array and add them.

print(arr[2] + arr[3])

 

Write a NumPy program to convert the values of Centigrade degrees into Fahrenheit degrees and vice versa. Values are stored into a NumPy array.

import numpy as np

fvalues = [0, 12, 45.21, 34, 99.91, 32]

F = np.array(fvalues)

print("Values in Fahrenheit degrees:")

print(F)

print("Values in  Centigrade degrees:")

print(np.round((5*F/9 - 5*32/9),2))

6 a). Apply and explore various plotting functions on UCI data sets. Density and contour plots

 6 a). Apply and explore various plotting functions on UCI data sets. Density and contour plots

Aim

          To apply and explore various plotting functions like Density and contour plots on datasets.

Procedure

There are three Matplotlib functions that can be helpful for this task: plt.contour for contour plots, plt.contourf for filled contour plots, and plt.imshow for showing images

A contour plot can be created with the plt.contour function. It takes three arguments: a grid of x values, a grid of y values, and a grid of z values.

The x and y values represent positions on the plot, and the z values will be represented by the contour levels.

Perhaps the most straightforward way to prepare such data is to use the np.meshgrid function, which builds two-dimensional grids from one-dimensional arrays.

Next standard line-only contour plot and for color the lines can be color-coded by specifying a colormap with the cmap argument. 

Additionally, we'll add a plt.colorbar() command, which automatically creates an additional axis with labeled color information for the plot.

Program

%matplotlib inline

import matplotlib.pyplot as plt

plt.style.use('seaborn-white')

import numpy as np

def f(x, y):

    return np.sin(x) ** 10 + np.cos(10 + y * x) * np.cos(x)

x = np.linspace(0, 5, 50)

y = np.linspace(0, 5, 40)

X, Y = np.meshgrid(x, y)

Z = f(X, Y)

plt.contour(X, Y, Z, colors='black');

Output

 

plt.contour(X, Y, Z, 20, cmap='RdGy');

Output

plt.contourf(X, Y, Z, 20, cmap='RdGy')

plt.colorbar();

Output

Result

Various plotting functions like Density and contour plots on datasets are successfully executed.

6 b). Apply and explore various plotting functions like Correlation and scatter plots on UCI data sets

 6 b). Apply and explore various plotting functions like Correlation and scatter plots on UCI data sets

Aim

          To apply and explore various plotting functions like Correlation and scatter plots on datasets.

Procedure

Program

import pandas as pd

con = pd.read_csv('D:/diabetes.csv')

con

list(con.columns)

import seaborn as sns

sns.scatterplot(x="Pregnancies", y="Age", data=con);

Output

sns.lmplot(x="Pregnancies", y="Age", data=con);

Output

sns.lmplot(x="Pregnancies", y="Age", hue="Outcome", data=con);

Output

from scipy import stats

stats.pearsonr(con['Age'], con['Outcome'])

Output

(0.23835598302719774, 2.209975460664566e-11)

cormat = con.corr()

round(cormat,2)

sns.heatmap(cormat);

Output

Result

Various plotting functions like Correlation and scatter plots on datasets

are successfully executed.

6 c. Apply and explore histograms and three dimensional plotting functions on UCI data sets

 6 c. Apply and explore histograms and three dimensional plotting functions on UCI data sets 

Aim

          To apply and explore histograms and three dimensional plotting functions on UCI data sets 

Procedure

ü Download CSV file and upload to explore.

ü  A histogram is basically used to represent data provided in a form of some groups.

ü  To create a histogram the first step is to create bin of the ranges, then distribute the whole range of the values into a series of intervals, and count the values which fall into each of the intervals.

ü Bins are clearly identified as consecutive, non-overlapping intervals of variables.The matplotlib.pyplot.hist() function is used to compute and create histogram of x. 

ü The first one is a standard import statement for plotting using matplotlib, which you would see for 2D plotting as well.

ü The second import of the Axes3D class is required for enabling 3D projections. It is, otherwise, not used anywhere else.

 

Program

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt  # To visualize

from mpl_toolkits.mplot3d import Axes3D

data = pd.read_csv('d:\\diabetes.csv')

data

data['Glucose'].plot(kind='hist')

Output

fig = plt.figure(figsize=(4,4))

ax = fig.add_subplot(111, projection='3d')

Output

fig = plt.figure()

ax = fig.add_subplot(111, projection='3d')

x = data['Age'].values

y = data['Glucose'].values

z = data['Outcome'].values

ax.set_xlabel("Age (Year)")

ax.set_ylabel("Glucose (Reading)")

ax.set_zlabel("Outcome (0 or 1)")

ax.scatter(x, y, z, c='r', marker='o')

plt.show()

Output

 

 

 

Result

The histograms and three dimensional plotting functions on UCI data sets  are successfully executed.

Saturday, 1 October 2022

5 c. Use the diabetes data set from UCI and Pima Indians Diabetes data set for performing the following: Multiple Regression

 5 c. Use the diabetes data set from UCI and Pima Indians Diabetes data set for performing the following: Multiple Regression

Aim

Multiple regression is like linear regression, but with more than one independent value, meaning that we try to predict a value based on two or more variables.

Procedure 

The Pandas module allows us to read csv files and return a DataFrame object.

Then make a list of the independent values and call this variable X.

Put the dependent values in a variable called y.

From the sklearn module we will use the LinearRegression() method to create a linear regression object.

This object has a method called fit() that takes the independent and dependent values as parameters and fills the regression object with data that describes the relationship. 

We have a regression object that are ready to predict age values based on a person  Glucose and BloodPressure

Program

import pandas as pd

from sklearn import linear_model

df = pd.read_csv (r'd:\\diabetes.csv')

print (df)

X = df[['Glucose', 'BloodPressure']]

y = df['Age']

regr = linear_model.LinearRegression()

regr.fit(X, y)

predictedage = regr.predict([[150, 13]])

print(predictedage)


Output


[28.77214401]


5 b. Linear Regression and Logistic Regression with the Diabetes Dataset Using Python Machine Learning

 5 b. Linear Regression and Logistic Regression with the Diabetes Dataset Using Python Machine Learning

Aim

In this experiment we use the diabetes dataset from sklearn and then we need to implement the Linear Regression over this:


Procedure

Load sklearn Libraries.

Load Data

Load the diabetes dataset

Split Dataset

Creating Model Linear Regression and Logistic Regression

Make predictions using the testing set

Finding Coefficient And Mean Square Error


Program

import matplotlib.pyplot as plt

import pandas as pd

import numpy as np

from sklearn import datasets, linear_model

from sklearn.metrics import mean_squared_error, r2_score

from sklearn.linear_model import LogisticRegression

from sklearn.model_selection import train_test_split


#To calculate accuracy measures and confusion matrix

from sklearn import metrics


diabetes_X, diabetes_y = datasets.load_diabetes(return_X_y=True)


diabetes_X = diabetes_X[:, np.newaxis, 2]


# Split the data into training/testing sets

diabetes_X_train = diabetes_X[:-20]

diabetes_X_test = diabetes_X[-20:]


# Split the targets into training/testing sets

diabetes_y_train = diabetes_y[:-20]

diabetes_y_test = diabetes_y[-20:]


# Create linear regression object

regr = linear_model.LinearRegression()



# Train the model using the training sets

regr.fit(diabetes_X_train, diabetes_y_train)



# Make predictions using the testing set

diabetes_y_pred = regr.predict(diabetes_X_test)


# Create Logistic regression object

Logistic_model = LogisticRegression()

Logistic_model.fit(diabetes_X_train, diabetes_y_train)


# The coefficients

print('Coefficients: \n', regr.coef_)

# The mean squared error

print('Mean squared error: %.2f'

      % mean_squared_error(diabetes_y_test, diabetes_y_pred))

# The coefficient of determination: 1 is perfect prediction

print('Coefficient of determination: %.2f'

      % r2_score(diabetes_y_test, diabetes_y_pred))


y_predict = Logistic_model.predict(diabetes_X_train)

#print("Y predict/hat ", y_predict)

y_predict



Output

Coefficients: 

 [938.23786125]

Mean squared error: 2548.07

Coefficient of determination: 0.47


CCS 365 Software Defined Network Lab Manual

 CCS 365 Software Defined Network Lab Manual 1) Setup your own virtual SDN lab i) Virtualbox/Mininet Environment for SDN - http://mininet.or...