Week 1: Python Basics¶
Monday, Jan 6, 2025
This course uses Python 3 inside Rhino 8 and Grasshopper. In Python, programs are created by chaining together statements in order to achieve a desired effect. Statements are formed via expressions, which can themselves be formed via simpler expressions.
Why Python?
Grasshopper in Rhino 8 supports scripting with both C# and Python, but Python is much easier to get into and hack together solutions with.
Additionally, there’s tons of support online for Python in general, from tutorials to libraries and even to generative AI. You can also use Python in other applications like Blender and Revit (using pyRevit).
Warning
This summary is not exhaustive. It is instead intended to cover the basic features of Python that might be used during this course.
Throughout these sections and those in the future, you will see Python code blocks like
the one below. They will often be commented to explain the code inside of them.
Comments in Python are preceded by a #
symbol. Comments can either be on their
own line or at the end of another line. Anything after the #
will be ignored when
the program is executed. For example:
# This piece of code prints "Hello, World!" to the console
# When printing, the quotations (") won't appear
print("Hello, World!") # This is an end-of-line comment