Topic 0: Basics of Python

Introduction to Business Analytics — HKUST

Prof. Xuhu Wan

Welcome to Python

Python is the #1 language for business analytics. Everything on this slide runs live in your browser — no install, no setup.

How to use these slides

  • Edit any code cell, then click the ▶ Run button to execute
  • Press Shift+Enter while inside a cell to run it
  • All output appears below the code, just like Jupyter

Your First Line of Python

Edit the line above and run again.

Variables & Arithmetic

Strings — Working with Text

Boolean Logic

If / Elif / Else

Try it: change daily_return and re-run.

For Loops

Functions

Try It Yourself

Modify the cost to make profit > $300k:

Click ▶ Run after editing.

What’s Next

You now know

  • Variables, arithmetic, f-strings
  • Booleans and if/elif/else
  • For loops and zip()
  • Functions with docstrings

Topic 1 → Lists, comprehensions, pandas Series, NumPy, plotting.