0% found this document useful (0 votes)
8 views2 pages

Untitled 93

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)
8 views2 pages

Untitled 93

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

lst = [10, 20, 30, 40, 50]

print("Original List: ", lst)


print("Reversed List: ", lst[::-1])

Original List: [10, 20, 30, 40, 50]


Reversed List: [50, 40, 30, 20, 10]

s = input("Enter a string: ")


print("Left to Right (alternate): ", s[::2])
print("Right to Left (alternate): ", s[::-2])

Enter a string: SCMIRT

Left to Right (alternate): SMR


Right to Left (alternate): TIC

s = input("Enter a string: ")


vowels = 'aeiouAEIOU'
v, c = 0, 0
for ch in s:
if [Link]():
if ch in vowels:
v += 1
else:
c += 1
print("Vowels: ", v)
print("Consonants: ", c)

Enter a string: hii

Vowels: 2
Consonants: 1

nums = []
for _ in range(5):
[Link](int(input("Enter number: ")))
if len(set(nums)) != len(nums):
print("DUPLICATES")
else:
print("ALL UNIQUE")

Enter number: 76436747654876487943274326549439843730187432785498754


Enter number:
98743764898754398765498043298043876543980465498654398047
Enter number: 985438543704254980
Enter number: 987498743875347985
Enter number: 4738754376594387543

ALL UNIQUE

s = '[Link]'
freq = {}
for ch in s:
freq[ch] = [Link](ch, 0) + 1
print(freq)

{'g': 2, 'o': 3, 'l': 1, 'e': 1, '.': 1, 'c': 1, 'm': 1}

s = input("Enter string: ")


print("New string: ", s[::2])

Enter string: hfgdkjsggkdsfgsjkalddddddddg

New string: hgksgdfskldddd

stack = []
[Link](10)
[Link](20)
print("Popped item: ", [Link]())
print("Stack after pop: ", stack)

Popped item: 20
Stack after pop: [10]

s = "restart"
first = s[0]
modified = first + s[1:].replace(first, "$")
print("Modified string: ", modified)

You might also like