Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Exam (python lab )

Rating
-
Sold
-
Pages
20
Grade
A+
Uploaded on
29-12-2024
Written in
2024/2025

It contains some practical python lab program question and answer which can be very helpful for students.

Institution
Course

Content preview

BCA203P- Python Programming



Part A
1. Write a python Program To find “Anagram” and “Palindrome”

Code:
print("****Anagram****")
s1 =input("Enter string1 ")
s2 =input("Enter string2")

def anagram_check(s1, s2):
if(sorted(s1)== sorted(s2)):
print("The strings are anagrams.")
else:
print("The strings aren't anagrams.")
anagram_check(s1, s2)

print("****palindrome****")
p1=input("Enter string to check palindrome ")
def palind_check(p1):
rev_p=p1[::-1]
if p1==rev_p:
print("It's a palindrome")
else:
print("It's not a palindrome")

palind_check(p1)

, 2. Write a python program to Demonstrate linear search.



Code:

list1=[]

#input the number of elements

n=int(input("enter the number of elements: "))

print("Enter the elements")

for i in range(n):

ele=int(input())

list1.append(ele)

print("list elemens are : " , list1)

# input the key to be searched

key=int(input("enter the key to be searched"))

def linear_Search(list1,n,key):

for i in range(0,n):

if list1[i]==key:

return i

return -1

print("______Linear Search_____")

#perform the linear search

res=linear_Search(list1,n,key

if res== -1:

print("elements not found")

else:

print("elements found at index : ", res)

, 3. Write a Menu Driven Program to add and Delete Stationary items. Use
a Dictionary for Adding Items and Brands.
i. 1.Add an item to the stationaries
ii. 2.Remove an item from stationaries
iii. 3.Display stationery
iv. 4.exit
Code:
dict={}
print("Choose the Option from the Menu")
print("--------------------------------------------")
print("1.Add an item to the stationaries ")
print("2.Remove an item from stationaries ")
print("3.Display stationery ")
print("4.exit")
#key - brand
#value - item
ch=int(input("Enter your Choice: "))
while(ch!=5):
if ch==1:
brand=input("Enter the brand [key] to be inserted : ")
item=input("Enter the item to be inserted : ")
dict[brand]=item
print("Added successfully" )
elif ch==2:
brand=input("Enter the brand [key] to be deleted: ")
if brand in dict.keys():
del dict[brand]
print(" Deleted successfully" )
elif brand not in dict.keys():
print("invalid key")
elif ch==3:
print(dict)
elif ch==4:
print( "Exiting!!!!!")
break
else:
print("Invalid choice....!! Choose option between 1 to 4")
ch=int(input("Enter your choice: "))

Written for

Institution
Course

Document information

Uploaded on
December 29, 2024
Number of pages
20
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$9.89
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
sweetymanoj300

Get to know the seller

Seller avatar
sweetymanoj300 Yenepoya
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions