Data Visualization With Python - Update
Data Visualization With Python - Update
(BCS403)
LAB MANUAL
For
III SEMESTER (ISE)
2022 SCHEME
Prepared By:
Dr.RekhaH
Professor
Department of Information Science and Engineering
SIET Tumkuru
Data Visualization with Python(BCS358D) 2024-2025
Experiments:
1. a) Write a python program to find the best of two test average marks out of three
test’s marks acceptedfrom the user.
b) Develop a Python program to check whether a given number is palindrome or
not andalso count thenumber of occurrences of each digit in the input number.
2. a) Defined as a function F as Fn = Fn-1 + Fn-2. Write a Python program which
accepts a value for N(where N >0) as input and pass this value to the function.
Display suitable error message if the conditionfor input value is not followed.
b) Develop a python program to convert binary to decimal, octal to hexadecimal
using functions.
3. a) Write a Python program that accepts a sentence and find the number of words,
digits, uppercase letters andlowercase letters.
b) Write a Python program to find the string similarity between two given strings
4. a) Write a Python program to Demonstrate how to Draw a Bar Plot using
Matplotlib.
b) Write a Python program to Demonstrate how to Draw a Scatter Plot using
Matplotlib.
5. a) Write a Python program to Demonstrate how to Draw a Histogram Plot using
Matplotlib.
b) Write a Python program to Demonstrate how to Draw a Pie Chart using
Matplotlib.
6. a) Write a Python program to illustrate Linear Plotting using Matplotlib.
b) Write a Python program to illustrate liner plotting with line formatting using
Matplotlib.
7. Write a Python program which explains uses of customizing seaborn plots with
Aesthetic functions.
Write a Python program to explain working with bokeh line graph using
8. Annotations and Legends.
a) Write a Python program for plotting different types of plots using Bokeh.
10. a) Write a Python program to draw Time Series using Plotly Libraries.
b) Write a Python program for creating Maps using Plotly Libraries.
ISE,SIET2
Data Visualization with Python(BCS358D) 2024-2025
LABORATORYPROGRAMS
1) A)Write a python program to find the best of two test average marks out of
three test’s marks acceptedfrom the user.
PROGRAM:
OUTPUT:
PROGRAM:
OUTPUT:
ISE,SIET3
Data Visualization with Python(BCS358D) 2024-2025
def fn(n):
if n == 1:
return 0
elif n == 2:
return 1
else:
return fn(n-1) + fn(n-2)
num = int(input("Enter a number : "))
if num> 0:
print("fn(", num, ") = ",fn(num) , sep ="")
else:
print("Error in input")
OUTPUT:
Enter a number : -1
Error in input
Enter a number : 5
fn(5) = 3
PROGRAM:
def binary_to_decimal(binary):
decimal = 0
for digit in binary:
decimal = decimal * 2 + int(digit)
return decimal
def octal_to_hexadecimal(octal):
decimal = 0
for digit in octal:
decimal = decimal * 8 + int(digit)
hexadecimal = hex(decimal).lstrip("0x").upper()
return hexadecimal
decimal = binary_to_decimal(binary)
print("The decimal equivalent of", binary, "is:", decimal)
ISE,SIET4
Data Visualization with Python(BCS358D) 2024-2025
hexadecimal = octal_to_hexadecimal(octal)
print("The hexadecimal equivalent of", octal, "is:", hexadecimal)
OUTPUT:
ISE,SIET5
Data Visualization with Python(BCS358D) 2024-2025
3) A)Write a Python program that accepts a sentence and find the number of
words, digits, uppercase letters andlowercase letters.
PROGRAM:
OUTPUT:
B) Write a Python program to find the string similarity between two given strings.
PROGRAM:
ISE,SIET6
Data Visualization with Python(BCS358D) 2024-2025
if str1[i] == str2[i]:
matchCnt += 1
print("Similarity between two said strings:")
print(matchCnt/long)
OUTPUT:
Enter String 1
Python Exercises
Enter String 2
Python Exercise
Similarity between two said strings:
0.9375
ISE,SIET7
Data Visualization with Python(BCS358D) 2024-2025
PROGRAM:
OUTPUT:
PROGRAM:
ISE,SIET8
Data Visualization with Python(BCS358D) 2024-2025
plt.show()
OUTPUT:
ISE,SIET9
Data Visualization with Python(BCS358D) 2024-2025
PROGRAM:
OUTPUT:
B) Write a Python program to Demonstrate how to Draw a Pie Chart using Matplotlib.
PROGRAM:
ISE,SIET10
Data Visualization with Python(BCS358D) 2024-2025
OUTPUT:
ISE,SIET11
Data Visualization with Python(BCS358D) 2024-2025
PROGRAM:
OUTPUT:
B)Write a Python program to illustrate liner plotting with line formatting using
Matplotlib.
PROGRAM:
ISE,SIET12
Data Visualization with Python(BCS358D) 2024-2025
plt.show()
OUTPUT:
ISE,SIET13
Data Visualization with Python(BCS358D) 2024-2025
7) Write a Python program which explains uses of customizing seaborn plots with
Aesthetic functions.
PROGRAM:
ISE,SIET14
Data Visualization with Python(BCS358D) 2024-2025
8) Write a Python program to explain working with bokeh line graph using
Annotations and Legends.
PROGRAM:
OUTPUT:
ISE,SIET15
Data Visualization with Python(BCS358D) 2024-2025
8)a) Write a Python program for plotting different types of plots using Bokeh.
PROGRAM:
x = list(range(1, 11))
y1 = [random.randint(1, 10) for i in x]
y2 = [random.randint(1, 10) for i in x]
OUTPUT:
ISE,SIET16
Data Visualization with Python(BCS358D) 2024-2025
PROGRAM:
import plotly.graph_objs as go
import numpy as np
X, Y = np.meshgrid(x, y)
Z = np.sin(np.sqrt(X**2 + Y**2))
layout = go.Layout(
title='3D Surface Plot',
scene=dict(
xaxis=dict(title='X Axis'),
yaxis=dict(title='Y Axis'),
zaxis=dict(title='Z Axis')
)
)
OUTPUT:
ISE,SIET17
Data Visualization with Python(BCS358D) 2024-2025
10) a) Write a Python program to draw Time Series using Plotly Libraries.
PROGRAM:
import plotly.graph_objects as go
data = [
{'x': [1, 2, 3, 4, 5], 'y': [6, 7, 2, 4, 5]},
{'x': [6, 7, 8, 9, 10], 'y': [1, 3, 5, 7, 9]}
]
fig = go.Figure()
for i in range(len(data)):
fig.add_trace(go.Scatter(x=data[i]['x'], y=data[i]['y'], mode='lines'))
fig.update_layout(title='Time Series', xaxis_title='Time', yaxis_title='Value')
fig.show()
OUTPUT:
PROGRAM:
import plotly.express as px
# Sample data for demonstration
data = {
'City': ['New York', 'San Francisco', 'Los Angeles', 'Chicago', 'Houston'],
'Lat': [40.7128, 37.7749, 34.0522, 41.8781, 29.7604],
'Lon': [-74.0060, -122.4194, -118.2437, -87.6298, -95.3698],
'Population': [8175133, 870887, 3971883, 2716000, 2328000]
}
# Create a map
fig = px.scatter_geo(data, lat='Lat', lon='Lon', text='City', size='Population',
projection='natural earth', title='Population of Cities')
fig.update_traces(textposition='top center')
ISE,SIET18
Data Visualization with Python(BCS358D) 2024-2025
fig.show()
OUTPUT:
ISE,SIET19