Strings Homework

In this homework assigment, you will practice working with and manipulating strings. You will manipulat names, quotes, and word phrases through concatenation, slicing, replace etc. Some parts of this homework will guide you through the process, while others are meant to be open ended to give you room to be creative. The goal is to streghthen your understanding of strings in a creative and interavtice format.

Part 1: String Basics

# Step 1: Define your variables
full_name = "___"  # <-- Fill in your full name (first and last)

# Step 2: Extract first and last name
first_name = ___   # Use slicing or indexing
last_name = ___    # Use slicing or indexing

# Step 3: Create initials
initials = ___     # Combine first letters of first and last name

# Step 4: Count total characters in your first name, last name, and full name
first_length = ___
last_length = ___
full_length = ___

# Step 5: Print greetings using concatenation and f-strings
# Example: "Hello, Tanay Paranjpe!"
greeting1 = ___  # Use + for concatenation
greeting2 = ___  # Use f-string

# Step 6: Reverse your first and last name using slicing
reversed_first = ___
reversed_last = ___

# Step 7: Print everything
print("First name:", first_name)
print("Last name:", last_name)
print("Initials:", initials)
print("First name length:", first_length)
print("Last name length:", last_length)
print("Full name length:", full_length)
print("Greeting using + :", greeting1)
print("Greeting using f-string:", greeting2)
print("Reversed first name:", reversed_first)
print("Reversed last name:", reversed_last)

Part 2: Addtional Practice

# Step 1: Define short sentence or quote
quote = "___"  # <-- Add your short sentence or quote here

# Step 2: Manipulate the string 
# 1. Convert the string to uppercase
upper_quote = ___

# 2. Convert the string to lowercase
lower_quote = ___

# 3. Replace a word or phrase with something new
modified_quote = ___

# 4. Count total characters and total words
quote_length = ___  # Use len()
word_count = ___    # Hint: split() can help

# 5. Count how many times a specific letter appears
letter_count = ___  # Hint: use .count("a") for example

# 6. Check if a word exists in the quote
word_check = ___    # Hint: use "in" (e.g., "Python" in quote)

# 7. Your Turn: Extract a word or part of the quote using slicing
excerpt = ___

# 8. Combine this quote with other strings
# For example, adding your first/last name from Task 1
bio_or_story = ___

# 9. Optional: Make a multi-line string using triple quotes
multi_line_quote = """___"""  # Rewrite or expand your quote

# 10. Creative Challenge: 
# - Rearrange the words in your quote to make a new sentence
# - Add symbols or punctuation
# - Combine multiple quotes into one paragraph
creative_version = "___"  # Create your own version

# Step 3: Print all results
print("Uppercase version:", upper_quote)
print("Lowercase version:", lower_quote)
print("Modified version:", modified_quote)
print("Total characters:", quote_length)
print("Total words:", word_count)
print("Letter count (example 'a'):", letter_count)
print("Check if a word exists:", word_check)
print("Excerpt (optional):", excerpt)
print("Creative combination (optional):", bio_or_story)
print("Multi-line version (optional):", multi_line_quote)