PDS Ketan
PDS Ketan
PDS Ketan
PRACTICAL 1
AIM: Implement program of “HelloWorld” in Python language.
CODE:
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 1
PDS (3150713)
PRACTICAL 2
AIM: Implement program of Primary Data Types (String, Integer, Float,
Complex, Boolean) in Python.
String:
CODE:
#string
>>> str1="malek Azba"
>>> print(str1);
OUTPUT:
Integer:
CODE:
#Integer
a=12
>>> print(a)
OUTPUT:
Float:
CODE:
#Float
>>> z=34.55
>>> print(z)
OUTPUT:
Complex:
CODE:
#Complex
>>> x=complex(4,9)
>>> print(x)
VIEAT/BE/SEM-5/220940107005 Page 2
PDS (3150713)
OUTPUT:
Boolean:
CODE:
#Boolean
>>> p=90
>>> bool(p)
True
>>> q=100
>>> bool(q)
True
>>> bool(p==q)
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 3
PDS (3150713)
PRACTICAL 3
AIM: Implement below program of using input function in Python.
CODE:
# Addiiton of Two numbers using input function
number1 = int(input ("Ener the value of first number for addition : "))
Ener the value of first number for addition : 78
number2 = int(input ("Enter the value of second number for addition : "))
Enter the value of second number for addition : 23
Addition=number1 + number2
print(Addition)
101
OUTPUT:
CODE:
# SquareRoot
num=int(input("Enter a number to find its SquareRoot : "))
Enter a number to find its SquareRoot : 25
result=num**0.5
print("Square root of " ,num, "is", result)
Square root of 25 is 5.0
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 4
PDS (3150713)
PRACTICAL 4
AIM: Implement a conditional statements in Python.
# if else
for i in list_of_numbers:
if 1%2!=0:
print(i,"is an odd number")
else:
print(i,"is an even number")
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 5
PDS (3150713)
PRACTICAL 5
AIM: Implement “for loop” & “while loop” in Python.
OUTPUT:
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 6
PDS (3150713)
PRACTICAL 6
AIM: Implement the user defined function to find factorial of any number.
CODE :
import math
num=5
factorial=math.factorial(num)
print("The factorial of",num,"is",factorial)
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 7
PDS (3150713)
PRACTICAL 7
AIM: Implement the function to find area of Geometrical shapes (Square,
Rectangle, Circle & Triangle).
OUTPUT:
OUTPUT:
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 8
PDS (3150713)
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 9
PDS (3150713)
PRACTICAL 8
AIM: Implement Data Structures (List, Dictionary, Tuple, Set) in Python.
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 10
PDS (3150713)
PRACTICAL 9
AIM: Implement the Program which perform of perform basic data
manipulations(delete empty,rows,columns,remove outliners)in .csv file
using Pandas on jupyter Notebook in python.
CODE:
# import module
import pandas as pd
# assign dataset
df = pd.read_csv("country_code.csv")
# display
print("Type-", type(df))
df
df.head(10)
df.shape
df1 = pd.read_csv("country_code.csv")
merged_col = pd.merge(df, df1, on='Name')
merged_col
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 11
PDS (3150713)
PRACTICAL 10
AIM:Implement the program to perform in following
1.basic Numpy operation:-Create one,two,multi-dimensional Array.
2.Perform addition,Subtraction,multiplication and division operation on
two matrix.
3.Perform below functions of nump:-range(), arrange(), linespace(),
reshape() , zeroes(),ones(),min(),max(),sum(),sqrt() functions in Python.
1.basic Numpy operation:-Create one,two,multi-dimensional Array.
CODE:
import numpy as np
#creating one dimention array
print("creating one dimention array")
arr = np.array([10,28,35,32,11,37])
print(type(arr))
print(arr.shape)
print(arr.ndim)
#creating two dimention array
print("creating two dimention array")
arr2 = np.array([[10,20,30],[40,50,60]])
print(arr2)
print(arr2.ndim)
#creating multi dimention array
arr3 = np.array([[[1,2,3],[5,6,7]],[[10,20,30],[40,50,60]]])
print(arr3)
print(arr3.ndim)
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 12
PDS (3150713)
print (numpy.add(x,y))
print ("The element wise subtraction of matrix is : ")
print (numpy.subtract(x,y))
print ("The element wise division of matrix is : ")
print (numpy.divide(x,y))
print ("The element wise multiplication of matrix is : ")
print (numpy.multiply(x,y))
print ("The product of matrices is : ")
print (numpy.dot(x,y))
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 13
PDS (3150713)
VIEAT/BE/SEM-5/220940107005 Page 14
PDS (3150713)
PRACTICAL 11
AIM:Implement data visualization on .csv file by the use of matplotlib in
Python.
CODE:
import matplotlib.pyplot as plt
import csv
x = []
y = []
with open('biostats.csv','r') as csvfile:
plots = csv.reader("csvfile,delimiter "= ',')
for row in plots:
x.append(row[0])
y.append(int(row[2]))
plt.bar(x, y, color = 'g', width = 0.72, label = "Age")
plt.xlabel('Names')
plt.ylabel('Ages')
plt.title('Ages of different persons')
plt.legend()
plt.show()
OUTPUT:
VIEAT/BE/SEM-5/220940107005 Page 15