Skip to content

ZipCodeCore/WhiteSpace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhiteSpace Lab - Understanding Invisible Characters

This repository contains a fundamental programming exercise designed to help beginner coders understand the concept of whitespace in both text files and source code. The lab is available in two versions to accommodate different programming languages and learning paths.

Repository Structure

  • java/ - Java implementation using Maven build system
  • python/ - Python implementation with native file handling
  • testdata1.txt, testdata2.txt, testdata3.txt - Sample data files for testing

What is Whitespace?

Whitespace refers to invisible characters that provide spacing and formatting in text. The most common whitespace characters are:

  • Space (' ') - The character you get when pressing the spacebar
  • Tab ('\t') - Horizontal indentation character
  • Newline ('\n') - Line break character
  • Carriage Return ('\r') - Return to beginning of line

Why Understanding Whitespace Matters

Understanding whitespace is crucial for several reasons:

  1. Text Processing: When working with data files, user input, or parsing text, you need to handle whitespace correctly to avoid errors and unexpected behavior.

  2. Code Formatting: While most languages ignore extra whitespace in source code, proper use of whitespace makes code readable and maintainable.

  3. String Manipulation: Whitespace often needs special handling when comparing strings, validating input, or formatting output.

  4. Cross-Platform Compatibility: Different operating systems use different line ending conventions, making whitespace awareness essential for portable applications.

The Exercise

Both versions implement a countBoth method that manually counts whitespace and non-whitespace characters without using built-in library functions. This hands-on approach ensures students understand what constitutes whitespace rather than relying on abstracted methods.

Students must use loops to examine each character individually, reinforcing fundamental programming concepts while building practical text processing skills.

Choose the Java or Python version based on your current learning focus, but the core concepts and expected outputs remain identical across both implementations.

About

what is whitespace in coding?

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •