Strings & I/O: Worked Reasoning

25 min
0/5 practice checks

Worked Reasoning

Make each reasoning step visible: identify the knowns, choose the governing idea, apply it and check the result.

This extension applies that lens specifically to Strings & I/O.

A string is text. You can join strings with + (concatenation) and measure them with len():

greeting = "Hello, " + name n = len("hello") # 5

Strings have handy methods: "cape town".upper()"CAPE TOWN", " hi ".strip()"hi".

print(...) sends text to the screen; input(...) reads a line the user types (returns a string).

Code practice

Python Foundations — Worked Reasoning: Write a function greet(name) that returns the string "Hello, " followed by the name. For example greet("Zanele") returns "Hello, Zanele".

python

Runs in your browser. Charts (matplotlib) are not supported — use print-based output.

Code practice

Python Foundations — Worked Reasoning: Given s = "cape town", create a variable shout holding the uppercase version ("CAPE TOWN").

python

Runs in your browser. Charts (matplotlib) are not supported — use print-based output.

Python Foundations — Worked Reasoning: What does len("Caelum") return?

Name the original topic being extended by this worked reasoning lesson.

Which statement is the best evidence-led starting point for Strings & I/O: Worked Reasoning?