MIND CRAFT ACADEMY
Python Programming Sheet: String Modification, Methods & Printing
Part 1: Quick Reference
1. Methods for Printing & Combining Strings
• The standard print() Function: Used to output text directly to your screen (terminal). Text must be
placed inside quotation marks.
print("Hello World") # Output: Hello World
• The f-string (Formatted String): By putting the letter f right before the opening quotation mark, you can
easily plug data or numbers directly inside curly braces {} without explicit conversion errors.
print(f"I am {15} years old.") # Output: I am 15 years old.
• The + Operator: Glues strings together exactly as they are without adding automatic spaces.
a = "Hello"
b = "World"
print(a + " " + b) # Output: Hello World (Requires manual space string)
• The Comma Separation ( , ): Pairs multiple data elements, automatically converts numbers to text, and
inserts a blank space separator between items.
print("I am", 20, "years old.") # Output: I am 20 years old.
2. Modifying & Analyzing Strings (Built-in Methods)
Python features handy tools to analyze characters, modify cases, or clean up trailing/leading spaces:
text = " mindcraft "
• [Link]() — Converts text to uppercase.
print([Link]()) # Output: " MINDCRAFT "
• [Link]() — Converts text to lowercase.
print([Link]()) # Output: " mindcraft "
• [Link]() — Removes leading and trailing spaces completely.
print([Link]()) # Output: "mindcraft"
Mind Craft Academy • Python Programming Page 1 of 3
• len(string) — A built-in function that returns the total count of characters in a string (including
punctuation and empty spaces).
print(len("Hello")) # Output: 5
• [Link]() — Capitalizes only the very first character of a string and converts all remaining
characters to lowercase.
print("python".capitalize()) # Output: Python
Part 2: Assignment Sheet
Task 1: Basic Printing & f-strings
Write a Python program using exactly 5 print() statements to display the sentences specified below.
Rule: You must use an f-string (putting 'f' before the quotation marks and placing curly braces {} around
the numeric values) for sentences 2, 4, and 5.
• 1. Hello everyone, let me introduce myself
• 2. I am 20 years old and I love technology
• 3. My favorite hobby is reading and learning new skills
• 4. I spend 2 hours practicing coding every day
• 5. My goal is to build 10 real-world projects this year
Task 2: Modify Strings (Upper, Lower & Strip)
• Given sample1 = " mindcraft" , write a print statement that outputs it in ALL UPPERCASE.
• Given sample2 = "MINDCRAFT" , write a print statement that outputs it in all lowercase.
• Given sample3 = " mindcraft " , use a built-in method to print it with all outer empty spaces
removed.
Task 3: Analyzing and Capitalizing Strings (len & capitalize)
• Given word = "programming" , write a print statement using a string method to display it with its
first letter capitalized (Expected Output: Programming ).
• Given phrase = "Python Coding" , write a print statement using a built-in function to find and
display the total character count of the phrase (Expected Output: 13 ).
Mind Craft Academy • Python Programming Page 2 of 3
Task 4: Raw Concatenation (+)
Create three variables: word1 = "Coding" , word2 = "is" , word3 = "fun" .
Use the + operator inside a single print() statement to combine them to display exactly "Coding is
fun" (ensure you include manual spaces).
Task 5: The Comma Shortcuts
Using the same variables from Task 4, write a single print() statement that outputs "Coding is
fun" without typing or adding manual spaces ( " " ).
Task 6: Master Challenge (Modification + Length + Concatenation)
Given str1 = " super" and str2 = "computer" , write a program that:
• Strips the leading empty spaces from str1 and converts it to uppercase.
• Finds the character count (length) of str2 and stores it in a variable.
• Combines the modified str1 with the uppercase version of str2 .
• Prints the final combined string ( SUPERCOMPUTER ) followed by the length of str2 using a single print
statement with the comma shortcut.
Expected Terminal Output
Hello everyone, let me introduce myself
I am 20 years old and I love technology
My favorite hobby is reading and learning new skills
I spend 2 hours practicing coding every day
My goal is to build 10 real-world projects this year
MINDCRAFT
mindcraft
mindcraft
Programming
13
Coding is fun
Coding is fun
SUPERCOMPUTER 8
Build Your Mind! Good Luck
Mind Craft Academy • Python Programming Page 3 of 3