Session 2 - Strings Flashcards
Strings (12 cards)
String Length (2mins)
Ask the user to enter any word, and print how many characters it has.
Input: banana
Output:
Length: 6
A
Uppercase (2mins)
Ask the user for a sentence and print it in uppercase.
Input: Python is fun
Output:
PYTHON IS FUN
A
Lowercase (2mins)
Ask the user for two numbers and print their sum.
Input 1: HELLO THERE
Output:
hello there
Replace a Word (2mins)
Ask the user for a sentence and replace the word “Java” with “Python”.
Input 1: I love Java
Output:
I love Python
A
Slice a String (2mins)
Ask the user for a word and print only the first 3 letters.
Input 1: Programming
Output:
Pro
A
Substring Check (2mins)
Ask the user to enter a sentence and check if the word “Python” is in it.
Input 1: I am learning Python today
Output:
True
A
Reverse a String (2mins)
Ask the user to enter a word and print it reversed.
Input 1: hello
Output: olleh
A
Count Letters (2mins)
Ask the user to enter a sentence and count how many times the letter “a” appears.
Input 1: Apples are amazing
Output:
The letter ‘a’ appears 4 times.
A
Combine Input and Formatting (2mins)
Ask the user for their city and print a welcome message.
Input 1: Toronto
Output:
Welcome to Toronto!
A
Split a Sentence into Words (2mins)
Split a sentence into a list of words.
Input 1: Split this sentence
Output:
[‘Split’, ‘this’, ‘sentence’]
A
Join a List of Words into a Sentence (2mins)
Join words from a list into one space-separated string.
Input 1: [“Python”, “is”, “awesome”]
Output:
Python is awesome
A
Join a List of Words into a Sentence separated by commas (2mins)
Ask the user to input strings separated by commas
Input 1: Python,is,awesome
Output:
Python is awesome
A