Coding is a relatively easy skill to learn. At their age, I am more focused on math.
Coding skill has many many different levels, just like math. Some coding and math skills required in certain application areas are far beyond the comprehension of most educated people.
So, yes, you can teach many 9 year olds to write very simple Python or R programs.
The complexity comes with "packages" that have to be added to programs to provide necessary features. These packages can demand high levels of knowledge and offer high degrees of complexity.
For example, Python has long been know to natively offer only single thread programming. But in writing programs for market analysis, for example, multi-threaded programming is needed to keep processing times down, due to all the data that has to be ingested and analyzed, plus the lengthy workflows. Pydantic and Prefect to the rescue!
Data validation using Python type hints
docs.pydantic.dev
Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
docs.prefect.io
not to forget "pandas"
pandas.pydata.org
Now, Pydantic and Prefect occur in only 2-5% of the more advanced Python programs, - I use them both and they are not simple to thoroughly and completely understand, - unless maybe you have many years of programming experience in other languages under your belt.
And these are the other common packages used in Python:
Core Python Standard Library Packages
os: For interacting with the operating system.
datetime: For working with dates and times.
json: For encoding and decoding JSON data.
collections: For specialized container datatypes (like Counter, defaultdict, namedtuple).
logging: For generating log messages.
sys: For system-specific parameters and functions.
re: For regular expressions.
Data Manipulation and Analysis
numpy: For numerical computing with arrays and matrices.
scipy: For scientific computing, extending NumPy with additional functions.
Visualization
matplotlib: For creating static, animated, and interactive visualizations in Python.
seaborn: Built on top of matplotlib for making statistical graphics in Python.
plotly: For interactive plotting, especially useful for web applications.
Machine Learning/Deep Learning
scikit-learn: For machine learning algorithms, preprocessing, model selection, and evaluation.
TensorFlow or PyTorch: For deep learning, neural network implementations, and related tools.
Web Frameworks
Django: Full-featured web framework for perfectionists with deadlines.
Flask: A lightweight WSGI web application framework.
Database Interaction
SQLAlchemy: For Python SQL toolkit and Object-Relational Mapping (ORM).
psycopg2 or mysql-connector-python: For direct database connections (PostgreSQL or MySQL respectively).
Asynchronous Programming
asyncio: Python's standard asynchronous I/O framework.
aiohttp: Asynchronous HTTP client/server for asyncio.
API Development
FastAPI: For building APIs with Python 3.6+ based on standard Python type hints.
requests: For making HTTP requests in your code.
Testing
pytest: For writing and running tests.
unittest: Python's built-in testing framework.
Logging and Configuration
loguru: Aims to make Python logging easier to use.
pydantic: For settings management and data validation.
DevOps/Automation
boto3: For AWS SDK for Python, used for cloud operations.
docker: Python SDK for Docker.
Data Serialization
pyyaml: For YAML parsing and emission.
toml: For TOML file parsing.
Utilities
click: For creating command line interfaces with Python.
tqdm: For adding progress bars to loops in Python.
Workflow Management
Prefect or Airflow: For managing data pipelines and workflows.
Children, in particular adolescents, if they can handle the load, should be given the opportunity to go as far as possible in designing and writing lengthy programs, - as this will instill in them early skills at remembering complex workflows and steps that will remain with them for the rest of their life.