Loading
/custom-emojis/emojis/contour-map.png
Templates
📚
Articles & Resources
📖
Guides & Support
🌵
CalcTree
Estados de Vigas de Concreto
Bust Common Myths About Java Programming
Loading
/custom-emojis/emojis/calculator.png
Tensile Strength and Capacity Control of the W-Shape Sections According to AISC 360-16
Loading
/custom-emojis/emojis/calculator.png
Concrete Cylinder Strength Vs Cube Strength
Loading
/custom-emojis/emojis/calculator.png
Earthquake Design Action Calculation
Sıvılaşma Verileri Tablosu
Loading
/custom-emojis/emojis/rc-beam.png
Concrete Column Designer to AS3600
EM Wave Propagation Calculator
section properties with units
Forward Kinematics of Robotic Arm with 6 Degrees of Freedom
İKSA YAPILARI PROJELENDİRME HİZMET BEDELİ (2024)
GEOTEKNİK RAPOR (EK-B) ASGARİ HİZMET BEDELİ (2024)
ZEMİN İYİLEŞTİRME/DERİN TEMEL PROJELENDİRME ASGARİ HİZMET BEDELİ (2024) (İMO)
🚀
Projectile motion
Loading
/custom-emojis/emojis/bending-moment.png
Dezi et. al (2010)
🤾
Projectile motion
Quick start Python's banner
👟

Quick start Python

You can use the Python programming environment in your CalcTree pages. For example, parameter n below is defined on this page's content. It is then used to calculate the factorial of n in the Python environment of this page.


n
:5.00






factorial
:120.00


The parameter factorial is defined and calculated inside the Python environment and used above on the page content.

Below is a step-by-step guide to quickly add a Python environment to your page while creating the above example calculation.


How to add a Python source to your page

Please follow these four steps:

Step one: Add a Python source

First, you should add a Python source to your page. Click on Python on the Integrations sidebar:
Select Python from the Integrations sidebar


If you cannot see the Integrations sidebar, click on the plug icon, then click on + Add :
Click on + Add icon to see the Python option


When you click on Python, an example Python source code will be added:
A Python source is added to the page



Step two: Add parameter n to page content

Type /p on the page to receive the command menu:
type /p to get the parameter commands


click on the Parameter field or press Enter to insert a parameter on the page. Change the default Untitled title of the parameter to n:
Insert a parameter and set the title to n



Step three: Add Python logic

Add Python code inside the code editor. Try adding the following sample code:
Type this sample Python code to calculate factorial

Note that here, you can use parameter n, defined on the page content. To do that, start typing the title of the parameter to receive an auto-completion:
Using parameters defined on the page content inside Python

Click on the suggestion to use that page parameter in your Python code.

👉 Note that at the moment, you must click on that suggestion to use the parameter n from the page content. Soon, our Python editor will recognise the page parameters by just typing or pasting their titles in your code without having to click on the auto-completion suggestion.


Step four: add calculated Python parameter to page content

After typing the above example code, you will notice that the Python variable factorial will appear as a parameter under your Python source on the Integrations pane:
Python variables appear as source parameters


🧐 Note that only variables defined at the global scope will be taken as source parameters. In other words, variables defined within a function won't be considered source parameters.

You can now drag and drop the source parameter factorial into page:
Drag and drop source parameter on page content

You can alternatively insert source parameter factorial using the keyboard by typing the following: /pEnter faDown ArrowEnter.
Inserting a source parameter by keyboard


🙌 Bonus: if you don't want a Python variable to be taken as a parameter, start it with an underline, e.g. _i instead of i.


Still have more questions?

Join the conversation on Slack below!