

String.format()
Presentation
•
Computers
•
9th - 10th Grade
•
Easy
Calum Gordon
Used 2+ times
FREE Resource
17 Slides • 21 Questions
1
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
A screen has an output width of 80 characters.
If 5 columns of equal-width output are required, how many characters must be allocated to each column?
Type answer...
14
15
Fill in the Blanks
Which string method in Python allows the programmer to modify the contents and appearance of a printed string?
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
Predict the output of these lines:
p = "pi"
v = 22/7
print("The value of {0} is {1:.3f}".format(p,v))
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
Predict the output of this line of code:
print("cheese"*3+"ham"*5)
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
Formatting printed output to meet user requirements

Show answer
Auto Play
Slide 1 / 38
SLIDE
Similar Resources on Wayground
31 questions
Edexcel Algorithm efficiency
Presentation
•
9th Grade
32 questions
Stored Program Concept
Presentation
•
9th - 10th Grade
36 questions
Media Digital #1
Presentation
•
9th Grade
32 questions
ระบบทางเทคโนโลยีที่ซับซ้อน
Presentation
•
10th Grade
33 questions
Unit 4 Output 5. Printers Part 1
Presentation
•
10th Grade
36 questions
Data Types, Validation, Testing with Data
Presentation
•
9th - 10th Grade
34 questions
Year 9 - Digital Tech - Term 1 - Week 1
Presentation
•
9th Grade
37 questions
Low-level & High-level Languages
Presentation
•
9th - 10th Grade
Popular Resources on Wayground
10 questions
Safety Day 2026 – Student Review
Quiz
•
9th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
15 questions
Rounding Decimals
Quiz
•
5th Grade