Python (Fall 2026) Module 2-4: Understanding Functions
Overview
Bill Moseley explains how to read Python function references and why programmers should learn to look up functions rather than memorize every parameter. Using print, input, and type, he demonstrates the difference between functions that perform an action and functions that return values, including storing, nesting, and inspecting those values.
Key takeaways
- Python function references typically explain a function's purpose, show its syntax, and identify required and optional arguments, making them useful beyond any single function.
- A function's return value must be assigned, passed to another function, or otherwise used; otherwise, Python discards it.
- input(prompt) returns what the user types, not the prompt text, so storing a user's name requires an assignment such as strName = input("Type your name").
- Python's print function accepts multiple arguments and separates them with spaces by default, which makes it easy to combine text and a variable in one output line.
- Nesting input inside print lets a program immediately display the user's response without first saving it in a variable.
- type(variable) reports the type of the value currently stored, regardless of whether the variable's name accurately describes that value.
Chapters
- Function references describe what a function does, show its syntax, and list required and optional arguments.
- Python's print function requires something to display; optional parameters include sep, end, and file.
- Moseley advises learning what functions are available and looking up details as needed instead of memorizing every parameter.
- Some functions, such as print, perform an action, while return-value functions send results back to Python for use or storage.
- input(prompt) displays instructions such as "Type your name" and returns the text the user enters.
- Assigning input to strName stores the user's response; without assignment or another use, the returned value is discarded.
- Passing "Hi", strName, and "Nice to meet you" to print displays them on one line, with spaces inserted by print's default separator.
- The string inside input is a prompt, not a preset value; nesting input inside print immediately displays the returned response without storing it.
- type(strName) returns the data type of the value, so nesting it inside print displays results such as str or int.
- A variable name does not enforce its contents: assigning 42 to strName makes type(strName) report an integer.
- input pauses program execution until the user types a response and presses Enter.
- A prompt such as "Press Enter to continue" can use input as a pause, with the returned text left unused.
Transcript excerpt
0:02 So we've talked about variables and data types. I want to talk a little bit about functions, and what I mean when I say function. So a function is like print, and I will add a link in Python, or in our class on Canvas, to a function reference that has a lot of our basic functions that we'll be using in this class, in pages like this. And this is a common format. If you Google Python print function, you will come up with a web page that looks a lot like this. It often has these same elements. So I want to teach you now how to read a page like this so that you can use any function that you can look up in Python. Why do I want you to learn that?
0:54 Because for the rest of your programming life, you will be looking up functions. I looked up a function yesterday, and I've been doing Python programming for decades. But here's the deal. Our brains, in spite of everything you've learned, your entire education, are not containers for data. Our brains are thinking machines. Trying to store a bunch of data in there just clouds your ability to think. You only got a certain amount of space. In fact, one researcher described our brains as like a small table. You can put stuff on the small table and you can add as much as you want there, but eventually you're going to add so much crap on the small table that you're going to be pushing other stuff off. So here's what I suggest. This
1:45 isn't a memorize it kind of class. This is a have an idea of what's possible kind of class, and learn how to look it up. And if you focus on that in your programming. You know, you've
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.