0% found this document useful (0 votes)
39 views3 pages

Python String Manipulation Worksheet

The document is a worksheet designed to teach string manipulation in Python. It includes three levels of tasks: BRONZE for understanding string methods, SILVER for implementing code snippets, and GOLD for creating a program that generates variations of a user's name. Each section provides specific instructions and examples for coding practices related to strings.

Uploaded by

hna2001deptrai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views3 pages

Python String Manipulation Worksheet

The document is a worksheet designed to teach string manipulation in Python. It includes three levels of tasks: BRONZE for understanding string methods, SILVER for implementing code snippets, and GOLD for creating a program that generates variations of a user's name. Each section provides specific instructions and examples for coding practices related to strings.

Uploaded by

hna2001deptrai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

9.1.

9 Worksheet
1.​ BRONZE - Read and understand the following examples. We use the #
to add comments and explain the code we are implementing.

a.​ How to make a string lowercase? ____


b.​ How to make a string uppercase? ____
c.​ How to capitalize a string? ____
d.​ How to calculate the length of a string? ____

The worksheet continues in the next page


2.​ SILVER – Open a python compiler and paste the code in purple
below. Implement the instruction provided in the comment.

colour = "Yellow"
#add code to output the length of the variable

name = input("What is your name: ")


#add code to change this input to uppercase letters
#OUTPUT name

activity = input("Enter a possible activity: ")


#add code to change this input to lowercase letters
#OUTPUT activity

holiday = input("Enter a holiday destination: ")


# add code to change this input to a capitalised word
#OUTPUT holiday

Add your code below:

3.​ GOLD – Create a Python program that generates fun names based
on user input. The program should include the following steps:

a.​ Ask the user to input their first name and store it in a variable
called username.
b.​ Use string manipulation techniques to create at least three
variations of the user's name.
i.​ For example:
1.​ All lowercase: use lower()
2.​ All uppercase: use upper()
3.​ The first letter capitalized: use capitalize()
4.​ Add "inator" to the end of the name:
(print(userName + "inator")) (feel free to choose other name
endings)
5.​ Add “The great” at the beginning of the name:
(print("The great", userName)) (feel free to choose other name
starter).
c.​ Add a screenshot of your work below.

You might also like