Babulal Tarabai Institute of Research and Technology, Sagar: Btirt
Babulal Tarabai Institute of Research and Technology, Sagar: Btirt
LAB MANUAL
DATA ANALYTICS
(CS – 605)
Enrollment No:
0608CS203D06
DATA ANALYTICS BTIRT 0608CS203D06
INDEX
List Of Experiments
6. Program to create all possible strings by using ‘a’, ‘e’, ‘i’, ‘o’, ‘u’.
2
DATA ANALYTICS BTIRT 0608CS203D06
EXPERIMENT – 1
Aim- Write a python program to define a module to find Fibonacci Numbers and input the
module to another program.
Program-
# Function for nth Fibonacci number
def Fibonacci(n):
# Check if n is 0
# then it will return 0
elif n == 0:
return 0
# Check if n is 1,2
# it will return 1
elif n == 1 or n == 2:
return 1
else:
return Fibonacci(n-1) + Fibonacci(n-2)
# Driver Program
print(Fibonacci(9))
Program Output- 34
DATA ANALYTICS BTIRT 0608CS203D06
EXPERIMENT – 2
Aim- Write a python program to find factorial of a number using recursion.
Program-
# Python 3 program to find
def factorial(n):
# is 1 or 0 then
# return 1
# factorial
if (n==1 or n==0):
return 1
else:
# Driver Code
num = 5;
print("number : ",num)
print("Factorial : ",factorial(num))
Program Output-
Number : 5
Factorial : 120
DATA ANALYTICS BTIRT 0608CS203D06
EXPERIMENT – 3
Aim- Write a python program to that accepts length of three sides of a triangle as
inputs. The program should indicate whether or not the triangle is a right-angled triangle.
Program-
from math import sqrt
print("Input lengths of shorter triangle sides:")
a = float(input("a: "))
b = float(input("b: "))
c = sqrt(a**2 + b**2)
print("The length of the hypotenuse is:", c )
Program Output- Input lengths of shorter triangle sides
a: 3
b: 4
EXPERIMENT – 4
Aim- Python program to print a half diamond star pattern.
Program-
# Python Program to Print Half Diamond Star Pattern
i=0
j=0
j=j+1
i=i+1
print()
i=1
j = i;
j=j+1
i=i+1
print()
DATA ANALYTICS BTIRT 0608CS203D06
Program Output-
**
***
****
*****
******
*******
********
*********
********
*******
******
*****
****
***
**
*
DATA ANALYTICS BTIRT 0608CS203D06
EXPERIMENT – 5
Aim- Python program to check whether the string is symmetrical or
palindrome.
Program-
# string
def palindrome(a):
mid = (len(a)-1)//2
start = 0
last = len(a)-1
flag = 0
# string
if (a[start]== a[last]):
start += 1
last -= 1
else:
flag = 1
break;
# or not
if flag == 0:
else:
def symmetry(a):
n = len(a)
flag = 0
# is odd or even
if n%2:
mid = n//2 +1
DATA ANALYTICS BTIRT 0608CS203D06
else:
mid = n//2
start1 = 0
start2 = mid
if (a[start1]== a[start2]):
start1 = start1 + 1
start2 = start2 + 1
else:
flag = 1
break
# or not
if flag == 0:
else:
# Driver code
string = 'amaama'
palindrome(string)
symmetry(string)
Program Output-
The entered string is palindrome
The entered string is symmetrical
DATA ANALYTICS BTIRT 0608CS203D06
EXPERIMENT – 6
Aim- Write a python program to create all possible strings by using
‘a’, ‘e’, ‘i’, ‘o’, ‘u’.
Pictorial Presentation:
Program-
import random
char_list = ['a','e','i','o','u']
random.shuffle(char_list)
print(''.join(char_list))
Program Output-
iauoe
DATA ANALYTICS BTIRT 0608CS203D06
EXPERIMENT – 7
Aim- Write a python program to remove and print every third number
from a list of numbers until the list become empty.
Program-
def remove_nums(int_list):
#list starts with 0 index
position = 3 - 1
idx = 0
len_list = (len(int_list))
while len_list>0:
idx = (position+idx)%len_list
print(int_list.pop(idx))
len_list -= 1
nums = [10,20,30,40,50,60,70,80,90]
remove_nums(nums)
Program Output-
30
60
90
40
80
50
20
70
10
DATA ANALYTICS BTIRT 0608CS203D06
Program Output-
0
0
0
0
DATA ANALYTICS BTIRT 0608CS203D06
Program-
print("Input two integers(a b): ")
a,b = map(int,input().split(" "))
print("Number of digit of a and b.:")
print(len(str(a+b)))
Program Output-
Input two integers(a b):
57
Number of digit of a and b.:
2
DATA ANALYTICS BTIRT 0608CS203D06
my_nums = [1,2,3]
print("Original Cofllection: ",my_nums)
print("Collection of distinct numbers:\n",permute(my_nums))
Program Output-
Original Collection: [1, 2, 3]
Collection of distinct numbers: [[3, 2, 1], [2, 3, 1], [2, 1, 3], [3, 1, 2], [1, 3, 2], [1, 2, 3]]