0% found this document useful (0 votes)
21 views

Prankush DSA-pages-deleted

Uploaded by

Krishanu Ghosh
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)
21 views

Prankush DSA-pages-deleted

Uploaded by

Krishanu Ghosh
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/ 17

Data Structures and Algorithm-LAB

ONLINE and OFFLINE


Assignments merged report

Submitted by:-

NAME- PRANKUSH GIRI


ROLL/SEC – 36/F
ENROLLMENT – 12020009022155
Paper name - Data Structures and Algorithms Laboratory
Paper Code- PCCCS391
TABLE OF CONTENTS
Sl no. TOPIC Date of Assignment
ONLINE
1. Python Programming Day 1 13.07.2021
2. Python Programming Day 2 23.07.2021
3. Basics of c programming Day 3 28.07.2021
4. Basics of c programming and pointers Day 4 04.08.2021
5. Structure in C basics Day 5 11.08.2021
6. Singly/Double/Circular Link List Day 6 18.08.2021
7. Operations with pointer in Link Lists Day 7 25.08.2021
8. Stack operations in C Day 8 25.08.2021
9. QUEUE operations in C DAY 9 22.09.2021
10. Problem solving in C Day 10 29.09.2021
11. TREES programming in C DAY 11 01.10.2021

OFFLINE
1. (Searching/Sorting) 18.11.2021
2. Stack and QUEUE 23.11.2021
3. Problem Solving in Python 30.11.2021
Data Structures and Algorithm
LAB date 13.07.2021 SEC - F

Assignment 01

NAME- PRANKUSH GIRI


ROLL/SEC – 36/F
ENROLLMENT - 12020009022155
Source code is in text format not as image
1) Write a Python program to find those numbers which are divisible by 7 and multiple of 5, between
1500 and 2700 (both included).

INPUT:
Case 1:
Enter the lower range:1500
Enter the upper range:2700
OUTPUT:
1505,1540,1575,1610,1645,1680,1715,1750,1785,1820,1855,1890,1925,1960,1995,2030,2065,210
0,2135,2170,2205,2240,2275,2310,2345,2380,2415,2450,2485,2520,2555,2590,2625,2660,2695

#copyright @PRANKUSH
l= int(input("Enter the lower range: "))
r= int(input("Enter the upper range: "))
# accepting input from user
list=[]
# declaring blank list
for i in range(l,r):
if(i%7==0 and i%5==0):
list.append(str(i))
print(",".join(list))

Output
2) Write a Python program to convert temperatures to and from celsius, fahrenheit.
[ Formula : c/5 = f-32/9 [ where c = temperature in celsius and f = temperature in fahrenheit ]
INPUT: 60°C
OUTPUT:140 in Fahrenheit

#copyright @PRANKUSH
c=int(input("Enter temperature in Celcius"))
# taking user input
f=int((c*1.8) + 32)
print(f,"in Fahrenheit")

Output
3) Write a Python program to guess a number between 1 to 9.
INPUT:
Guess a number between 1 and 10 until you get it right : 5
OUTPUT:
Well guessed!

Note : User is prompted to enter a guess. If the user guesses wrong then the prompt appears again until the
guess is correct, on successful guess, user will get a "Well guessed!" message, and the program will exit.

#copyright @PRANKUSH
import random
a=999
r=random.randint(1,10)
while(r!=a):
a=int(input('Guess a number between 1 and 10 until you get it right : '))
print('Well guessed!')

Output
4) Write a Python program that accepts a word from the user and reverse it.
INPUT: Input a word to reverse: ecruoser3w

OUTPUT: w3resource

#copyright @PRANKUSH
s1=input('Input a word to reverse: ')
l=len(s1)
print(s1[::-1])

Output
5) Write a Python program to count the number of even and odd numbers from a series of numbers.
Input: numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9)
Expected Output :
Number of even numbers : 5
Number of odd numbers : 4

#copyright @PRANKUSH
numbers=(1,2,3,4,5,6,7,8,9)
ctr=0
ctr2=0
for i in numbers:
if(i%2==0):
ctr=ctr+1
# counting the even numbers
else:
ctr2=ctr2+1
# counting the odd numbers
print('Number of even numbers : ',ctr)
print('Number of odd numbers : ',ctr2 )

Output
6) Write a Python program that prints each item and its corresponding type from the following list.
INPUT:
datalist = [1452, 11.23, 1+2j, True, 'w3resource', (0, -1), [5, 12], {"class":'V', "section":'A'}]
OUTPUT:
Type of 1452 is <class 'int'>
Type of 11.23 is <class 'float'>
Type of (1+2j) is <class 'complex'>
Type of True is <class 'bool'>
Type of w3resource is <class 'str'>
Type of (0, -1) is <class 'tuple'>
Type of [5, 12] is <class 'list'>
Type of {'class': 'V', 'section': 'A'} is < class 'dict'>

#copyright @PRANKUSH
datalist = [1452, 11.23, 1+2j, True, 'w3resource', (0, -1), [5, 12], {"class":'V', "section":'A'}]
for i in datalist:
print("Type of", i,"is ", type(i))

Output
7) Write a Python program that prints all the numbers from 0 to 6 except 3 and 6.
Note : Use 'continue' statement.

Input:6
Expected Output : 0 1 2 4 5

#copyright @PRANKUSH
set=(0,1,2,3,4,5,6)
for i in set:
if(i==3 or i==6):
continue
print(i,end=' ')

Output
8) Write a Python program to get the Fibonacci series between 0 to
50.
Note : The Fibonacci Sequence is the series of numbers :
0, 1, 1, 2, 3, 5, 8, 13, 21, ....
Every next number is found by adding up the two numbers before
it.
INPUT: 50
Expected Output : 1 1 2 3 5 8 13 21 34

#copyright @PRANKUSH
n=int(input('Enter the nth term : '))
a=0
b=1
sum=0
while(sum<n):
print(sum,end=' ')
a=b
b=sum
sum=a+b

Output
9) Write a Python program which iterates the integers from 1 to 50. For multiples of three print "Fizz"
instead of the number and for the multiples of five print "Buzz". For numbers which are multiples
of both three and five print "FizzBuzz".
Input:
Enter no:51
Sample Output :
fizzbuzz
1
2
fizz
4
buzz
#copyright @PRANKUSH
n=int(input('Enter a number: '))
for i in range(0,n):
if(i%3==0 and i%5==0):
print('fizzbuzz')
continue
elif(i%3==0):
print("fizz")
continue
elif(i%5==0):
print("buzz")
continue
print(i)

Output
10) Python program to check whether the string is Symmetrical or Palindrome
Input: khokho
Output:
The entered string is symmetrical
The entered string is not palindrome
#copyright @PRANKUSH
def ispalindrome(s1):
s2=s1[::-1]
if(s1==s2):
return 1
else:
return 0

def issymetry(s1):
l=len(s1)

if(l%2==0):
mid=l//2
else:
mid=l//2 + 1
s2=s1[0:mid]
s3=s1[mid:l]

if(s2==s3):
return 1
else:
return 0

s1=input(("Enter a string : "))


palin=ispalindrome(s1)
symmetry=issymetry(s1)

if(symmetry==1):
print('The entered string is symmetrical')
else:
print('The entered string is not symmetrical')
if(palin==1):
print('The entered string is palindrome')
else:
print('The entered string is not palindrome')

Output
11) Reverse words in a given String in Python
Input : str = geeks quiz practice code
Output : str = code practice quiz geeks

#copyright @PRANKUSH
s1=input(('Enter a String : '))
word=s1.split(' ')
rev=' '.join(reversed(word))
print(rev)

Output

12) Python program to capitalize the first and last character of each word in a string
Input: hello world
Output: HellO WorlD
#copyright @PRANKUSH
s1=input()
s1=s1.split(' ')
s2=""
w,c=0,0
for w in s1:
l=len(w)
for c in range(l):
if(c==0 or c==(l-1)):
s2=s2+w[c].upper()
else:
s2=s2+w[c]
s2=s2+" "
print(s2)
Output

13) Python program to check if a string has at least one letter and one number
Input: welcome2ourcountry34
Output: True

#copyright @PRANKUSH
s1=input()
bool=(any(chr.isdigit() for chr in s1))
bool1=(any(chr.islower() for chr in s1))

if(bool==True and bool1==True):


print("True")
else:
print("False")

Output
14) Python program to count number of vowels using sets in given string
Input : GeeksforGeeks
Output : No. of vowels : 5

#copyright @PRANKUSH
s1 = ("GeeksforGeeks")
ctr = 0
v = set("aeiouAEIOU")
for i in s1:
if i in v:
ctr = ctr + 1
print("Output : No. of vowels :", ctr)

Output
15) Python program to split and join a string
Input: ['Geeks', 'for', 'Geeks']
Output: Geeks-for-Geeks

#copyright @PRANKUSH
s1=input()
w=s1.split(' ')
s2='-'.join(w)
print(s2)
Output

You might also like