FPT Lab Manual 2024 - Nep 2
FPT Lab Manual 2024 - Nep 2
College of Engineering
Bangalore-560 019
LAB MANUAL
(Subject Code
Code: 23IM4PCFPT)
IV SEMESTER – NEP 2
Prepared By:
Dr. B. Ravishankar
Prof. Mayur Appaiah
Dr. V.N. Shailaja
Dr. Kavitha Rani N.
Prof. Disha M. Nayak
Department of IEM IV Semester FPT Laboratory
1. Largest of 3 Nos.
2. Whether Given No. is a Palindrome or Not.
3. Check Whether Given No. is odd /even
4. Develop a program to sort the given set of numbers using Bubble sort
5. Develop a program that reads two matrices and Computes their product. Print
both the input and output matrices (suitable headings /Output in matrix format.)
6. To Write a Program for Fibonacci Series up to 30 terms
7. Bisection Method
8. False Position Method
9. Newton Raphson Method
10. Euler’s Method
11. Arduino Board Device (Demonstration Only)
12. Raspberry Pi Device (Demonstration Only)
Note:
1. List is Indicative only; the Course Instructor will decide the Programming Language to be used for
the above programs.
2. Program submissions include program code/algorithm /solved manual example/flowchart, etc.
Note: For all Experiments, some Theory has to be written - why the experiment is carried out,
background information, etc.
Largest of 3 Nos.
Aim: Write a Python Program to find the Largest of 3 Nos
Algorithm:
1. Start
2. Input A,B,C
3. If (A>B) and (A>C) then print “A is greater”. Else if (B>A) and (B>C) then print “B is greater”. Else print “C is
greater”.
4. Stop Flowchart
Flowchart:
Algorithm:
1: Start
2: Read the input number from the user
3: Declare and initialize the variable reverse and assign input to a temp variable tempNum=num
4: Start the while loop until num !=0 becomes false
rem = num % 10
reverse*= 10 + rem
num = num / 10
5 : Check if reverse == tempNum
6: If it’s true then the number is a palindrome
7: If not, the number is NOT a palindrome
8: Stop
Flowchart:
Algorithm:
1: Start
2: Read a number to N
3: Divide the number by 2 and store the remainder in R.
4: If R = O Then go to Step 6
5: Print “N is odd” go to step 7
6: Print “N is even”
7: Stop
Flowchart:
Develop a program to sort the given set of numbers using Bubble sort
Aim: Write a Python Program to sort the given set of numbers using Bubble sort
Algorithm: Flowchart:
1. Set N = Length of Array
2. Array[j] > Array[j + 1] (Decision)
if no - continue with the step 4
3. Swap Array[j] and Array[j+1]
4. Increment j (j++)
5. j < N - i - 1 (Decision)
if yes - continue with the step 2
6. Clear j (j = 0)
7. Increment i (i++)
8. i < N - 1 (Decision)
if yes continue with the step 2
9. Ordered Array
Algorithm:
1.Start.
2.Enter the value of m and n (or) order of the first matrix.
3.Enter the value of p and q (or) order of the second matrix.
4.Create a matrix of size a[m][n] and b[p][q].
5.Enter the element of matrices row-wise using loops.
6.If the number of columns of the first matrix is not equal to the number of rows of the second matrix, print matrix
multiplication is not possible and exit. If not, proceed to the next step.
7.Create a third matrix, c of size m x q, to store the product.
8.Set a loop from i=0 to i=m.
9.Set an inner loop for the above loop from j=0 to j=q.
10.Initialise the value of the element (i, j) of the new matrix to 0.
11.Set an inner loop inside the above loop from k=0 to k=p.
12.Using the add and assign operator (+=) store the value of a[i][k] * b[k][j] in the third matrix, c[i][j].
13.Print the third matrix.
14. Stop
Flowchart:
Algorithm:
1. Start
2. Declare variables i, a,b , show
3. Initialize the variables, a=0, b=1, and show =0
4. Enter the number of terms of Fibonacci series to be printed
5. Print first two terms of series
6. Use loop for the following steps
-> Show=a+b
-> a=b
-> b=show
-> Increase value of i each time by 1
-> print the value of show
7.End
Flowchart:
Bisection Method
Aim: Write a Python Program to solve the given mathematical expression using Bisection Method
Algorithm:
1.Start
2.Read x1, x2, e
*Here x1 and x2 are initial guesses
e is the absolute error i.e. the desired degree of accuracy*
3.Compute: f1 = f(x1) and f2 = f(x2)
4.If (f1*f2) > 0, then display initial guesses are wrong and goto (11).
Otherwise, continue.
5.x = (x1 + x2)/2
6.If ( [ (x1 – x2)/x ] < e ), then display x and goto (11).
* Here [ ] refers to the modulus sign. *
7.Else, f = f(x)
8.If ((f*f1) > 0), then x1 = x and f1 = f.
9.Else, x2 = x and f2 = f.
10.Goto (5).
*Now the loop continues with new values.*
11.Stop
Flowchart:
Aim: Write a Python Program to solve the given mathematical expression using False Position Method
Algorithm:
1. Start
2. Read values of x0, x1 and e
*Here x0 and x1 are the two initial guesses
e is the degree of accuracy or the absolute error i.e. the stopping criteria*
3. Computer function values f(x0) and f(x1)
4. Check whether the product of f(x0) and f(x1) is negative or not.
If it is positive take another initial guesses.
If it is negative then goto step 5.
5. Determine:
x = [x0*f(x1) – x1*f(x0)] / (f(x1) – f(x0))
6. Check whether the product of f(x1) and f(x) is negative or not.
If it is negative, then assign x0 = x;
If it is positive, assign x1 = x;
7. Check whether the value of f(x) is greater than 0.00001 or not.
If yes, goto step 5.
If no, goto step 8.
*Here the value 0.00001 is the desired degree of accuracy, and hence the stopping criteria.*
8. Display the root as x.
9. Stop
Flowchart:
Algorithm:
1. Start
2. Read x, e, n, d
*x is the initial guess
e is the absolute error i.e the desired degree of accuracy
n is for operating loop
d is for checking slope*
3. Do for i =1 to n in step of 2
4. f = f(x)
5. f1 = f'(x)
6. If ( [f1] < d), then display too small slope and goto 11.
*[ ] is used as modulus sign*
7. x1 = x – f/f1
8. If ( [(x1 – x)/x1] < e ), the display the root as x1 and goto 11.
*[ ] is used as modulus sign*
9. x = x1 and end loop
10. Display method does not converge due to oscillation.
11. Stop
Flowchart:
Euler’s Method
Aim: Write a Python Program to solve the given mathematical expression using Euler’s Method
Algorithm:
1. Start
2. Define function
3. Get the values of x0, y0, h and xn
*Here x0 and y0 are the initial conditions
h is the interval
xn is the required value
4. n = (xn – x0)/h + 1
5. Start loop from i=1 to n
6. y = y0 + h*f(x0,y0)
x=x+h
7. Print values of y0 and x0
8. Check if x < xn
If yes, assign x0 = x and y0 = y
If no, goto 9.
9. End loop i
10. Stop
Flowchart:
Part A:
i) Draw the neat labeled Layout of ERP Lab
ii) Write a note on the features, advantages and disadvantages of the Python Language.
iii) Explain the Anaconda Suite, including its main features and advantages. Explain the Jupyter
Notebook feature in Anaconda.
Part B:
Explain the following:
i) In the FPT Lab, elaborate on the use of :
- Use and Importance of Algorithms
- Parts of a Flowchart / Blocks used
ii) What is the importance of Sensors in Industrial Engineering? List the types of sensors in use and
describe any 3 of them.
iii) What is the difference between a Solution Engineer and a Solution Architect?
iv) Draw a neat labeled diagram of Arduino Board. What are the applications of this?
v) What devices can be created using Raspberry Pi? What is the OS used in Raspberry Pi Boards, List and
explain any 3 of them.
viii) Draw the flow diagram of various types of loops used in Python:
a) For Loop
b) IF Loop
c) While Loop
d) If-Else Loop
***********************************************************************************