Skip to main content

Think - A language for learning computational thinking

Project description

Think

Think is an educational programming language designed to teach computational thinking through problem decomposition. It helps users break down complex problems into manageable parts while providing interactive feedback and explanations.

Features

  • Structured Problem Solving: Break down problems into objectives, tasks, subtasks, and steps
  • Interactive Execution: Run your code and see results in real-time
  • Explain Mode: Get detailed explanations of what each part of your code does
  • Jupyter Integration: Use ThinkPy directly in Jupyter notebooks
  • Educational Focus: Learn computational thinking concepts through hands-on coding

Installation

# Clone the repository
git clone https://github.com/lwgray/think.git
cd think

# Install the package
pip install -e .

Quick Start

Here's a simple ThinkPy program that calculates student grades:

objective "Calculate student grades"

task "Data Collection":
    step "Get scores":
        scores = [85, 92, 78, 90, 88]

task "Analysis":
    subtask "Calculate Average":
        total = sum(scores)
        avg = total / len(scores)
        return avg
    
    step "Determine Grade":
        final_score = Calculate_Average()
        decide:
            if final_score >= 90 then:
                grade = "A"
            elif final_score >= 80 then:
                grade = "B"
            else:
                grade = "C"

run "Data Collection"
run "Analysis"

Language Structure

Core Concepts

  1. Objective: The main goal of your program

    objective "Your goal here"
    
  2. Task: Major components of your solution

    task "Task Name":
        # steps or subtasks
    
  3. Subtask: Reusable pieces of code

    subtask "Subtask Name":
        # statements
        return result
    
  4. Step: Specific actions

    step "Step Name":
        # statements
    

Control Flow

  1. Decide (If/Else):

     decide:
         if condition then:
            # statements
         elif another_condition then:
            # statements
         else:
            # statements
    
  2. Loopd:

     for num in numbers:
        # statements
     end
     for index, value in enumerate(items):
         print(index, value)
     end
     for _, value in enumerate(items):
         print(value)
     end
    

Data Types

  • Numbers: 42, 3.14
  • Strings: "Hello, World!"
  • Lists: [1, 2, 3, 4, 5]
  • Variables: score = 85
  • Dictionaries `{'key': 'value'}

Jupyter Notebook Usage

  1. Load the ThinkPy extension:

    %load_ext think.jupyter_magic
    
  2. Write ThinkPy code in cells:

    %%think --explain
    
    objective "Your program objective"
    # ... rest of your code
    

Built-in Functions

  • sum(list): Calculate the sum of a list
  • len(list): Get the length of a list
  • print(value): Display a value

Examples

Temperature Analysis

objective "Analyze temperature data"

task "Data Collection":
    step "Get readings":
        temps = [72, 75, 68, 70, 73]

task "Analysis":
    subtask "Calculate Average":
        total = sum(temps)
        avg = total / len(temps)
        return avg
    
    subtask "Find High":
        max_temp = temps[0]
        for index, value in enumerate(temps):
            decide:
                if temps[index] > max_temp then:
                    max_temp = temps[index]
        end
        return max_temp

run "Data Collection"
run "Analysis"

Grade Calculator

objective "Calculate final grades"

task "Setup":
    step "Initialize data":
        scores = [85, 92, 78]
        weights = [0.3, 0.4, 0.3]

task "Calculate":
    subtask "Weighted Average":
        total = 0
        for index in range(3):
            total = total + (scores[index] * weights[index])
        end
        return total

run "Setup"
run "Calculate"

Development

Running Tests

python -m pytest tests/

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to all contributors to this project
  • Inspired by Python and educational programming concepts
  • Built with PLY (Python Lex-Yacc)

Support

For support, feature requests, or bug reports:

  1. Check the documentation
  2. Open an issue on GitHub
  3. Contact the maintainers

Made with ❤️ for teaching computational thinking

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

think_lang-0.1.9rc4.tar.gz (31.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

think_lang-0.1.9rc4-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file think_lang-0.1.9rc4.tar.gz.

File metadata

  • Download URL: think_lang-0.1.9rc4.tar.gz
  • Upload date:
  • Size: 31.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for think_lang-0.1.9rc4.tar.gz
Algorithm Hash digest
SHA256 22f6a3d1d6edec3d3149587ca804d996b0e04f8d7cb08d0d8980d98ed70e0d27
MD5 ec4f887bc8d4f52d3f0a2ad2e9beaa7e
BLAKE2b-256 9a5198f489a4c5089a786b254b890d28c72297dda937e46d21139f7f059a1ae2

See more details on using hashes here.

File details

Details for the file think_lang-0.1.9rc4-py3-none-any.whl.

File metadata

  • Download URL: think_lang-0.1.9rc4-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for think_lang-0.1.9rc4-py3-none-any.whl
Algorithm Hash digest
SHA256 324649d6154d1d2c29e302843de84583c5a4c3dd42a43f1e8b0919ad61ebc3f1
MD5 9b41508260b95ae0f1a94d9b20406a3f
BLAKE2b-256 d48d33684f6b5d9407fe1e1b02b5357c6c5d86789b98f241f6dfd0350ed82b83

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page