[go: up one dir, main page]

0% found this document useful (0 votes)
126 views16 pages

Babulal Tarabai Institute of Research and Technology, Sagar: Btirt

This document contains a lab manual for a Data Analytics course. It includes 10 experiments covering topics like recursion, Fibonacci numbers, checking if a triangle is right-angled, printing patterns, checking palindromes, permutations, and removing elements from lists. Each experiment has the aim, Python code, and output to solve problems related to these topics. The index provides the experiment number, name, and date to track progress.

Uploaded by

yogesh ahirwar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views16 pages

Babulal Tarabai Institute of Research and Technology, Sagar: Btirt

This document contains a lab manual for a Data Analytics course. It includes 10 experiments covering topics like recursion, Fibonacci numbers, checking if a triangle is right-angled, printing patterns, checking palindromes, permutations, and removing elements from lists. Each experiment has the aim, Python code, and output to solve problems related to these topics. The index provides the experiment number, name, and date to track progress.

Uploaded by

yogesh ahirwar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

DATA ANALYTICS BTIRT 0608CS203D06

MACHINE LEARNING BTIRT 0808CS191030


BABULAL TARABAI INSTITUTE
OF RESEARCH AND
TECHNOLOGY, SAGAR
COMPUTER SCIENCE & ENGINEERING
DEPARTMENT

LAB MANUAL
DATA ANALYTICS
(CS – 605)

SUBMITTED TO: SUBMITTED BY:


Miss Muskan Jain YOGESH AHIRWAR
(Asst. Professor) IIIrd Year VIth Sem
DATA ANALYTICS BTIRT 0608CS203D06

Enrollment No:
0608CS203D06
DATA ANALYTICS BTIRT 0608CS203D06

INDEX
List Of Experiments

S. No. Name of Experiment Date Grade Sign

Write a python program to define a module to find Fibonacci


1.
numbers and input the module to another program.
Write a python program to find factorial of a number using
2. recursion.
3. Write a python program that accepts length of sides of a triangle as
inputs & should indicate whether it is a right-angled triangle or not.
4. Python program to print a half diamond star pattern.

5. Program to check whether the string is symmetrical or palindrome.

6. Program to create all possible strings by using ‘a’, ‘e’, ‘i’, ‘o’, ‘u’.

7. Program to remove and print every third number from a list of


numbers until the list become empty.
8. Program that accept a +ve no. and subtract from this no., the sum of
its digits and so on. Continues this operation until the no. is +ve.
9. Program to compute the digit number of sum of two given
integers.
10. Program to create all possible permutation from a given collection
of distinct number.

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 input is 0 then it will


# print incorrect input
if n < 0:
print("Incorrect input")

# 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

# factorial of given number

def factorial(n):

# Checking the number

# is 1 or 0 then

# return 1

# other wise return

# factorial

if (n==1 or n==0):

return 1

else:

return (n * factorial(n - 1))

# 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

The length of the hypotenuse is: 5.0


DATA ANALYTICS BTIRT 0608CS203D06

EXPERIMENT – 4
Aim- Python program to print a half diamond star pattern.
Program-
# Python Program to Print Half Diamond Star Pattern

rows = int(input("Enter Half Diamond Pattern Rows = "))

print("Half Diamond Pattern")

i=0

while(i <= rows):

j=0

while(j < i):

print('*', end = '')

j=j+1

i=i+1

print()

i=1

while(i < rows):

j = i;

while(j < rows):

print('*', end = '')

j=j+1

i=i+1

print()
DATA ANALYTICS BTIRT 0608CS203D06

Program Output-

Enter Half Diamond Pattern Rows = 9

Half Diamond Pattern

**

***

****

*****

******

*******

********

*********

********

*******

******

*****

****

***

**

*
DATA ANALYTICS BTIRT 0608CS203D06

EXPERIMENT – 5
Aim- Python program to check whether the string is symmetrical or
palindrome.
Program-

# Python program to demonstrate

# symmetry and palindrome of the

# string

# Function to check whether the

# string is palindrome or not

def palindrome(a):

# finding the mid, start

# and last index of the string

mid = (len(a)-1)//2

#you can remove the -1 or you add <= sign in line 21

start = 0

#so that you can compare the middle elements also.

last = len(a)-1

flag = 0

# A loop till the mid of the

# string

while(start <= mid):

# comparing letters from right

# from the letters from left


DATA ANALYTICS BTIRT 0608CS203D06

if (a[start]== a[last]):

start += 1

last -= 1

else:

flag = 1

break;

# Checking the flag variable to

# check if the string is palindrome

# or not

if flag == 0:

print("The entered string is palindrome")

else:

print("The entered string is not palindrome")

# Function to check whether the

# string is symmetrical or not

def symmetry(a):

n = len(a)

flag = 0

# Check if the string's length

# is odd or even

if n%2:

mid = n//2 +1
DATA ANALYTICS BTIRT 0608CS203D06

else:

mid = n//2

start1 = 0

start2 = mid

while(start1 < mid and start2 < n):

if (a[start1]== a[start2]):

start1 = start1 + 1
start2 = start2 + 1

else:
flag = 1
break

# Checking the flag variable to

# check if the string is symmetrical

# or not

if flag == 0:

print("The entered string is symmetrical")

else:

print("The entered string is not symmetrical")

# 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

Aim- Write a python program that accept a positive number and


subtract from this number, the sum of its digits and so on. Continues
this operation until the number is positive.
Program-
def repeat_times(n):
n_str = str(n)
while (n > 0):
n -= sum([int(i) for i in list(n_str)])
n_str = list(str(n))
return n
print(repeat_times(9))
print(repeat_times(20))
print(repeat_times(110))
print(repeat_times(5674))

Program Output-
0
0
0
0
DATA ANALYTICS BTIRT 0608CS203D06

Aim- Write a python program to compute the digit number of sum of


two given integers.
Input:-
Each test case consist of two non- negative integers x and y while are
separated by a space in a line.
0<=x,y<=100000
Input two integers (a,b):57
Sum of two integers a and b:
Pictorial Presentation:

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

Aim- Write a python program to create all possible permutation from


a given collection of distinct number.
Program-
def permute(nums):
result_perms = [[]]
for n in nums:
new_perms = []
for perm in result_perms:
for i in range(len(perm)+1):
new_perms.append(perm[:i] + [n] + perm[i:])
result_perms = new_perms
return result_perms

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]]

You might also like