0% found this document useful (0 votes)
14 views10 pages

Kartik MLP 1-3

The document is a practical file record for a Machine Learning with Python course at Panipat Institute of Engineering and Technology. It includes various practical exercises aimed at demonstrating Python programming concepts such as division, temperature conversion, and factorial calculations. Each practical outlines the aim, objectives, key points, source code, and expected outputs.

Uploaded by

mitravlakshay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views10 pages

Kartik MLP 1-3

The document is a practical file record for a Machine Learning with Python course at Panipat Institute of Engineering and Technology. It includes various practical exercises aimed at demonstrating Python programming concepts such as division, temperature conversion, and factorial calculations. Each practical outlines the aim, objectives, key points, source code, and expected outputs.

Uploaded by

mitravlakshay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

PANIPAT INSTITUTE OF ENGINEERING AND TECHNOLOGY

(P.I.E.T)

Department of
B. TECH CSE- AI &DS

Practical File Record


Of
Machine Learning With Python
(PC-CS- AIDS- 315 LA)

Submitted To: Submitted By:

Ms. Anju Saini Satyam


B Tech CSE (AI &DS)
5th Semester
2822527

Session: 2024-25 (Odd Semester)


PANIPAT INSTITUTE OF ENGINEERING TECHNOLOGY Machine Learning with Python

Assessme
S. nt

Date of Practical
No. Name of Practical

Performance
Facult

Total Marks
File Record
Attendance

Viva (10)
y

Lab
(10)

(10)

(10)

(40)
Sign.

1.

2.

3.

4.

5.

Department of B. TECH CSE-AI & DS Page 1 Satyam


m
PANIPAT INSTITUTE OF ENGINEERING TECHNOLOGY Machine Learning with Python

6.

7.

8.

9.

10.

Total Marks

Aggregated Marks

Department of B. TECH CSE-AI & DS Page 2 Satyam


m
PANIPAT INSTITUTE OF ENGINEERING TECHNOLOGY Machine Learning with Python

Practical No. 1

Aim:
Write and run a python program that outputs the value of each of the following expression:
5.0/9.0,5.0/9,5/9.0,5/9,9.0/5.0,9.0/5,9/5.0,9/5
Based on your result, what is the rule for arithmetic operations when integers and floating point
numbers are used?

Objectives:

The objective of the code is to demonstrate how Python handles division involving both integers
and floating-point numbers, showing that the result is always a floating-point number regardless
of the types of operands.

Key Points:

1. Division with integers and/or floating-point numbers always results in a floating-point value.
2. Python automatically converts integers to floating-point numbers when necessary during
division.
3. The result of division (using /) is always a float, even if both operands are integers.

1. Source Code:

print(5.0/9.0)
print(5.0/9)
print(5/9.0)
print(5/9)
print(9.0/5.0)
print(9.0/5)
print(9/5.0)
print(9/5)

Department of B. TECH CSE-AI & DS Page 3 Satyam


m
PANIPAT INSTITUTE OF ENGINEERING TECHNOLOGY Machine Learning with Python

Output:

Rule:
When an arithmetic operation involves both integers and floating-point numbers (like division),
the result will always be a floating-point number. If all the operands are integers, Python will
perform integer division, but the result of division (using /) will always be a floating-point
number, even when dividing integers.

Department of B. TECH CSE-AI & DS Page 4 Satyam


m
PANIPAT INSTITUTE OF ENGINEERING TECHNOLOGY Machine Learning with Python

Practical No. 2
Aim: Write and run a python program that asks the user for a temperature in Celsius and converts
and outputs the temperature in Fahrenheit. (use the formula given in the example above and solve
for temp F in terms of temp C.)

Objective: The objective of this code is to convert a temperature provided in Celsius to Fahrenheit
using the formula F=C×95+32F = \frac{C \times 9}{5} + 32F=5C×9+32 and then output the result.

Key Points:

1. Accepts temperature input in Celsius.

2. Converts Celsius to Fahrenheit using the formula F=C×95+32F = \frac{C \times 9}{5} +
32F=5C×9+32.

3. Outputs the temperature in Fahrenheit.

1. Source Code:

celsius_temp = float(input("Enter the temperature in Celsius: "))

fahrenheit_temp = (celsius_temp * 9/5) + 32

print(f"The temperature in Fahrenheit is: {fahrenheit_temp} °F")

Output:

Department of B. TECH CSE-AI & DS Page 5 Satyam


m
PANIPAT INSTITUTE OF ENGINEERING TECHNOLOGY Machine Learning with Python

Practical No. 3
Aim: Here is an algorithm to print out n! (n factorial) from 0! to 19!

1. Self =1

2. Setn=0

3. Repeat the following 20 times:

a. Output n, “! =”, f

b. Add 1 to n

c. Multiply f by n

Using a for loop, write and run a Python for this algorithm.

3(a). Modify the program above using a while loop so it prints out all the factorial values that are
less than 1 billion.

3(b). Modify the first program so it finds the minimum in the array instead of the maximum.

3(c). (Harder) modify the first program so that it finds the index of the maximum in the array
rather than the maximum itself.

Objective: The objective of the code is to calculate and display factorial values, including:

1. Printing factorials from 0 to 19.

2. Printing factorials less than 1 billion using a while loop.

3. Finding the minimum factorial in an array of factorials.

4. Finding the index of the maximum factorial in the array.

Key Points:

1. Factorial Calculation: Computes and prints factorials from 0! to 19!.

2. Value Limitation: Outputs factorials less than 1 billion using a while loop.

3. Minimum Factorial: Finds and displays the minimum value in the factorial array.

4. Index of Maximum Factorial: Identifies the index of the maximum factorial in the array.

Department of B. TECH CSE-AI & DS Page 6 Satyam


m
PANIPAT INSTITUTE OF ENGINEERING TECHNOLOGY Machine Learning with Python

1. Source Code:

factorial = 1

for n in range(0, 20):


print(f"{n}! = {factorial}")
n += 1
factorial *= n

Output:

3(a). Source Code: Using a while loop to print factorials less than 1 billion.

factorial = 1
n=0

while factorial < 1_000_000_000: # 1 billion


print(f"{n}! = {factorial}")
n += 1
factorial *= n

Department of B. TECH CSE-AI & DS Page 7 Satyam


m
PANIPAT INSTITUTE OF ENGINEERING TECHNOLOGY Machine Learning with Python

Output:

3(b). Source Code: Finding the minimum factorial in an array of factorials from 0! to
19!

factorials = []
factorial = 1

for n in range(0, 20):


factorials.append(factorial)
n += 1
factorial *= n

min_factorial = min(factorials)
print(f"Minimum factorial: {min_factorial}")

Output:

Department of B. TECH CSE-AI & DS Page 8 Satyam


m
PANIPAT INSTITUTE OF ENGINEERING TECHNOLOGY Machine Learning with Python

3(c). Source Code: Finding the index of the maximum factorial in the array.

factorials = []
factorial = 1

for n in range(0, 20):


factorials.append(factorial)
n += 1
factorial *= n

max_factorial = max(factorials)
max_index = factorials.index(max_factorial)
print(f"Index of maximum factorial: {max_index}")

Output:

Department of B. TECH CSE-AI & DS Page 9 Satyam


m

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy