

String.format()
Presentation
•
Computers
•
9th - 10th Grade
•
Easy
Calum Gordon
Used 2+ times
FREE Resource
17 Slides • 21 Questions
1
String.format()
Formatting printed output to meet user requirements

2
3
4
Multiple Select
In this lesson I am going to learn to ... ?
Format printed output to meet specific requirements
Format printed output suitable for the user
Save output to text files
Input data from text files
5
6
Multiple Choice
Which code will loop through all items in the data structure?
wizards = ["Gandalf", "Saruman", "Sauron", "Radagast"]
for wizard in wizards:
print(wizard)
for wizards in wizard:
print(wizard)
while wizard in wizards:
print(wizard)
for wizard in range(len(wizards)):
print(wizard)
7
8
Multiple Choice
Output from this program will be .... ?
Cheese = 4
Ham = 4
Tuna = 3
Cheese = 3
Ham = 4
Tuna = 4
Cheese = 4
Tuna = 3
Ham = 4
Cheese=4
Ham=4
Tuna=3
9
10
Multiple Select
Choose two reasons for this program output being NOT user-friendly ...
No titles on the output
Number values are not aligned
Too few items
Not in alphabetical order
11
12
Multiple Select
The maximum width of program output is 80 characters and each column must be of an equal size.
Which of these options represent valid numbers of columns in the output?
4
5
3
6
13
Fill in the Blanks
Type answer...
14
15
Fill in the Blanks
Type answer...
16
17
Multiple Choice
What output would this produce?
print("Gandalf has {} personas.".format(2))
Gandalf has 2 personas
Gandalf has personas
Gandalf has personas Gandalf has personas
Gandalf has two personas
18
Multiple Choice
What output would this produce?
print("{}, {} and {}.".format("red", "green", "blue"))
red, green and blue
blue, green and red
red, green, blue
red, red and blue
19
20
Multiple Choice
What output would this produce?
print("I like to eat {1}, {2} and {0}".format("fish","chips","peas"))
I like to eat chips, peas and fish
I like to eat fish, chips and peas
I like to eat peas, chips and fish
I like to eat chips, fish and peas
21
Multiple Choice
What output would this produce?
a = 8
b = 5
c = "apples"
d = "bananas"
print("Gandalf ate {1} {0}",format(d,a))
Gandalf ate 8 bananas
Gandalf ate 8 apples
Gandalf ate 5 apples
Gandalf ate bananas 8
22
23
Fill in the Blanks
Type answer...
24
25
Multiple Choice
Which field widths would produce columnar output as shown?
{:8}{:7}{:5}
{:7}{:6}{:5}
{:7}{:7}{:7}
{:6}{:5}{:5}
26
27
Multiple Choice
Choose the field that is right-aligned ...
{:>10}
{:<10}
{:^10}
{:.10f}
28
Multiple Choice
Choose the field that is centre-aligned ...
{:>6}
{:<6}
{:^6}
{:.6f}
29
30
Multiple Choice
Predict the output of this code:
print("{0:<10}{2:^8}{1:>4}".format("Wizard","Colour","Age"))
print("{0:<10}{2:^8}{1:>4}".format("Gandalf","Grey","999"))
print("{0:<10}{2:^8}{1:>4}".format("Sauron","Black","2500"))
print("{0:<10}{2:^8}{1:>4}".format("Saruman","White","1199"))
31
32
Fill in the Blanks
Type answer...
33
34
Multiple Select
Choose all the ways in which the output has been improved ...
Arranged in columns
Alignment applied
Text dividers used
Field headings used
35
36
Multiple Select
In this lesson I have learned to ...
Format printed output using <string>.format()
Use placeholders {}
Use alignment
Arrange output in columns
37
Open Ended
Thinking Hard
What have you learnt today?
What can you do with this knowledge/skill/understanding?
What do you still need to know?
(press Shift+Enter to take a new line ...)
38
Poll
How much of this lesson have you understood?
None of it
Some of it
Most of it
All of it
String.format()
Formatting printed output to meet user requirements

Show answer
Auto Play
Slide 1 / 38
SLIDE
Similar Resources on Wayground
35 questions
Client-Server & Peer-To-Peer Networks
Presentation
•
9th Grade
30 questions
LESSON 3: INSERTING MEDIA (HTML)
Presentation
•
9th Grade
33 questions
Procedures
Presentation
•
9th - 10th Grade
31 questions
Data-level Protection
Presentation
•
9th - 10th Grade
32 questions
Business Letter Lesson 1
Presentation
•
10th Grade
31 questions
FORMULATING OPINION OR ASSERTION
Presentation
•
10th Grade
Popular Resources on Wayground
16 questions
Grade 3 Simulation Assessment 2
Quiz
•
3rd Grade
19 questions
HCS Grade 5 Simulation Assessment_1 2526sy
Quiz
•
5th Grade
10 questions
Cinco de Mayo Trivia Questions
Interactive video
•
3rd - 5th Grade
17 questions
HCS Grade 4 Simulation Assessment_2 2526sy
Quiz
•
4th Grade
24 questions
HCS Grade 5 Simulation Assessment_2 2526sy
Quiz
•
5th Grade
13 questions
Cinco de mayo
Interactive video
•
6th - 8th Grade
20 questions
Math Review
Quiz
•
3rd Grade
30 questions
GVMS House Trivia 2026
Quiz
•
6th - 8th Grade