python
python
[DOCUMENT TITLE]
DATA VISUALIZATION WITH PYTHON(BCS358D)
INTERNAL EVALUATION SHEET
EVALUATION (MAX MARKS 50)
REGULAR
TEST RECORD TOTAL MARKS
EVALUATION
A C A+B+C
B
20 20 10 50
Sl.
Needs
No Parameters Good Average
improvement
.
Problem statement
Problem statement is understood
Understanding Clear understanding of problem is not clearly
clearly but few mistakes while
a. of problem statement while designing and understood while
designing and implementing
(2 marks) implementing the program (2) designing the
program (1)
program (0)
Writing Program does not
Program handles all possible Average condition is defined and
b. program handle possible
conditions (2) verified. (1)
(2 marks) conditions (0)
Design, Program follows syntax and
Program has few logical errors, Syntax and
implementation semantics of C programming
moderately demonstrates all semantics of C
c. , and language. Demonstrates the
possible concepts implemented in programming is
demonstration complete knowledge of the
programs (2) not clear (1)
(3 marks) program written (3)
Result and Documentation
Meticulous documentation and all Acceptable documentation shown
d. documentation does not take care
conditions are taken care (3) (2)
(3 marks) all conditions (1)
[DOCUMENT TITLE]
SYLLABUS
Data Visualization with Python(BCS358D)
Course Code BCS358D CIE Marks 50
Number of Contact Hours/Week 0:0:2:0 SEE Marks 50
Total Number of Lab Contact Hours 24 Exam Hours 03
Credits –1
Descriptions(if any):
Programs List:
a) Write a python program to find the best of two test average marks out of three test’s marks
accepted from the user.
1.
b) Develop a Python program to check whether a given number is palindrome or not and also
count the number of occurrences of each digit in the input number.
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
2. if the condition for input value is not followed.
b) Develop a python program to convert binary to decimal, octal to hexadecimal using
functions.
a) Write a Python program that accepts a sentence and find the number of words, digits,
uppercase letters and lowercase letters.
b) Write a Python program to find the string similarity between two given strings
Sample Output: Sample Output:
3 Original string: Original string:
Python Exercises Python Exercises
Python Exercises Python Exercise
Similarity between two said strings: Similarity between two said strings:
1.0 0.967741935483871
a)Write a Python program to Demonstrate how to Draw a Bar Plot using Matplotlib.
4
b) Write a Python program to Demonstrate how to Draw a Scatter Plot using Matplotlib.
a) Write a Python program to Demonstrate how to Draw a Histogram Plot using Matplotlib.
5.
b) Write a Python program to Demonstrate how to Draw a Pie Chart using Matplotlib
a) Write a Python program to illustrate Linear Plotting using Matplotlib.
6 b) Write a Python program to illustrate liner plotting with line formatting using Matplotlib.
a) Write a Python program which explains uses of customizing seaborn plots with Aesthetic
7. functions.
Write a Python program to explain working with bokeh line graph using Annotations and
8 Legends.
a) Write a Python program for plotting different types of plots using Bokeh
9 Write a Python program to draw 3D Plots using Plotly Libraries.
a) Write a Python program to draw Time Series using Plotly Libraries.
10
b) Write a Python program for creating Maps using Plotly Libraries.
[DOCUMENT TITLE]
Course Objectives and Course Outcomes
CO-PO-PSO Matrix
COURSE
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2 PSO3 PSO4
OUTCOMES
CO1 3 2 2
CO2 3 2 2
CO3 3 2 2
CO4 3 2 2
CO5 3 2 2
1.a )Write a python program to find the best of two test average marks out of three test’s marks
accepted from the use
OR
m1=int(input("Enter the test1 Marks"))
m2=int(input("Enter the test2 Marks"))
m3=int(input("Enter the test3 Marks"))
L1=[]
L1.append(m1)
L1.append(m2)
[DOCUMENT TITLE]
L1.append(m3)
L1.sort()
print(L1)
Avg=(L1[1]+L1[2])/2
print("Average of best two test marks out of three test’s marks is ",Avg)
output
Enter the test1 Marks 25
Enter the test2 Marks 25
Enter the test3 Marks 12
[12, 25, 25]
Average of Best of two Test is 25.0
OR
m1=int(input("Enter the test1 Marks"))
m2=int(input("Enter the test2 Marks"))
m3=int(input("Enter the test3 Marks"))
Minimum=min(m1,m2,m3)
sum=m1+m2+m3-Minimum
Avg=sum/2
print("Average of best two test marks out of three test’s marks is ",Avg)
1.b)Develop a Python program to check whether a given number is palindrome or not and #also count
the number of occurrences of each digit in the input number.
for i in range(10):
if str_val.count(str(i)) > 0:
print(str(i),"appears", str_val.count(str(i)), "times");
OR
output
Enter the Number12321
The Number is Palindrome 12321
[DOCUMENT TITLE]
1 appears 2 times
3 appears 1 times
2 appears 2 times
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 condition for input value is not followed.
def Fibonacci(n):
if n==1:
return 0
elif n==2:
return 1
else:
return (Fibonacci(n-1)+Fibonacci(n-2))
Output
Enter the number 5
Fibonacci of 5 is 3
2.b) Develop a python program to convert binary to decimal, octal to hexadecimal using
functions.
def Bin2dec(bin):
l=len(bin)
dec=0
for i in range(l):
dec+=int(bin[i])*(2**(l-i-1))
return dec
def oct2hex(oct):
l=len(oct)
dec=0
for i in range(l):
dec+=int(oct[i])*(8**(l-i-1))
hexa=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']
octhex=' '
while dec>0:
rem=dec%16
octhex=hexa[rem]+octhex
[DOCUMENT TITLE]
dec=dec//16
return octhex
OUTPUT:
Enter the Binary Number1011
Binary to Decimal is 11
Enter the octal Number12
Octal to Decimal is A
3. a) Write a Python program that accepts a sentence and find the number of words, digits,
uppercase letters and lowercase letters.
sentence = input("Enter a sentence : ")
digCnt = upCnt = loCnt =wordcnt=0
wordcont=sentence.split()
for ch in sentence:
if ch>='0' and ch<='9':
digCnt += 1
if ch>='A'and ch<='Z':
upCnt += 1
if ch>='a' and ch<='z':
loCnt += 1
words: 4
digits 4
upper case letters 6
lower case letters 4
3.b) Write a Python program to find the string similarity between two given strings
def compare(s,p):
count=0
n=min(len(s),len(p))
for i in range(n):
if s[i]==p[i]:
count+=1
return count
s1 = input("Enter String 1 \n")
s2 = input("Enter String 2 \n")
mx=max(len(s1),len(s2))
count=compare(s1,s2)
similarity=count/mx*100
[DOCUMENT TITLE]
print ("Total number letter matched is",count)
print("simirality between two string is",similarity)
Output
Enter String 1
rnsit
Enter String 2
rnsit
Total number letter matched is 5
simirality between two string is 100.0
Enter String 1
welcome
Enter String 2
rnsit
Total number letter matched is 0
simirality between two string is 0.0
4.a ) Write a Python program to Demonstrate how to Draw a Bar Plot using Matplotlib.
import matplotlib.pyplot as plt
plt.bar([1,3,5,7,9],[5,2,7,8,2], label="Data 1")
plt.legend()
# The following commands add labels to our figure.
plt.xlabel('X values')
plt.ylabel('Height')
plt.title('Vertical Bar chart')
plt.show()
OUTPUT
Or
import matplotlib.pyplot as plt
plt.barh(["Cats","Dogs","Goldfish","Snakes","Turtles"],
[5,2,7,8,2], align='center', label="Data 1")
plt.legend()
[DOCUMENT TITLE]
plt.ylabel('Pets')
plt.xlabel('Popularity')
plt.title('Popularity of pets in the neighbourhood')
plt.show()
OUTPUT
y =[99, 86, 87, 88, 100, 86, 103, 87, 94, 78, 77, 85, 86]
plt.scatter(x, y, c ="blue")
plt.show()
OUTPUT
[DOCUMENT TITLE]
5 a) Write a Python program to Demonstrate how to Draw a Histogram Plot using
Matplotlib.
import numpy as np
a = np.array([22, 87, 5, 43, 56, 73, 55, 54, 11, 20, 51, 5, 79, 31,27])
plt.show()
OUTPUT:
5 b) Write a Python program to Demonstrate how to Draw a Pie Chart using Matplotlib.
import numpy as np
plt.show()
OUTPUT:
[DOCUMENT TITLE]
6 b) Write a Python program to illustrate liner plotting with line formatting using
Matplotlib.
[DOCUMENT TITLE]
plt.xlabel("Students")
plt.ylabel("Marks")
plt.title("CLASS RECORDS")
plt.plot(studentsusn,marks, color = 'green', linestyle = 'solid', marker = 'o', markerfacecolor =
'red', markersize = 15)
OUTPUT
7 a) Write a Python program which explains uses of customizing seaborn plots with
Aesthetic functions.
data = sns.load_dataset("iris")
sns.set_style("darkgrid")
plt.show()
[DOCUMENT TITLE]
OUTPUT
8 a) Write a Python program to explain working with bokeh line graph using Annotations and
Legends.
x = [1, 2, 3, 4, 5]
y = [5, 4, 3, 2, 1]
show(graph)
OUTPUT:
[DOCUMENT TITLE]
8. b) Write a Python program for plotting different types of plots using Bokeh.
x = y = list(range(10))
fig2.circle(x, y, size = 5)
show(row(fig1, fig2))
OUTPUT:
OR
x = y = list(range(10))
[DOCUMENT TITLE]
xs = [[[[1, 1, 2, 2]]]]
ys = [[[[4, 3, 3, 4]]]]
output:
import plotly.express as px
df = px.data.iris()
[DOCUMENT TITLE]
y = 'sepal_length',
z = 'petal_width',
color = 'species',
size='petal_length',
size_max = 20,
opacity = 0.5)
fig.show()
10. a) Write a Python program to draw Time Series using Plotly Libraries.
import pandas as pd
import plotly.express as px
tsla = pd.read_csv('C:/Users/Admin/OneDrive/Desktop/Tesla.csv')
tsla.head()
fig.show()
[DOCUMENT TITLE]
fig.show()
import plotly.graph_objects as go
import plotly.express as px
url = 'C:/Users/Admin/Downloads/Places.csv'
data.head()
data.head()
fig.update_layout(mapbox_style="open-street-map")
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
[DOCUMENT TITLE]
Sample Programs
1. Python program to print "Hello Python"
print ('Hello Python')
[DOCUMENT TITLE]
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('The area of the triangle is %0.2f' %area)
5. Python program to find the sum and average of natural numbers up to n where n is provided by
user.
n=int(input("Enter upto which number you want sum and average"))
sum=0
for i in range(0,n+1):
sum=sum+i
avg=sum/n
print("Result of sum is",sum)
print("Result of Average",avg)
[DOCUMENT TITLE]
14. WAP to print grades obtained by the students and print the appropriate message.
marks=input()
type(marks)
x=int(marks)
if x>=90 and x<100:
print('distinction')
elif x>=80 and x<=90:
print("first")
else :
[DOCUMENT TITLE]
print("fail")
[DOCUMENT TITLE]
Python Additional Programs
1. Python program to print "Hello Python"
2. Python program to do arithmetical operations
3. Python program to find the area of a triangle
4. Python program to solve quadratic equation
5. Python program to swap two variables
6. Python program to generate a random number
7. Python program to convert kilometers to miles
8. Python program to convert Celsius to Fahrenheit
9. Python program to display calendar
10. Python Program to Check if a Number is Positive, Negative or Zero
11. Python Program to Check if a Number is Odd or Even
12. Python Program to Check Leap Year
13. Python Program to Check Prime Number
14. Python Program to Print all Prime Numbers in an Interval
15. Python Program to Find the Factorial of a Number
16. Python Program to Display the multiplication Table
17. Python Program to Print the Fibonacci sequence
18. Python Program to Check Armstrong Number
19. Python Program to Find Armstrong Number in an Interval
20. Python Program to Find the Sum of Natural Numbers
21. Python Function Programs
22. Python Program to Find LCM
23. Python Program to Find HCF
24. Python Program to Convert Decimal to Binary, Octal and Hexadecimal
25. Python Program To Find ASCII value of a character
26. Python Program to Make a Simple Calculator
27. Python Program to Display Calendar
28. Python Program to Display Fibonacci Sequence Using Recursion
29. Python Program to Find Factorial of Number Using Recursion
30. Python Number Programs
31. Python program to check if the given number is a Disarium Number
32. Python program to print all disarium numbers between 1 to 100
33. Python program to check if the given number is Happy Number
34. Python program to print all happy numbers between 1 and 100
35. Python program to determine whether the given number is a Harshad Number
36. Python program to print all pronic numbers between 1 and 100
37. Python Array Programs
38. Python program to copy all elements of one array into another array
39. Python program to find the frequency of each element in the array
40. Python program to left rotate the elements of an array
41. Python program to print the duplicate elements of an array
42. Python program to print the elements of an array
43. Python program to print the elements of an array in reverse order
44. Python program to print the elements of an array present on even position
45. Python program to print the elements of an array present on odd position
46. Python program to print the largest element in an array
[DOCUMENT TITLE]
47. Python program to print the smallest element in an array
48. Python program to print the number of elements present in an array
49. Python program to print the sum of all elements in an array
50. Python program to right rotate the elements of an array
51. Python program to sort the elements of an array in ascending order
52. Python program to sort the elements of an array in descending order
Viva Questions:
1. What it the syntax of print function?
2. What is the usage of input function?
3. Define a variable.
4. What is type conversion?
5. Mention the data types in Python
6. What are the attributes of the complex datatype?
7. Mention a few escape sequences.
8. Define an expression
9. What is the usage of ** operator in Python?
10. Give the syntax of if else statement.
11. Give the syntax of for statement.
12. How is range function used in for?
13. Give the syntax of while statement.
14. What are multi way if statements?
15. How is random numbers generated?
16. Define a function.
17. Give the syntax of function.
18. What are the types of arguments in function.?
19. What is a recursive function?
20. What are anonymous functions?
21. What are default arguments?
22. What are variable length arguments?
23. What are keyword arguments?
24. Mention the use of map().
25. Mention the use of filter().
26. Mention the use of reduce().
27. Define a string.
28. How is string slicing done?
29. What is the usage of repetition operator?
30. How is string concatenation done using + operator>
31. Mention some string methods
32. How is length of a string found?
33. How is a string converted to its upper case?
34. `Differentiate isalpha() and isdigit().
35. What is the use of split()?
36. Define a file.
37. Give the syntax for opening a file.
[DOCUMENT TITLE]
38. Give the syntax for closing a file.
39. How is reading of file done?
40. How is writing of file done?
41. What is a list?
42. Lists are mutable-Justify.
43. How is a list created?
44. How can a list be sorted?
45. How are elements appended to the list?
46. How is insert() used in list?
47. What is the usage of pop() in list?
48. Define a tuple.
49. Are tuples mutable or immutable?
50. Mention the use of return statement.
51. What is a Boolean function?
52. How is main function defined?
53. What is a dictionary?
54. How are tuples created?
55. How is a dictionary created?
56. How to print the keys of a dictionary?
57. How to print the values of a dictionary?
58. How is del statement used?
59. Can tuple elements be deleted?
60. What is Python interpreter?
61. Why is Python called an interpreted language?
62. Mention some features of Python
63. What is Python IDLE?
64. Mention some rules for naming an identifier in Python.
65. Give points about Python Numbers.
66. What is bool datatype?
67. Give examples of mathematical functions.
68. What is string formatting operator?
69. Mention about membership operators in Python.
70. How is expression evaluated in Python?
71. What are the loop control statements in Python?
72. What is the use of break statement?
73. What is the use of continue statement?
74. What is the use of pass statement?
75. What is assert statement?
76. Differentiate fruitful function s and void functions.
77. What are required arguments ?
78. Differentiate pass by value and pass by reference.
79. Mention few advantages of function.
80. How is lambda function used?
81. What is a local variable?
82. What are global variables?
[DOCUMENT TITLE]
83. What are Python decorators?
84. Are strings mutable or immutable?
85. What is join()?
86. What is replace() method?
87. What is list comprehension?
88. Define multidimensional list.
89. How to create lists using range()?
90. What is swapcase() method?
91. What is linear search?
92. How is binary search done?
93. How is merge sort performed?
94. What is sorting?
95. How is insertion sort done?
96. How is selection sort done?
97. What are command line arguments?
98. Name some built in functions with dictionary.
99. What is an exception?
100. How is exception handled in python?