Introduction to Programming with Python

Control Flow and Functions

Alp Tezbasaran

2025-09-24

Welcome

Slides: https://go.ncsu.edu/intro-to-prog-py QR code to workshop material


To get a complete from this session:

  • In-person: Sign the attendance sheet
  • Virtual: We will use Zoom attendance

Who we are

Mara Blake
Head, Data Science Services
Shannon Ricci
Associate Head, Data Science Services
Jeff Essic
Lead Librarian for GIS
Alp Tezbasaran
Data Science Librarian
Selene Schmittling
Data Science Librarian
Lynnee Argabright
Data Science Teaching Librarian

Our team comes from a variety of academic backgrounds, including nuclear engineering, electrical engineering, marine ecology, history, information science, natural resources, and geographic information sciences.

Check our workshops

go.ncsu.edu/datavizworkshops QR code to Data Viz Workshops

  • Introduction to Programming with Python [R]: Basic Syntax and Operators
  • Introduction to Programming with Python [R]: Control Flow and Functions
  • Map, analyze, and share spatial data
  • Introduction to Creating Publication-Quality Visualizations
  • Getting Started with Data Publication: What, Why, and How

Have workshop ideas? Contact us!

How to contact us

go.ncsu.edu/getdatahelp

Get Data Help

Direct email: getdatahelp@ncsu.edu

Who is this workshop for?

  • If you know basic syntax and operators
  • If you need a refresher on branching (if/else), repeating (loops)
  • If you want to discuss functions in Python
  • If you used Python just for a little bit
  • If you are following the full series:
      1. Introduction to Computing and Programming Concepts
      2. Introduction to Programming with Python: Basic Syntax and Operators
      3. Introduction to Programming with Python: Control Flow and Functions

So far we covered

  • Computers, codes, algorithms
  • Computing concepts
  • Basic syntax: #, name = 'alp'
  • Variables: cat_name
  • Data types/structures: int, str, datetime, bool
  • Operators in this session: +, -, ==, <=, !=

Today we will go beyond basics

  • Access notebooks in Colab
  • Branching if/else
  • Repeating for/while
  • Functions
    • [Object] methods
    • Built-in functions
    • User defined functions

Why Python?

  • Easy to read and learn
  • Large ecosystem for data, web, and automation
  • Strong community and documentation
  • Cross-platform and cloud-friendly
  • Works with Excel, databases, and websites
  • Free and open source

Where can we use Python?

Why Colab?

  • No installs or setup; runs in the browser
  • Free compute (CPUs/GPUs/TPUs) for small projects
  • Autosaves to Google Drive by default
  • Easy sharing and collaboration (like Google Docs)
  • Many Python/data libraries preinstalled
  • Same experience on Windows, macOS, and Linux

Follow the instructor on Google Colab

During the workshop:

  • Open your Colab notebook
  • Type along with the instructor
  • Run each code cell after we write it
  • Ask questions if something doesn’t work

Tips for following along:

  • Keep your notebook visible
  • Don’t worry about typos - we’ll catch them
  • Experiment with changing values
  • Save your work frequently

How to access workshop material?

  1. Go to
    https://go.ncsu.edu/intro-to-prog-py

  2. Scroll down to the right session. Click “Open in Colab”
    Colab logo

  3. Click “Copy to Drive”
    Copy to Drive

Repository screenshot

How to contact us

go.ncsu.edu/getdatahelp

Get Data Help

Direct email: getdatahelp@ncsu.edu

Continue learning Python!

  • NC State University Libraries workshops
  • LinkedIn Learning: lots of python courses!
  • Python for Data Analysis 3e
  • Search documentation for packages you want to learn!
  • Ask AI! (but learn the basics and concepts first)

Tell us how we did

go.ncsu.edu/dss-workshop-eval

QR code for workshop evaluation

THANK YOU