NCO (Cyber Olympiad) /Software Applications & Programming

Formatting Text and Paragraphs

Word Processing (MS Word) · free study notes · Updated

📚 Study Notes – Formatting Text and Paragraphs

(Software Applications & Programming – NCO Cyber Olympiad)


1. Simple Explanation

Formatting text and paragraphs is the art of arranging characters, words, and lines so that the output is readable, aesthetically pleasing, and adheres to a given specification.

  • In programming it usually means controlling line breaks, indentation, alignment, and spacing when you print or display data.
  • In document editors (Word, Google Docs, LaTeX, HTML) it refers to setting paragraph styles (indent, spacing, alignment, bullets, etc.) so the final document looks professional.

For the NCO Cyber Olympiad we focus on programmatic formatting: how to produce well‑structured text (including paragraphs) using code.


2. Key Points

# Concept What It Means Typical Syntax / API
1 Line Breaks Move the cursor to the next line. \n (C/C++/Java/Python), Console.WriteLine() (C#),
(HTML)
2 Indentation Add spaces/tabs at the start of a line for hierarchy. " " (4 spaces), \t (tab), String.format("%8s", text)
3 Alignment Left, right, center, or justified text within a width. printf("%-10s", s) (left), printf("%10s", s) (right), printf("%^10s", s) (center in Python’s str.center)
4 Padding / Width Ensure a fixed width for tabular data. printf("%-15s %5d", name, score)
5 Paragraph Spacing Blank lines between paragraphs. Two consecutive \n or \n\n
6 Text Wrapping Break long lines into a given column width. Built‑in (textwrap.wrap in Python), printf("%-80s", ...)
7 String Interpolation Insert variables into a template. f"{var}" (Python), "${var}" in JavaScript, "${var}" in Bash, String.format() in Java
8 HTML/Markdown Tags Mark up text for web or markdown rendering. <p>,
, **bold**, *italic*
9 Escaping Characters Treat special characters literally. \\n becomes the two characters \ and n; \" for quotes in C/Java
10 Locale/Unicode Support multi‑byte characters. Unicode strings in Python 3, char vs wchar_t in C

3. Worked Example

Goal: Write a program that prints a short biography paragraph, properly indented, with a title, two paragraphs, and a footer, using Python 3.
The output should look like:

           ABOUT JOHN DOE

John Doe is a software engineer with 10 years of experience
in developing scalable web services. He enjoys contributing
to open‑source projects and mentoring junior developers.

   © 2026 John Doe

3.1 Code

# -*- coding: utf-8 -*-

# 1. Define constants
TITLE = "ABOUT JOHN DOE"
PARAGRAPH_1 = ("John Doe is a software engineer with 10 years of "
               "experience in developing scalable web services. "
               "He enjoys contributing to open‑source projects "
               "and mentoring junior developers.")
FOOTER = "© 2026 John Doe"

# 2. Helper: wrap text to a given width, preserving words
def wrap(text, width):
    import textwrap
    return textwrap.fill(text, width=width)

# 3. Build the formatted output
indent = "   "          # three spaces for indentation
title_line = indent + TITLE.center(80 - len(indent))  # center within 80 cols

para1 = wrap(PARAGRAPH_1, width=70)   # wrap at 70 chars
para1_lines = [indent + line for line in para1.split('\n')]

footer_line = indent + FOOTER.rjust(80 - len(indent))

# 4. Print everything
print(title_line)
print()                 # blank line between title and paragraph
for line in para1_lines:
    print(line)
print()                 # blank line between paragraphs
print(footer_line)

3.2 Explanation

Step What Happens Why
1 Define text constants Keeps data separate from formatting logic.
2 wrap() Uses Python’s textwrap to avoid breaking words.
3 Build each section - title_line is indented and centered.
- Each paragraph line is indented.
- Footer is right‑justified.
4 print() Two blank lines separate the title, paragraph, and footer.

3.3 Output

           ABOUT JOHN DOE

   John Doe is a software engineer with 10 years of experience in developing scalable web services. He enjoys contributing to open‑source projects
   and mentoring junior developers.

   © 2026 John Doe

(Note: The actual line breaks may differ slightly depending on your console width.)


4. Quick Revision Summary

Topic Take‑away
**Line breaks

Your note

Page 1

Doubt hai is topic me?

Free AI teacher se poocho — 24/7, step by step.