Difficulty: Low
Title: Short + Long + Short
Description:
Write a program that prompts a user for two strings. Determine the length of the two strings and output a string in the following order: short + long + short
Output:
Input a string: Hello
Input a string: Bye
ByeHelloBye
Difficulty: Low
Title: Lowercase and Uppercase
Description:
Based upon user input of a sentence, replace lowercase characters with uppercase and vice versa.
Output:
Input a string: This Is A Sample Sentence
New sentence: tHIS iS a sAMPLE sENTENCE
Difficulty: Low
Title: First & Last Character
Description:
Write a program to prompt the user for a word. Take the inputted word / string and if the word is 5 or more characters only output the first 3 and last 2 characters of a given string. If the string length is less than 5, print the original string instead.
Output:
Input a string: abcdefg
abcfg
Difficulty: Medium
Title: Type of Characters
Description:
NOTE: Do not use lists / arrays to solve this. Just use String methods, loops, and conditionals.
Prompt the user for a String and count the total number of alphabets, digits and special characters in a string.
txt = "Hello"
txt.isalpha()
nbr = 12345
nbr.isdigit()
Output:
Input the string : W3lc0me to p3ri0d 3 Pr0gramming Fundam3ntals!!
Number of alpha characters: 32
Number of digits: 7
Number of special characters: 2
Difficulty: Medium
Title: Longest and Shortest Word
Description:
Write a program that prompts a user for a sentence. Find the largest and smallest words in the sentence.
Output:
Input a string: It is a string with smallest and largest word
Largest word: smallest
Smallest word: a
Difficulty: Medium
Title: Replacing Characters
Description:
Write a program to replace specified characters with another character.
Output:
Input a string: hello
Input character to replace: e
Input character to replace with: $
h$llo
Difficulty: High
Title: String Menu Option
Description:
NOTE: Do not use lists / arrays to solve this. Just use String methods, loops, and conditionals.
Create a program that has a menu option that solves simple String programs. The menu option input must be an integer and if the user does not enter one of the following options re-prompt the user till they enter one of the following menu options.
Output:
Choose from the following menu options
1 - Remove odd characters
2 - Reverse the String
3 - Uppercase a String
4 - Sort alphabetically
5 - Word swap
Choose an option: 1
Input a string: hello
hlo
Difficulty: High
Title: How Many Times
Description:
NOTE: Do not use lists / arrays to solve this. Just use String methods, loops, and conditionals
NOTE: The count() function will find every occurrence of a word, even if it part of another word (ex. he is found in the, shell, etc.). Instead to pass all the tests students will need to look at each individual word.
Prompt the user for a sentence and a word to find. Output the number of times that the word to find appears in the sentence as its own word.
Output:
Input a string: I felt happy because I saw the others were happy and because I knew I should feel happy, but I wasn’t really happy.
Word to find: happy
Count: 4