[go: up one dir, main page]

0% found this document useful (0 votes)
9 views6 pages

Python Week 4

Uploaded by

24071a6225
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)
9 views6 pages

Python Week 4

Uploaded by

24071a6225
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/ 6

• Check String Palindrome:

s=input() O/P:
s=s.replace(" ","").lower() Input:
if s==s[::-1]: race a car
print("Yes") Actual Output:
else: No
print("No")

• Remove Word from String:

O/P:
Input:
apple apple apple
apple
Expected Output:
Empty String

• Generate N-Bit Binary Strings:

Input:
2
Expected Output:
00
01
10
11

• Implement Set Operations:


Input:
4
1234
3
345
Expected Output:
12345
34
12
125
• Is List Sorted Checker:

Input:
5
12345
Expected Output:
True

• Duplicate Element Checker:

def has_duplicates(lst):
Duplicates found!
return len(lst) != len(set(lst))
numbers = [1, 2, 3, 4, 5, 2]
if has_duplicates(numbers):
print("Duplicates found!")
else:
print("No duplicates.")

• Capitalize First Letter of Words:

text = input("Enter a sentence: ") Enter a sentence: hello world


capitalized_text = text.title() from python
Capitalized: Hello World From
print("Capitalized:",capitalized_te Python
xt)

• Remove Duplicates from List:

Input:
6
135371
Expected Output:
1357
• Add Commas Between Characters:

Input:
Apple
Expected Output:
A,p,p,l,e

You might also like