Apr 24, 2026 5.4 KB octet-stream v1 python / Python 3 · 4 code, 4 md

Mixed Output Types

Testing all output types: text, HTML, images (base64), SVG, and errors.

[1]
1# stream output — multiple prints
2for i in range(5):
3 print(f"Step {i + 1}: processing...")
4print("Done!")
Step 1: processing...
Step 2: processing...
Step 3: processing...
Step 4: processing...
Step 5: processing...
Done!

SVG Output

Inline SVG rendering (like matplotlib with SVG backend):

[2]
1from IPython.display import SVG, display
2
3svg = '''<svg width="300" height="200" xmlns="http://www.w3.org/2000/svg">
4 <rect x="10" y="10" width="80" height="180" fill="#4CAF50" rx="4"/>
5 <rect x="110" y="60" width="80" height="130" fill="#2196F3" rx="4"/>
6 <rect x="210" y="100" width="80" height="90" fill="#FF9800" rx="4"/>
7 <text x="50" y="205" text-anchor="middle" font-size="12">A</text>
8 <text x="150" y="205" text-anchor="middle" font-size="12">B</text>
9 <text x="250" y="205" text-anchor="middle" font-size="12">C</text>
10</svg>'''
11display(SVG(svg))
A B C

Rich HTML Output

Custom HTML via display(HTML(...)):

[3]
1from IPython.display import HTML
2
3HTML('''
4<div style="padding: 16px; border: 1px solid #ddd; border-radius: 8px; max-width: 400px;">
5 <h3 style="margin: 0 0 8px 0;">System Status</h3>
6 <table style="width: 100%; border-collapse: collapse;">
7 <tr><td>CPU</td><td style="text-align: right; color: green;">12%</td></tr>
8 <tr><td>Memory</td><td style="text-align: right; color: orange;">67%</td></tr>
9 <tr><td>Disk</td><td style="text-align: right; color: green;">34%</td></tr>
10 <tr><td>Network</td><td style="text-align: right; color: green;">2.4 Mbps</td></tr>
11 </table>
12</div>
13''')

System Status

CPU12%
Memory67%
Disk34%
Network2.4 Mbps

Empty Cell

An unexecuted code cell:

[ ]
1# TODO: implement this later
This is a raw cell.
It is rendered as plain text without any formatting.
Useful for LaTeX or other markup that shouldn't be processed.