Approved by AICTE, Permanently Affiliated to JNTUK, Accredited by NBA & NAAC
Aditya Nagar, ADB Road, SURAMPALEM-533436
DEPARTMENT OF ELECTRONICS AND
COMMUNICATION ENGINEERING
DATA ANALYSIS USING PYTHON LAB
([Link]-2024 REGULATION, Code: 241CS002)
IV Semester
Lab Manual
Date:
Experiment-1.1
Write a program that asks the user for a weight in kilograms and converts it to pounds. There are 2.2
pounds in a kilogram.
AIM: To write a program that asks the user for a weight in kilograms and converts it to pounds.
Description:
The purpose of this program is to convert a weight value from kilograms to pounds. The user is asked
to input the weight in kilograms. The program uses the standard conversion factor, multiplies the
entered value by 2.2 to obtain the equivalent weight in pounds, and then displays the result in the
specified format.
Procedure/Algorithm:
1. Start the program.
2. Prompt the user to input a weight in kilograms.
3. Read the user's input and store it as a floating-point number.
4. Multiply the input value by 2.2 to convert it to pounds.
5. Display the calculated weight in pounds.
6. End the program.
Program:
Output:
Result:
Date:
Experiment-1.2
Write a program that uses a for loop to print the numbers 8,11,14,17,20,...,83,86,89.
AIM: To write a program using a for loop to print the numbers 8,11,14,17,20,...,83,86,89.
Description:
This program prints a sequence of numbers starting at and increasing by a step value each time, up to
a specified value. In this sequence the difference between consecutive terms is constant, is called an
arithmetic progression. The sequence generated will be: 8, 11, 14, ..., 86, 89.
Procedure/Algorithm:
1. Initialize the starting number (first term) as 8.
2. Set the common difference as 3.
3. Start a loop from 8, incrementing by 3 each time.
4. Continue looping and printing each number until the value exceeds 89.
Program:
Output:
Result:
Date:
Experiment-1.3
Split a string into array of characters in Python.
AIM: To write a program to split a given string into array of characters in Python.
Description:
In Python, strings are sequences of characters. To manipulate or analyze individual characters, it's
often useful to convert the string into an array (or list) of its characters. This process is called splitting
a string into a list of characters. This can be done easily using built-in Python features like list() or list
comprehensions. It should also be implemented without using inbuilt function (list()).
Procedure/Algorithm:
1. Start.
2. Accept the input from the user and store it in a variable.
3. Convert the string in to a list of characters using list() and without using the list().
4. Display the resulting list
5. Stop
Program:
Output:
Result:
Date:
Experiment-1.4
Write a Python program to get the largest number from a list.
AIM: To write a Python program to get the largest number from a list.
Description:
In Python, lists can store multiple values including integers. To determine the largest number from a
list, we can use built-in functions like max() or traverse the list manually to compare each element. This
helps in understanding how to handle lists and use control flow structures effectively.
Procedure/Algorithm:
1. Input a list of numbers from the user.
2. Convert the input string into a list of integers.
3. Use the built-in max() function to find the largest number.
4. Alternatively, iterate through the list using a loop to manually find the maximum.
5. Display the largest number.
Program:
Output:
Result:
Date:
Experiment-1.5
Write a Python program to calculate the nth Fibonacci number using a function.
AIM: To write a Python program to calculate and print the nth Fibonacci number using a function.
Description:
The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding
ones, starting from 0 and 1.
That is:
F(0)=0, F(1)=1
F(n)=F(n-1) +F(n-2) for n ≥ 2
In this program, a function is defined to compute the Fibonacci using iteration. Functions in Python
allow us to organize code for reusability and clarity.
Procedure/Algorithm:
1. Define a function called fibonacci(n) that calculates then the Fibonacci number.
2. Use a iterative approach inside the function.
3. Take input ‘n’ from the user.
4. Call the function with ‘n’ and display the result.
Program:
Output:
Result: