Python is the “Swiss Army Knife” of modern science. It is versatile, beginner-friendly programming language used for everything from data analysis and scientific research to automation and web development. Its simple and readable syntax makes it the perfect tool for learning fundamental programming concepts.
There are three primary ways to interact with Python:
Option 1: Interavtive Shell
Best for quick calculations or testing single lines of code. Open your terminal and type python3.
>>> 5 + 38>>> print("Hello!")Hello!
*Press Ctrl+Dor type exit() to leave.
Option 2: Python Scripts (.py)
For actual projects, you write a code in a file and run it all at once.
Create hello.py
Run it via terminal: python3 hello.py
Terminal wihtin Code Editors
Many integrated development environments (IDEs) and some code editors like VS Code, do have an integrated terminal function within the application. Some even have a run button (▶) (e.g., VS Code if you have the Python extension installed).
Option 3: Python Notebooks
Python notebooks (.ipynb) allow you to write code blocks and interact with the results at the same time, maintaining a global variable storage for the session. They also allow to combine Python code cells with Markdown explanation cells. This topic is handled in AB Jupyter Notebooks
2. Variables and Data Types
A Variable is a named container for storing data. Python identifies the type of the data automatically, unlike C++ for example.
Type
Description
Example
String (str)
Text data
name = "Alice", friend = 'Bob'
Integer (int)
Whole Numbers
age = 25
Float (float)
Decimal numbers
pi = 3.14
Boolean (bool)
Logic
is_ready = True, repeat = False
Type Conversion
You can change types using functions like int(), str(), or float(). Example:
You can also use the function isinstance(<variable-name>, <type>) to know the type of a variable.
3. Operations
Arithmetics
Python handles math naturally using standard operators:
+, -, *, / (Standard math)
// (Floor division: 10 // 3 = 3)
** (Exponentiation: 2 ** 3 = 8)
% (Modulo: gives the remainder)
Strings
You can combine strings with + or use f-strings for easy formatting:
name = "Bob"print(f"Hello, {name}!") # Output: Hello, Bob!
4. Control Flow
If/Else Statements
Use logic to decide which code to run.
age = 20if age >= 18: print("Adult")else: print("Minor")
Loops
While Loop: Runs as long as a condition is true.
For Loop: Iterates over a sequence (like a list or a range of numbers).
for i in range(3): print(f"Counting: {i}") # Prints 0, 1, 2
5. Collections: Lists and Dictionaries
Lists (Ordered)
Use square brackets [] to store a sequence of items.
Access items by index: fruits[0] is the first item.
Add items: fruits.append("mango").
Dictionaries (Key-Value)
Use curly braces {} to store data in pairs.
student = {"name": "Alice", "grade": "A"}print(student["name"]) # Alice
6. Functions
Functions are reusable “recipes” for code. You define them once and call them whenever needed.
def multiply(a, b): return a * bresult = multiply(10, 5) # result is 50
Multiple Returns
Functions can return more than one value at once:
return min_val, max_val.
7. Error Handling
Instead of letting your program crash when it hits an error, use try and except blocks to handle issues gracefully. This is great when working with unphysical combinations in parameter spaces.
try: x = 1 / 0except ZeroDivisionError: print("You can't divide by zero!")
SUCCESS
You now have the fundamenta building blocks of Pythona and have completed all tech foundations onboarding tutorials. You may now proceed to the advance tutorials or you can begin actually contributing to CAPIBARA’s codebase. Remember these 3 central ideas:
Python is an extremely wide useage language, there are tons of tutorials, guidelines and solution on the internet. Make a good use of them, but don’t try to digest everything.
There are Python libraries for everything. Most important Python libraries (NumPy, Matplotlib, SciPy, etc) have extensive and supported documentation.
It probably happens that you are not the first one encoutering an issue: ask other group members directly or wrtite on the help desk discussion.