EXPERIMENT- 26
AIM- Write the python code to calculate Euclidean Distance between 2D points X
and Y.
OBJECTIVE- The objective of this program is to calculate the Euclidean distance
between two points in a two-dimensional (2D) space. The Euclidean distance is the
straight-line distance between two points and is widely used in geometry, physics,
and various fields of data analysis and machine learning.
CODE-
OUTPUT-
CONCLUSION- This program successfully calculates the Euclidean distance
between two 2D points entered by the user. By applying the Euclidean distance
formula, the program provides a straightforward way to measure the straight-line
distance between any two points in a plane.
EXPERIMENT- 27
AIM- Write the python code to print the following pattern:
OBJECTIVE- To develop a Python program that prints a specific number
pattern using nested loops. The pattern starts with the number 1 on the first
line and appends the next integer on each subsequent line, forming a right-
angled triangle of increasing numeric sequences.
CODE-
OUTPUT-
CONCLUSION- The program successfully demonstrates how to use nested
loops in Python to generate and display a structured numeric pattern.
Through this exercise, we gained a better understanding of controlling loop
iterations and customizing output format, which is fundamental in learning
logic building and pattern design in programming.
EXPERIMENT- 28
AIM- Write the python code to print the following pattern:
OBJECTIVE- To write a Python program that prints a reverse
numeric triangle pattern where each row contains repeated
digits in decreasing order from 5 to 1.
CODE-
OUTPUT-
CONCLUSION- This program effectively demonstrates the use
of nested loops to create descending numeric patterns. It helps
reinforce logic-building skills using loops and control structures
in Python.
EXPERIMENT- 29
AIM- Write the python code to print the following pattern:
OBJECTIVE- To develop a Python program that prints a right-aligned
triangle pattern of asterisks. The pattern starts with one * at the top and
increases by one on each line, aligned to the right side of the output. This
helps in understanding nested logic, space management, and alignment
using string operations and loops in Python.
CODE-
OUTPUT-
CONCLUSION- The program successfully demonstrates how to manipulate
spaces and characters to form a right-aligned triangle pattern using loops in
Python. It enhances understanding of string multiplication and output
formatting — essential concepts in pattern printing and basic programming
logic.
EXPERIMENT- 30
AIM- Write the python code to print the following pattern:
OBJECTIVE- To develop a Python program that prints a right-aligned
triangle pattern of numbers. The pattern starts with 1 at the top, appends
the next number on each subsequent row, and aligns it to the right. This
helps in understanding loops, string manipulation, and alignment in output
formatting in Python.
CODE-
OUTPUT-
CONCLUSION- The program successfully prints a right-aligned number
pattern using nested loops. It demonstrates how to manage row alignment
with spaces and print numbers in sequence without using advanced
functions. This approach helps in understanding basic loop structures and
output formatting in Python.
EXPERIMENT- 31
AIM- Write the program to define the function that takes name of the
student and marks as input and use the defined function average to
compute the average makes and then use the user defined grade function to
compute the grade. At last, display the name, average marks and grade
back to the student.
OBJECTIVE- To create a Python program that collects a student's name
and marks for multiple subjects, calculates the average of those marks,
determines the grade based on the average, and displays the final result to
the user.
CODE-
OUTPUT-
CONCLUSION- The program successfully takes the student's name and
individual subject marks, computes the average marks, evaluates the
corresponding grade using conditional logic, and displays the complete
student report in a clear and readable format.
EXPERIMENT- 32
AIM- Write the function to calculate factorial value of a number
without and with using recursion.
OBJECTIVE- To develop a Python program that calculates the
factorial of a number using two different approaches — one
using recursion and the other using an iterative loop — in
order to understand and compare both techniques.
CODE- USING RECURSION
OUTPUT-
CODE- WITHOUT USING RECURSION
OUTPUT-
CONCLUSION- The program successfully calculates the
factorial using both recursion and iteration. The recursive
approach demonstrates how a problem can be solved by
breaking it down into smaller subproblems, while the iterative
approach provides a straightforward and efficient loop-based
solution. This comparison helps in understanding the advantages
and use-cases of each method in programming.