Python Strings Assignment
Part 1: Understanding String Literals
1. Create three different strings using each type of quotation:
o Single quotes ('example')
o Double quotes ("example")
o Triple quotes ("""example""")
2. Explain in your own words: What is the advantage of each type of quotation?
3. Write a string that contains both single and double quotes inside it. Example: She said,
"I'm going to the store."
4. Create a multi-line string using triple quotes that describes your favorite hobby.
Part 2: String Methods Practice
1. Create a variable full_name with your full name (first and last name). Then write code
to:
o Print your name in all uppercase letters
o Print your name in all lowercase letters
o Print your name with the first letter of each name capitalized
2. Create a variable messy_text = " Python programming is fun! " Then write code
to:
o Remove all the extra spaces at the beginning and end
o Replace "fun" with "amazing"
o Count how many times the letter 'i' appears
3. Create a variable sentence = "The quick brown fox jumps over the lazy dog"
Then write code to:
o Split this sentence into a list of words
o Join the words back together with dashes between them
o Check if the sentence starts with "The"
o Find the position of the word "fox"
Part 3: F-Strings
1. Create variables for:
o Your name
o Your age
o Your favorite programming language
Then use f-strings to create these sentences:
o "My name is {your_name} and I am {your_age} years old."
o "I enjoy programming in {language}, it's my favorite!"
o Create a math expression inside an f-string: "In 5 years, I will be {age + 5} years
old."
Part 4: Combining String Methods with F-Strings
Create a program that:
1. Asks for user input about their first name, last name, and birth year
2. Uses string methods to properly capitalize their name
3. Uses f-strings to create a profile message: "Profile: {First Last}, Age: {calculated age},
Username: {first initial + last name + birth year}"