Unit 10 • Lesson 7

Polishing with Visuals or Output Formatting

Overview

Small touches like formatted text or visual output can make a big difference. You'll explore ways to improve presentation — such as colorized terminal output or data visualization — enhancing the user experience of your project.

Intermediate 25–30 min

What You Will Learn in This Lesson

By the end of this lesson, you will know:

  • Output formatting: Making text output clear and readable.
  • Visual elements: Using formatting to improve presentation.
  • Tables and lists: Organizing data visually.
  • Color and styling: Enhancing terminal output.
  • Professional presentation: Making projects look polished.

Why Formatting Matters

Well-formatted output makes your project:

More Readable

Users can understand information quickly

More Professional

Shows attention to detail

More Enjoyable

Better user experience

More Impressive

Demonstrates quality work

Text Formatting

Use Python's string formatting to improve output:

Formatting Examples
# F-strings for formatting
name = "Alice"
age = 25
print(f"Name: {name:15} Age: {age:3}")

# Alignment
print(f"{'Task':<20} {'Status':>10}")
print(f"{'Buy groceries':<20} {'Done':>10}")

# Separators
print("=" * 50)
print("TASK MANAGER")
print("=" * 50)

# Lists with formatting
tasks = ["Task 1", "Task 2", "Task 3"]
for i, task in enumerate(tasks, 1):
    print(f"{i}. {task}")

Creating Tables

Format data in tables for clarity:

Table Formatting
def print_task_table(tasks):
    """Print tasks in a formatted table."""
    print(f"{'#':<5} {'Task':<30} {'Status':<10}")
    print("-" * 45)
    for i, task in enumerate(tasks, 1):
        status = "Done" if task["completed"] else "Pending"
        print(f"{i:<5} {task['name']:<30} {status:<10}")

# Output:
# #     Task                           Status    
# ---------------------------------------------
# 1     Buy groceries                 Pending  
# 2     Finish homework                Done

Summary

In this lesson, you learned:

  • Formatting: Use f-strings and alignment for readable output
  • Tables: Organize data in clear table format
  • Visual elements: Use separators and spacing effectively
  • Presentation: Polished output improves user experience

Remember

Good formatting doesn't require fancy libraries—Python's built-in string formatting is powerful. Take time to format your output well—it makes a big difference!

End-of-Lesson Exercises

Think about these questions to reinforce what you've learned:

Exercise 1: Formatting

Why is output formatting important? How can you improve the presentation of your project's output?

Exercise 2: Visual Elements

What formatting techniques can you use to make output more readable and professional?