ASSIGNMENT
BASIC IT WORKSHOP( IT 202)
SESSION: SPRING 2020
SUBMITTED BY:
STUDENT NAME- ADESH RANJAN
ROLL NUMBER- BTECH/15115/18
BRANCH- ECE
SEMESTER- 4TH SEM (2ND YEAR)
MOBILE NO.-8210706330
EMAIL- [email protected]
1. Write the basic objective of IT Workshop.
The objective of IT workshop is to impact basic
computer usage and maintenance skill and introduce to
a suite of productivity tolls that will aid in day-to-day
activities.IT workshop works in learning-by-doing
mode.IT concentrates more on hand-on experience for
the participant rather theoretical classes. The IT
workshop prepare the participant to have a hand-on
exercise in maintaining and troubleshooting a PC by
themselves.
2.Write some important features of MAT lab.
MATLAB is very capable in field of data science and is
currently being widely applied in industries ranging from
insurance, finance ,energy , medical devices, industrial
automation, automotive, and aerospace in various purpose of
business-critical functions. With the recent iterations of
software platform being even more capable of learning
complex machine learning algorithm , its relevance in data
science is expected to increases as we explore application of
ML & AI in our daily lives.
3.Write a program to find addition ,subtraction ,
multiplication and division by assigning value to variables.
val1= 8;
val2= 4;
addition= val1+val2;
subtraction= val1- val2;
multiplication= val1*val2;
division= val1/val2;
OUTPUT:
val1= 8
val2= 4
addition= 12
subtraction=4
multiplication= 32
division=2
4.Write a program to find addition ,subtraction,
multiplication and division by inputting value of variables.
1.Addition program:
x=input(‘Enter first value’)
y=input(‘\n Enter second value’)
sum= x + y
OUTPUT:
Enter first value 12
x=12
Enter second value 14
y=14
sum= 26
2.Subtraction program:
x=input(‘Enter first value’)
y=input(‘\n Enter second value’)
sub=x – y
OUTPUT:
Enter first value 12
x=12
Enter second value 14
y=14
sub= -2
3.Multiplication program:
x=input(‘Enter first value’)
y=input(‘\n Enter second value’)
mul= x *y
OUTPUT:
Enter first value 12
x=12
Enter second value 14
y=14
mul=168
4.Division program:
x=input(‘Enter first value’)
y=input(‘\n Enter second value’)
div= x /y
OUTPUT:
Enter first value 12
x=12
Enter second value 14
y=14
div= 0.8571
5.Write a program to find root of a quadratic equation.
disp (‘For the equation ax^2+bx+c’)
a= input(‘Enter a: ‘);
b=input(‘Enter b: ‘);
c=input(‘Enter c: ‘);
D= b^2 -4*a*c;
if D<0
fprintf(‘The equation has no real root’)
elseif D==0
root= -b/(2*a);
fprintf(‘The equation has one root’)
fprintf(‘%.3f ‘,root)
else
r1=(-b+ sqrt(D))/(2*a);
r2=(-b –sqrt(D))/(2*a);
fprintf(‘The equation has two roots’)
fprintf(‘%.3f and %.3f’, r1,r2)
end
OR
p=[ 3 -2 -4]; %Quadratic equation 3x^2-2x-4=0
a= roots(p)
OUTPUT:
a=3
b=-2
c=-4
The equation has two roots
r1=1.5352
r2= - 0.8685
OR
a= 1.5352
-0.8685
6.Write a program to find roots of cubic equations/
polynomials.
p=[ ];
n=input(‘Enter the degree of polynomial’)
for r= 1:n
p(r)= input ([‘enter the x’ num2str(r)’coefficient’ ]);
end
a=roots(p)
OR
disp (‘For the equation ax^3+b^2+cx+d’)
a= input(‘Enter a: ‘);
b=input(‘Enter b: ‘);
c=input(‘Enter c: ‘);
d= input(‘Enter d: ‘);
p=[ a b c d];
r=root(p)
similarly, for any polynomial roots can be obtained.
OUTPUT:
Enter the degree of polynomial 3
n =3
enter the x1 coefficient 2
enter the x2 coefficient 4
enter the x3 coefficient 5
p= 2 4 5
a=
-1.0000+1.2247i
-1.0000-1.2247i
7.Write a program to find compound interest by
assuming required values.
P= 10000; %Principal amount
r= 0.05; %rate per annum
n=12; %compounded times per year
t=3; %number of years
A= double(P*(1+r/n)^(n*t)) %amount, or ending balance
OUTPUT:
A= 1.1615e+ 04
8.Write a program to find simple interest by assuming
required values.
P= 5000;
r = 5;
t= 10;
simple interest= (P*r*t)/100
OUTPUT:
simple interest= 2500
9.Write a program to plot a circle having radius 4cm.
f= @(R)plot(R*cos(0:.001:2*pi),R*sin(0:.001:2*pi));
f(4)
axis equal
OUTPUT:
10.Write a program to plot a graph for sin^2x +
cos^2x=1.
plot((cos(-1:0.01:1)).^2+(sin(-1:0.01:1)).^2)
axis equal
OUTPUT:
11. Write a program to plot a pie chart by assuming
required data.
X=[61 19 10 10]
Labels={‘computer system design’, ‘telecommunication’,
‘data processing’ , ‘other IT services’};
pie(X)
legend(labels)
title(‘IT JOB MARKET SEGMENTATION DURING COVID- 3.68
MILLION JOBS’)
OUTPUT:
12.Write a program to find addition of two matrices.
m= input(‘Enter number of rows:’);
n=input(‘Enter number of columns;’);
strn=[‘Enter elements for matrix A’]
for i=1:m
for j=1:n
str=[‘Enter element in row’num2str(i)’,col’ num2str(j)’:’];
A(i,j)= input(str);
end
end
%a=input(‘enter number of rows:’);
%b=input(‘enter number of columns:’);
strn=[‘Enter elements for matrix B’]
for i=1:m
for j=1:n
str=[‘Enter element in row’num2str(i)’,col’ num2str(j)’:’];
B(i,j)= input(str);
end
end
string=[‘Addition is’]
C=A+ B
OUTPUT:
Enter number of rows: 2
Enter number of columns: 2
Strn= ‘Enter elements for matrix A ‘
Enter element in row 1, col 1:1
Enter element in row1,col 2:1
Enter element in row 2, col 1: 1
Enter element in row 2, col 2: 1
Strn= ‘Enter elements for matrix B ‘
Enter element in row 1, col 1:1
Enter element in row1,col 2:1
Enter element in row 2, col 1: 1
Enter element in row 2, col 2: 1
String = ‘Addition is:’
C= 2 2
2 2
13.Write a program to find transpose of any matrix.
m= input(‘Enter number of rows:’);
n= input(‘Enter number of columns:’);
strn=[‘Enter elements for matrix A’]
for i=1:m
for j=1:n
str=[‘Enter element in row’num2str(i),’col’ num2str(j)’:’];
A(i,j)= input(str);
end
end
B=transpose(A)
OUTPUT:
Enter number of rows: 2
Enter number of columns: 2
Strn= ‘Enter elements for matrix A ‘
Enter element in row 1, col 1:1
Enter element in row1,col 2: 2
Enter element in row 2, col 1: 3
Enter element in row 2, col 2: 4
B= 1 3
2 4
14.Write a program to find multiplication of two matrices.
m= input(‘Enter number of rows:’);
n=input(‘Enter number of columns;’);
strn=[‘Enter elements for matrix T’]
for i=1:m
for j=1:n
str=[‘Enter element in row’num2str(i)’,col’ num2str(j)’:’];
T(i,j)= input(str);
end
end
%a=input(‘enter number of rows:’);
%b=input(‘enter number of columns:’);
strn=[‘Enter elements for matrix S’]
for i=1:m
for j=1:n
str=[‘Enter element in row’num2str(i)’,col’ num2str(j)’:’];
S(i,j)= input(str);
end
end
C=T*S
OUTPUT:
Enter number of rows: 2
Enter number of columns: 2
Strn= ‘Enter elements for matrix T ‘
Enter element in row 1, col 1:1
Enter element in row1,col 2: 2
Enter element in row 2, col 1: 3
Enter element in row 2, col 2: 4
Strn= ‘Enter elements for matrix S ‘
Enter element in row 1, col 1:4
Enter element in row1,col 2: 3
Enter element in row 2, col 1: 2
Enter element in row 2, col 2: 1
C= 8 5
20 13
15.Write a program to generate prime numbers up to
100.
n= input(‘Enter number upto which prime number is to be
filtered’);
p=primes(n)
OUTPUT:
Enter number upto which prime number is to be filtered 100
p=
Columns 1 through 16
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47
53
Columns 17 through 25
59 61 67 71 73 79 83 89 97
16.Write a program to generate odd numbers up to 100.
n = 1:2:100
OUTPUT:
n = Columns 1 through 16
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31
Columns 17 through 32
33 35 37 39 41 43 45 47 49 51 53 55 57 59
61 63
Columns 33 through 48
65 67 69 71 73 75 77 79 81 83 85 87 89 91
93 95
Columns 49 through 50
97 99
17.Write a program to find sum of the given series
1+x+x^2+……………+x^n (n>0)
x= input(‘enter value of variable x’)
n= input(‘Range of given series’)
syms k
SUM= symsum(x^k, k,[0 n])
OUTPUT:
enter value of variable x 1
x=1
Range of given series 100
n=100
SUM=101
18.Write a program to find the sum of the given series
x+ x^3+……………..+x^n (n>0)
x= input(‘enter value of variable x’)
n= input(‘Range of given series’)
syms k
SUM= symsum(x^(k*2-1),k,[1 n])
OUTPUT:
enter value of variable x 1
x=1
Range of given series 3
n=3
SUM=42
19.Write a program to find sum of a given series:
1 + (1/x) + (1/x^3)+……………+(1/x^n) (n>0).
x= input(‘enter value of variable x’)
n= input(‘Range of given series’)
syms k
SUM= symsum(1/x^(k*2-1),k,[1 n])
OUTPUT:
enter value of variable x 2
x=2
Range of given series 2
n=2
SUM= 5/8
20.Write a program to find the sum of any exponential
series.
x= input(‘enter value of variable x’)
n= input(‘Range of given series’)
syms k
SUM= double(symsum((x^k)/(factorial(k)),k,[0 n]))
OUTPUT:
enter value of variable x 3
x=3
Range of given series 10
n=10
SUM= 20.0797
21.Write some important features of the python language
lab.
*Python is Interpreted-python is processed at runtime by
the interpreter. We do not need to compile our program
before executing it. This is similar to PERL and PHP.
*Python is Interactive-we can actually sit at a python
prompt and interact with the interpreter directly to write our
programs.
*Python is Object-Oriented-python supports object-oriented
style or technique of programming that encapsulates code
within objects.
*Python is a Beginner’s language-python is a great
language for the beginner-level programmers and supports
the development of a wide range of appilications from
simple text processing to WWW browsers to games.
22.Write a program to find the sum of even number using
python.
s=0
n=input(“Enter number: “) #upto which sum has to find
for r in range (2,n,2):
s=s+r
print(s)
OUTPUT:
Enter number: 10
10
s= 30
23.Write a program to find the sum of odd number using
python.
s=0
n=input(“Enter number: “) #upto which sum has to find
for r in range (1,n,2):
s=s+r
print(s)
OUTPUT:
Enter number: 23
11
13
15
17
19
21
23
s= 144
24.Write a simple program for a calculator using python.
#Python program for a simple calculator
#Function to add two numbers
Def add(num1,num2);
Return num1+num2
#Function to subtract two numbers
Def subtract(num1,num2);
Return num1-num2
#Function to multiply two numbers
Def multiply (num1,num2);
Return num1*num2
#Function to divide two numbers
Def divide(num1,num2);
Return num1/num2
Print(“Please select operation -\n”\
“1.add\n”\
“2.subtract\n”\
“3.multiply\n”\
“4.divide\n”)
#Take input from the user
Select = int(input(“Select operation from 1,2,3,4:”))
number_1= int(input(“Enter first number:”))
number_2=int(input(“Enter second number: “))
if select==1:
print(number_1,”+”,number_2,”=”,add(number_1,number_2))
if select==2:
print(number_1,”-
”,number_2,”=”,subtract(number_1,number_2))
if select==3:
print(number_1,”*”,number_2,”=”,multiply(number_1,number_2
))
if select==4:
print(number_1,”/”,number_2,”=”,divide(number_1,number_2))
else:
print(“Invalid input”)
OUTPUT:
Please select operation-
1. Add
2. Subtract
3. Multiply
4. Divide
Select operations from 1,2,3,4: 1
Enter first number: 50
Enter second number: 100
50 + 100 = 150
25.Write a simple program to find inverse of a matrix
using python.
Matrix= [[1,2],[3,4]]
Print(numpy.linalg.inv(matrix))
OR
Import numpy as np
R= inp(input(“Enter the number of rows:”))
C=inp(input(“Enter the number of columns:”))
m= [ ] #initialize matrix
print(“Enter the entires rowwise:”)
#For user input
For I in range(R): #A for loop for row entries
a= [ ]
for j in range(C): #A for loop for column entries
a.append(int(input()))
m.append(a)
print(“Original matrix”)
print(m)
result= np.linalg.inv(m)
print(“Inverse of the said matrix:”)
print(result)
OUTPUT:
Enter the number of rows: 4
Enter the number of columns: 4
Enter the entires rowwise:
10
11
12
13
14
15
16
Original matrix:
[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]
Inverse of the said matrix:
[[3.94064967e+15 -4.50359963e+15 -2.81474977e+15
3.37769972e+15]
[-4.12829966e+15 4.50359963e+15 3.37769972e+15 -
3.75299969e+15]
[-3.56534971e+15 4.50359963e+15 1.68884986e+15
-2.62709978e+15]
[3.75299969e+15 -4.50359963e+15 -2.25179981e+15
3.00239975e+15]]
****************************************************************