AI Use Cases & Applications

Python for Beginners: Jupyter, NumPy and Matplotlib Workshop

In a session at the Data Science Innovators Conference 2023, A Rieker led a live Python workshop for people who had never coded. Using a browser-based Jupyter notebook and short coding labs, attendees moved from strings and lists to loops, NumPy arrays and a Matplotlib sine graph.

By The AI Enterprise Magazine Team4 min read

Key takeaways

  • Start in the browser. JupyterLite lets beginners code with no software download.
  • Learn by doing. Short five-minute labs after each concept kept attendees coding, not just watching.
  • Types matter. Adding strings and adding numbers give different results, and type errors explain what went wrong.
  • NumPy replaces loops. Arrays can be adjusted directly, which simplifies tasks like shifting every value.
  • Finish with a graph. Matplotlib turned a NumPy sine array into a labeled plot.
Let's Jump into Python. Watch on YouTube

In a session at the Data Science Innovators Conference 2023 titled "Let's Jump into Python," A Rieker, listed as a researcher at Ontario Tech University, led a live, beginner-level coding workshop for people who had never written code and wanted to use Python for data science. Over 47 minutes, participants worked in a browser-based Jupyter notebook and finished by graphing a math function with NumPy and Matplotlib.

What was the plan for the workshop?

Rieker said the session was designed for people who have not coded before and may be nervous about starting. The learning goals were coding environments, Python variables, a little math to set up NumPy, and Matplotlib for graphs. Instead of importing a dataset, the group would graph math functions.

The format alternated short lectures with five-minute coding labs. Rieker coded live on screen, because "it's important to see the coding mindset of making mistakes and making typos." Attendees posted their attempts in chat and Rieker reviewed them on screen.

Which coding environment should beginners use?

Rieker chose Jupyter Notebook, which runs code in individual blocks. A user can import data once, then fix and rerun only the graph without repeating a processor-intensive step. Notebooks also hold text that explains why a function was used.

To avoid downloads, Rieker used JupyterLite, a version that runs in the browser. Rieker said it worked reliably only in Firefox. Anyone wanting desktop software was pointed to Anaconda. Rieker said that in professional work an IDE is the usual tool, and the browser notebook was chosen purely for accessibility.

How do strings, numbers and lists work in Python?

Rieker started with strings, showing that "print" outputs text, that a variable stores a string so it does not have to be retyped, and that string methods such as case fold, title, split and replace transform text. The first lab asked attendees to turn "let's jump into python" into lowercase, uppercase, with uppercase Ts, and with spaces removed.

Next came integers and floats. Rieker showed that adding the quoted characters "7" and "7" gives 77, while adding the numbers gives 14. Trying to add a string and an integer produced a type error, which Rieker described as helpful: errors "let us know what's going wrong." The operators covered included addition, subtraction, multiplication, exponents, division, floor division and modular division.

On lists, Rieker covered indexing from zero, append, remove and reassigning an element. Rieker also noted that notebook cells keep state in the order they are run, so running a cell out of order can change a variable's value.

When should you use a for loop or a while loop?

The second lab asked attendees to add three to every element of a list one element at a time, a deliberately tedious task. That set up loops. Rieker said a for loop fits when the number of repetitions is known, and a while loop fits when you know the condition but not how long it will take. Rieker noted that Python needs proper indentation inside a loop.

A third challenge repeated the task with a for loop. An attendee answered by looping over the list and printing each value plus three.

Why use NumPy and Matplotlib for data science?

Rieker explained that Python leaves out functions like sine to keep the base language small, so users import NumPy. A NumPy array holds one data type and, unlike a list, can have a number added to it directly. That removes the need for a loop.

The group then built an array of values with arange and a second array with the sine of those values, and plotted them with Matplotlib's pyplot. The first plot looked odd because NumPy's sine works in radians, so Rieker converted degrees to radians and increased the number of points to 500 for a smooth curve. Rieker then added axis labels, adjusted tick marks and changed the line color.

What should beginners do next?

Rieker encouraged attendees to graph any mathematical function and to read the NumPy documentation for more of a challenge. The suggested learning resources included Packt, YouTube, Coursera and a Harvard course link shared in chat.

Where to find more hands-on sessions

AI Connect continues to run free live sessions. The 2027 schedule includes 24 free live webinars in four series: the AI x Enterprise Panel Series, AI Demo Days, Agentic AI Showcases and the Plug & Play Series. Details are at /webinars/, and registration for 2027 events is coming soon.

Frequently asked questions

How do beginners start coding Python for data science?

Rieker recommended Jupyter Notebook, which runs code in blocks, and used browser-based JupyterLite so no download was needed.

What is the difference between a for loop and a while loop?

Rieker said a for loop is used when you know how many times to repeat, and a while loop when you know the condition that should hold but not how long it will take.

Why use NumPy instead of a Python list?

A NumPy array holds one data type and can have a number added to it directly, avoiding a loop.

Which library makes graphs in Python?

The session used Matplotlib's pyplot to plot a NumPy sine curve and add labels and ticks.

This article is based on remarks by A Rieker, Researcher / Influencer, Ontario Tech University at Data Science Innovators Conference 2023 on April 12, 2023. More coverage: More AI Connect Events.

Filed under: AI Use Cases & Applications, People, Culture & Leadership

More from AI Enterprise Magazine

Read the magazine