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.
- 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
# Clone the repository
git clone https://github.com/lwgray/think.git
cd think
# Install the package
pip install -e .
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"
-
Objective: The main goal of your program
objective "Your goal here"
-
Task: Major components of your solution
task "Task Name": # steps or subtasks
-
Subtask: Reusable pieces of code
subtask "Subtask Name": # statements return result
-
Step: Specific actions
step "Step Name": # statements
-
Decide (If/Else):
decide: if condition then: # statements elif another_condition then: # statements else: # statements
-
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
- Numbers:
42
,3.14
- Strings:
"Hello, World!"
- Lists:
[1, 2, 3, 4, 5]
- Variables:
score = 85
- Dictionaries `{'key': 'value'}
-
Load the ThinkPy extension:
%load_ext think.jupyter_magic
-
Write ThinkPy code in cells:
%%think --explain objective "Your program objective" # ... rest of your code
sum(list)
: Calculate the sum of a listlen(list)
: Get the length of a listprint(value)
: Display a value
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"
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"
python -m pytest tests/
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to all contributors to this project
- Inspired by Python and educational programming concepts
- Built with PLY (Python Lex-Yacc)
For support, feature requests, or bug reports:
- Check the documentation
- Open an issue on GitHub
- Contact the maintainers
Made with ❤️ for teaching computational thinking