Docsity

Machine Learning Lab Practical: Computing Polynomial Equations using Python, Schemes and Mind Maps of Machine Learning

Toggle sidebar
bg1
EXPERIMENT 1.1
Student Name: Mayank Gupta UID: 20BCS6892
Branch: BE CSE AIT Section/Group: 20AML-6B
Semester: 4th Date of Performance: 11/02/2022
Subject Name: Machine learning Lab Subject Code: 20CSF-288
• Aim/Overview of the practical:
To understand the basic programming syntax, data structure and to compute polynomial
equation using Python.
• Task to be done:
Develop a python code to compute polynomial equation and by asking the value of
variable, coefficients and store them in a list.
• Algorithm:
1. START
2. Import the math module.
3. Take the coefficient of the polynomial equation from the user and store it in the list.
4. Get a value of x from the user.
5. Compute the values of the polynomial expression for the first three terms and store them
in the sum variable using for loop and while loop.
6. Add the fourth term to the variable.
7. Print the computed value.
8. EXIT
pf3

Partial preview of the text

Download Machine Learning Lab Practical: Computing Polynomial Equations using Python and more Schemes and Mind Maps Machine Learning in PDF only on Docsity!

EXPERIMENT 1.

Student Name: Mayank Gupta UID: 20BCS

Branch: BE CSE AIT Section/Group: 20AML-6B

Semester: 4 th^ Date of Performance: 11/02/

Subject Name: Machine learning Lab Subject Code: 20CSF- 288

• Aim/Overview of the practical:

To understand the basic programming syntax, data structure and to compute polynomial

equation using Python.

• Task to be done:

Develop a python code to compute polynomial equation and by asking the value of

variable, coefficients and store them in a list.

• Algorithm:

1. START

2. Import the math module.

3. Take the coefficient of the polynomial equation from the user and store it in the list.

4. Get a value of x from the user.

5. Compute the values of the polynomial expression for the first three terms and store them

in the sum variable using for loop and while loop.

6. Add the fourth term to the variable.

7. Print the computed value.

8. EXIT

  • CODE: import math print("Enter the coefficients of the form ax^3 + bx^2 + cx + d") lst = [] for i in range( 0 , 4 ): a = int (input("Enter coefficient: ")) lst.append(a) x = int (input("Enter the value of x: ")) sum = 0 j = 3 for i in range( 0 , 3 ): while(j > 0 ): sum = sum + (lst[i] * math.pow(x,j)) break j = j - 1 sum = sum + lst[ 3 ] print("") print("The value of the polynomial is:",sum)
  • OUTPUT: