Sting Questions
Sting Questions
2. Create a program that checks if a string starts with the letter 'H' and ends with the letter 'e'. Use `if-
else` statements.
3. Write a program that loops through a string and prints only the uppercase letters.
4. Using a loop, write a program that replaces every occurrence of the word "Hello" with "Hi" in a given
string.
5. Create a program that counts the number of vowels (a, e, i, o, u) in the string `"Hello EveryOne"`.
6. Write a program that uses a loop to concatenate the first letter of each word in the string `"Hello
EveryOne"` to form a new string.
7. Create a program that checks if a string is a palindrome (reads the same backward as forward). Use `if-
else` statements.
8. Write a program that trims any extra spaces at the beginning and end of a string and then checks if the
string is empty.
9. Using a loop, write a program that converts every letter in a string to lowercase if it’s uppercase, and
to uppercase if it’s lowercase.
10. Write a program that slices the first 5 characters of a string and checks if this substring is equal to
`"Hello"`.
11. Create a program that replaces every vowel in a string with an asterisk (*) using a loop.
12. Write a program that checks if a string contains the word `"Hello"` using `if-else` statements. If it
does, replace it with `"Hi"`.
13. Using a loop, write a program that counts the number of spaces in the string `"Hello EveryOne"`.
14. Write a program that checks if the length of a string is greater than 10. If it is, print the string in
uppercase; otherwise, print it in lowercase.
15. Create a program that loops through a string and prints the index of each letter 'o' in the string
`"Hello EveryOne"`.
16. Write a program that trims a string, then checks if its length is even or odd using `if-else` statements.
17. Using a loop, write a program that checks if the first and last characters of a string are the same. Use
`if-else` statements to print the result.
18. Write a program that replaces the first 3 characters of a string with "ABC" using slicing and `if-else`
statements.
19. Create a program that uses a loop to reverse a string and print the reversed string.
20. Write a program that counts how many times a substring `"One"` appears in the string `"Hello
EveryOne"` using a loop.