Skip to main content

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/yourusername/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 thinkpy.jupyter_magic
    
  2. Write ThinkPy code in cells:

    %%thinkpy --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

Metadata

Release files for think-lang 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for think-lang 0.1.9
File Size Uploaded
think_lang-0.1.9.tar.gz 30.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for think-lang 0.1.9
File Interpreter ABI Platform
think_lang-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 57.8 kB

Release files / think_lang-0.1.9.tar.gz

Download URL think_lang-0.1.9.tar.gz
Size 30.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2a0fbb631ff06f9e77648cc56a7d8e33e42d8f2a2dbed5b87387438d5433d8a5
BLAKE2b-256 checksum
How to use checksums
88810bc0c40a0a420e6c67ebf30d32caf004a3ded0d1be94421be43f094a0bcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.0

Release files / think_lang-0.1.9-py3-none-any.whl

Download URL think_lang-0.1.9-py3-none-any.whl
Size 27.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ef83fb76d01ce77077946038294c7a4ea32222b5dc20b0e0710fa4b03d8cbaa
BLAKE2b-256 checksum
How to use checksums
953a776b6c72f12dcd761c7146fcb8ad0be198c6547b8cbe91eff0c8a7144c68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page