Online guidance · Shah Alam · Selangor

STEAM Miniature Model Building and Maker Craft Workshop Shah Alam

A STEAM miniature model building and maker craft workshop for Shah Alam introduces safe materials—EVA foam, cardboard, basic gears and small motors—so children learn spatial design before or alongside coding.

STEAM Shah Alam

1. Introduction: Operating Across Different File Modes

After mastering the fundamentals of opening, reading, writing, and closing files in Python, the next essential step is controlling how a file is opened and operated on.

When opening a file using Python's built-in open() function, you can pass a mode flag as a second argument. This flag explicitly informs the Python interpreter of your operational intent—whether you plan to read existing contents, write fresh data, or append new information to the end of the file.

2. Mode 1: Read Mode ('r')

To read data from an existing file, specify the 'r' flag when calling open().

  • Behavior: Informs Python that the target file is being accessed strictly for reading.
  • File pointer & safety: The file is opened safely without modifying or deleting its existing contents.
# 1. Opening demo.txt in Read mode using the 'r' flag
file = open("demo.txt", "r")

# 2. Reading and printing the contents
content = file.read()
print(content)

# 3. Safely closing the file
file.close()

Execution Walkthrough

  • Executing this script reads the stored text from demo.txt.
  • In our example, demo.txt contains the initial text lines: "This is a text" and "New line".
  • Python reads and prints these contents to the screen, after which the file is properly closed.

3. Mode 2: Write Mode ('w') & The Overwrite Behavior

To write data into a file, open it using the 'w' flag.

  • Behavior: Informs Python that you intend to write data into the target file.
  • Confirmation of written data: When you call file.write(), Python evaluates the string and confirms the exact number of characters written into the file (for example, confirming 21 characters written for a sentence).
  • The overwrite effect: When an existing file is opened in 'w' mode, all previous data is completely overwritten and replaced by the newly written content.
# 1. Opening demo.txt in Write mode using the 'w' flag
file = open("demo.txt", "w")

# 2. Writing new text into the file
file.write("This is another text")

# 3. Closing the file
file.close()

Execution Walkthrough

  • Writing "This is another text" writes 21 characters into the file.
  • Once the file is closed and demo.txt is reloaded on disk, the original contents ("This is a text" and "New line") are gone.
  • The file now contains only the new string: "This is another text".

4. Mode 3: Append Mode ('a') — Preserving Historical Data

In many real-world scenarios—such as logging events, recording transaction histories, or appending user entries—you do not want previous data to be overwritten. Instead, you need incoming information added cleanly to the end of the existing content.

For this purpose, Python provides Append Mode, designated by the 'a' flag.

  • Behavior: Python opens the file for writing, but instead of truncating or wiping the old content, it places new data directly after the old data.
  • Combining with newline characters (\n): To ensure that the appended text begins on a fresh line rather than attaching to the end of the previous sentence, prepend a backslash-n (\n) escape character before the text string.
# 1. Opening demo.txt in Append mode using the 'a' flag
file = open("demo.txt", "a")

# 2. Appending new text on a new line using '\n'
file.write("\nNew line added")

# 3. Closing the file
file.close()

Execution Walkthrough

  • Python appends "\nNew line added", confirming that 16 characters have been written into the file.
  • Calling file.close() ensures the appended changes are saved to disk.
  • When demo.txt is reloaded, the previous text remains fully intact, and the new line is successfully added underneath it:
This is another text
New line added

5. Summary: Choosing the Right File Mode

Mode Flag Name Primary Function Effect on Existing Data
'r' Read Opens file for reading Content is preserved unchanged
'w' Write Opens file for writing fresh data Overwrites / erases all previous content
'a' Append Opens file for writing at the end Preserves old data and appends new content

Lesson Q&A

In Write mode ('w'), Python opens the file for writing but completely overwrites and replaces all existing data with the new text. In Append mode ('a'), Python opens the file for writing while preserving all previous data, adding the new text directly to the end of the file without overwriting anything.

When writing data in append mode, Python writes new text directly from the current end of the file. If the previous line did not terminate with a line break, the new string would attach directly to the last character of the previous text. Prepending \n (backslash-n) forces Python to insert a line break, ensuring that the newly appended content starts cleanly on a fresh new line.

When Python executes file.write(), it writes the specified string into the file and confirms the exact number of characters written (such as confirming 21 characters or 16 characters in console feedback). Calling file.close() afterward is necessary to commit and flush those written changes safely to the disk and properly release the file resource.

What children can learn

WhatsApp +92 322 421 7059

AI and Robotics Club | The 100 Mission AI & Robotics Hero Journey

Recommended self-paced course for parents & educators

Robotics Miniature Modeling for Kids on Udemy.

Disclosure: This page contains affiliate links. We may earn from qualifying purchases at no extra cost to you. Links are intended for parents and educators, not as marketing directed at young children.

Hands and Minds: Physical Models That Teach Engineering Intuition

Shah Alam families seeking maker skills benefit from craft that trains spatial reasoning used later in robotics. Adult supervision is required for tools, batteries and motors. Enquire WhatsApp +92 322 4217059. We do not invent a Shah Alam workshop venue or material kit prices.

Frequently asked questions

What tools and materials are used in the Shah Alam STEAM miniature model building workshop?

Students work with safe, accessible maker materials—including EVA foam, cardboard chassis, thermocol structures, basic gear assemblies, LEDs, and small DC motors—to construct physical robot mascots, miniature bridges, and scaled architectural models.

How does physical craftwork enhance digital coding skills for kids?

Building physical models develops 3D spatial intelligence, mechanical intuition, and fine motor skills. When combined with electronic sensors and motors, students gain a complete engineering perspective from physical design to software logic.

How can families in Shah Alam register for an introductory maker craft session?

Reach out to our admissions coordinator on WhatsApp to select an open weekend session and download our beginner STEAM project guide.

Explore related learning

CyberjayaBootcamp · Cyberjaya BangsarArduino · Bangsar Subang JayaAI STEM · Subang Jaya