0
0
Pythonprogramming~5 mins

String values and text handling in Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a string in Python?
A string is a sequence of characters enclosed in quotes, used to represent text.
Click to reveal answer
beginner
How do you create a multi-line string in Python?
Use triple quotes (''' or """) to create a string that spans multiple lines.
Click to reveal answer
beginner
What does the len() function do when used with a string?
It returns the number of characters in the string, including spaces and punctuation.
Click to reveal answer
beginner
How can you combine two strings in Python?
By using the + operator to join them together, called concatenation.
Click to reveal answer
intermediate
What is the purpose of the strip() method on a string?
It removes any spaces or specified characters from the start and end of the string.
Click to reveal answer
Which of these is the correct way to create a string in Python?
Atext = Hello
Btext = "Hello"
Ctext = 'Hello
Dtext = (Hello)
What will len('Hi there') return?
A7
B6
C8
D9
What does 'Hello'.upper() do?
AReturns the length of 'Hello'
BConverts 'Hello' to 'hello'
CRemoves spaces from 'Hello'
DConverts 'Hello' to 'HELLO'
How do you join two strings, 'Good' and 'Morning', with a space in between?
A'Good' + ' ' + 'Morning'
B'Good' . 'Morning'
C'Good' & 'Morning'
D'Good' - 'Morning'
What does ' hello '.strip() return?
A'hello'
B' hello '
C'hello '
D' hello'
Explain how to create and manipulate strings in Python.
Think about how you write text and change it in Python.
You got /4 concepts.
    Describe the difference between single, double, and triple quotes in Python strings.
    Consider how you write short vs long text blocks.
    You got /3 concepts.