PRACTICE QUESTIONS
PRACTICE QUESTIONS
1)
def reverse_string(s):
return s[::-1]
OUTPUT:
2)
return s.count(char)
character = 'o'
OUTPUT:
3) def is_palindrome(s):
return s == s[::-1]
input_string = "madam"
OUTPUT:
4)
def replace_substring(s, old, new):
OUTPUT:
5)
def count_vowels_consonants(s):
vowels = "aeiouAEIOU"
OUTPUT:
6)
def remove_whitespace(s):
OUTPUT:
7)
def count_words(s):
return len(s.split())
OUTPUT:
8)
def are_all_digits(s):
return s.isdigit()
input_string = "123456"
OUTPUT:
9)
def is_alphanumeric(s):
return s.isalnum()
input_string = "Hello123"
OUTPUT:
10)
def longest_word(s):
words = s.split()
return max(words, key=len)
input_string = "The quick brown fox jumped over the lazy dog"
OUTPUT: