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

Part B Format python

The document is a lab manual for a Python course at SVKM’s NMIMS University, detailing various programming tasks and exercises for students. It includes code snippets for string manipulation, list operations, and character counting, among others. The manual concludes with a reflection on the advanced topics learned, such as lists and string functions.

Uploaded by

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

Part B Format python

The document is a lab manual for a Python course at SVKM’s NMIMS University, detailing various programming tasks and exercises for students. It includes code snippets for string manipulation, list operations, and character counting, among others. The manual concludes with a reflection on the advanced topics learned, such as lists and string functions.

Uploaded by

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

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering


COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

Experiment – 3

Roll No. C 168 Name: Simone Goyal

Program: BTI Division: D

Semester: IV Batch: D2

Date of Experiment: 28/1/25 Date of Submission: 29/1/25

Grade:

1
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

B.1. Software Code written by student:

string=input("Enter string ")


Task 1: print(string[::-1])
a
string=input("Enter the word ")
b print(string[::2])

string=input("Enter string ")


c char=input("Enter the char u wanna check ")

print(string.startswith(char))

sentence="""Python
d basics """

print(sentence.replace('\n',''))

string=input("Enter string ")


e char=input("Enter the char u wanna remove ")

char_1=input("Enter the char with u want to replace with ")

print(string.replace(char,char_1))

punctuations=[',','.','?','!']
f sentence=input("Enter string ")

for x in punctuations:

sentence=sentence.replace(x,'')

print(sentence)

sentence1=input("Enter 1st string ")


g sentence2=input("Enter 2nd string ")

char=input("Enter the char u wanna search for ")

if(sentence1.count(char)>=sentence2.count(char)):

print(f"there are {sentence2.count(char)} characters common")

elif(sentence1.count(char)<sentence2.count(char)):

print(f"there are {sentence1.count(char)} characters common")

2
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

sentence=input("Enter string ")


h list=[]

list.extend(sentence)

print(list)

sentence=input("Enter nos ")


i list=[]

for x in sentence:

list.append(int(x))

print(list)

string=input("Enter string ")


j count_u=0

count_l=0

for x in string:

if(x.isupper()):

count_u=count_u+1

elif(x.islower()):

count_l=1+count_l

print(f"Upper count is {count_u} and lower count is {count_l}")

vowels=['a','e','i','o','u']
k string=input("Enter string ")

string=string.lower()

for x in string:

if(x in vowels):

print(x,end=" ")

list=["banana","apple","dragon","cheese"]
l list.sort()

print(list)

3
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

string=input("Enter string ")


m print("Upper case is",string.upper())

print("Lower case is",string.lower())

number=int(input("Enter number"))
n string=str(number)

print("The type is",type(string))

Task 2: str1=input("Enter the string: ")

str2=str1.replace(' ','#')

print("the new string is ",str2)

Task 3: str1="python is fun"

str2="basics of python"

str1.lower()

str2.lower()

words1=str1.split()

words2=str2.split()

common_words=[]

for word in words1:

if word in words2:

common_words.append(word)

if common_words:

print("the common words are: ",common_words)

else:

print("no common words found")

4
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

Task 4: sent=input("Enter your string ")

sent=sent.lower()

count_a=0

count_e=0

count_i=0

count_o=0

count_u=0

for x in sent:

if(x=='a'):

count_a+=1

elif(x=='e'):

count_e+=1

elif(x=='i'):

count_i+=1

elif(x=='o'):

count_o+=1

elif(x=='u'):

count_u+=1

print(f"No of a is {count_a}\nNo of e is {count_e}\nNo of i is {count_i}\nNo of o is


{count_o}\nNo of u is {count_u}")

5
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

Task 5: bill=["234","546","9532"]

bill.append("1234")

print(bill)

bill[1]=1200

print(bill)

bill.remove(1200)

print(bill)

bill.clear()

print(bill)

bill=["234","546","9532","12345"]

print(bill[0:2])

bill.pop(2)

print(bill)

x=input("Enter the number of u want it to search")

count=0

for y in bill:

if(y==x):

count+=1

print(f"{x} appeares {count} times in the list")

bill.sort()

print(bill)

print(bill[-1::-1])

Task 6: list=["abc","12","simone","yo","12","abc"]

search=(input("Enter the value you want to search"))

count=0

6
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

for x in list:

if(search==x):

count+=1

print(f"The vlaue {search} appears {count} times")

Task 7: list=["1","1","1","2","2","3","5"]

temp=[]

for x in list:

if(x in temp):

continue

print(x,end=" ")

temp.append(x)

Task 8: list=[-9,-3,2,3,0,-2]

count_pos=0

count_neg=0

for x in list:

if(x>0):

count_pos+=1

elif(x<0):

count_neg+=1

print(f"The number of positive numbers is {count_pos}, negativee nos is {count_neg}")

Task 9: list=[1,2,3,4,5]

sum=0

for x in list:

sum+=x

print("The sum of all elements is",sum)

7
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

Task list=["hi","cheese","yo","hey","burger"]
10:
list2=[]

n=int(input("Enter the minimum size of the words "))

for x in list:

if(len(x)>=n):

list2.append(x)

print(list2)

Task list1=["red", "orange", "green", "blue", "white"]


11:
list2=["black", "yellow", "green", "blue"]

temp1=[]

temp1=list1.copy()

for x in list2:

for y in list1:

if(y==x):

list1.remove(y)

print("colour1-colour2=",list1)

for x in temp1:

for y in list2:

if(y==x):

list2.remove(y)

print("colour2-colour1=",list2)

Task list=["1","2","3","Simone"]
12:
string=''

for x in list:

string=string+x

8
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

print(string)

Task list=["1","2","3"]
13:
list_2=[]

string=input("Enter string ")

for x in list:

temp=string+x

list_2.append(temp)

print(list_2)

Task list2d=[1,1,1],[3,3,3,],[4,4,4,],[2,2,2]
14:
sums=[]

for x in list2d:

sum=0

for y in x:

sum+=y

sums.append(sum)

maximum=max(sums)

index=sums.index(maximum)

print(list2d[index][::],"is the list with highest sum")

9
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

B.2 Input and Output:


(Paste your program input and output in following format. If there is error then paste the
specific error in the output part. In case of error with due permission of the faculty extension
can be given to submit the error free code with output in due course of time. Students will be
graded accordingly.)

Task 1:
a

Figure 1-Task 1-A

Figure 2-Task 1-B

Figure 3-Task 1-C

Figure 4-Task 1-D

10
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

Figure 5-Task 1-E

Figure 6-Task 1-F

Figure 7-Task 1-G

Figure 8-Task 1-H

Figure 9-Task 1-I

11
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

Figure 10-Task 1-J

Figure 11-Task 1-K

Figure 12-Task 1-L

Figure 13-Task 1-M

Figure 14-Task 1-N

12
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

Task 2:

Figure 15-Task 2

Task 3:

Figure 16-Task 3

Task 4:

Figure 17-Task 4

13
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

Task 5:

Figure 18-Task 5

Task 6:

Figure 19-Task 6

Task 7:

Figure 20-Task 7

Task 8:

Figure 21-Task 8

Task 9:

Figure 22-Task 9

14
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

Task
10:

Figure 23-Task 10

Task
11:

Figure 24-Task 11

Task
12:

Figure 25-Task 12

Task
13:

Figure 26-Task 13

Task
14:

Figure 27-Task 14

B.3 Conclusion:

We learnt advanced topic like lists, appending, string, string functions etc.

15
SVKM’s NMIMS University
Mukesh Patel School of Technology Management & Engineering
COURSE: Basics of Python Lab Manual
BTI Sem IV Academic Year 2024-2025

16

You might also like