Lab 3
Lab 3
Computer Engineering
01CE1705 – Programming with Python– Lab Manual
PRACTICAL-3
Source Code:
def is_palindrome(input_string):
else:
print("The given string is not a palindrome.")
Output:
1
FACULTY OF TECHNOLOGY
Computer Engineering
01CE1705 – Programming with Python– Lab Manual
Source Code:
def reverse_string(input_string):
# Printing the string in reverse order
print("Reversed string:", input_string[::-1])
def odd_indexed_characters(input_string):
# Printing all the odd indexed characters of the string
print("Odd indexed characters:", input_string[1::2])
def count_vowels(input_string):
# Counting the number of vowels in the string
vowels = "aeiouAEIOU"
vowel_count = sum(1 for char in input_string if char in vowels)
print("Count of vowels:", vowel_count)
def main():
input_string = input("Enter a string: ")
reverse_string(input_string)
odd_indexed_characters(input_string)
count_vowels(input_string)
2
FACULTY OF TECHNOLOGY
Computer Engineering
01CE1705 – Programming with Python– Lab Manual
main()
Output: