
Module 4 - Functions
Over the two weeks, our class will focus on accomplishing two main objectives. The first and foremost goal is to delve into the intricacies of using functions in Python programming. Functions are crucial building blocks that allow you to create organized, modular, and more manageable code. They enable you to compartmentalize different tasks within your program, thereby simplifying complex operations and facilitating easier debugging and maintenance.
Functions in Python serve a dual purpose: they can accept variables as input and return variables as output. This input-output mechanism allows for greater flexibility and reusability in your code. For example, you can create a function that calculates the square of a number and use it throughout your program without having to rewrite the same logic multiple times. This not only makes your code more efficient but also significantly easier to read and understand.
By mastering the concept of functions, you will gain a powerful tool that is fundamental to Python and programming in general. You’ll learn how to declare functions, pass parameters, and return values, among other things. Understanding functions will also pave the way for more advanced programming topics, including object-oriented programming and error handling, which we will explore later in this course. Overall, becoming proficient in using functions will elevate the quality and efficiency of your coding projects.
W3 Schools
https://www.w3schools.com/python/python_functions.asp
https://www.w3schools.com/python/python_scope.asp
Recommended YouTube Videos
CS Dojo – How to Use Functions in Python
Bro Code – Functions in Python are easy
Create a Notebook Chapter on Functions
Chapter Title: Functions
1. What is function?
Briefly explain why you would use a function
Mention why it is useful in programming.
2. What is the “main” function?
Show how to utilize the “main” function. From now on all your code will use the “main” function. Be sure to call the main at the end of each program.
3. Passing Variables into a Function
Go over how to pass data (variables) into a function. Show both keyword and positional arguments.
4. Getting Values back from a Function
Go over how to return a value back to your call.
Go over where the returned value or values is stored, be sure to have great examples.
How do you return multiple values? Show how they are returned back to the call with examples.
5. What is an IPO chart used for?
Show some great examples of IPO charts.
6. What is the scope?
What is the scope of a variable? What is global scope?
What is the scope of a constant? What is a global constant?
Chapter Summary
Summarize the key concepts covered in the chapter.
Encourage students to practice writing code and experimenting with concepts.
Assignment Instructions
- In your notebook, create a well-organized chapter following the structure provided.
- Include explanations, examples, and where appropriate, screenshots.
- Feel free to add personal insights or observations.
Turn in Your Assignment
MMIS 6391 – After you finish creating your textbook chapter, save it as a PDF and upload the PDF to GeorgiaView.
CBIS 4210 – You will need to login to the OneNote “class” that was created for you. Create pages in Section 1 and add content into the OneNote.
Creating a PyCharm Video Tutorial for Functions
Assignment Description
For this task, you are to produce a step-by-step video guide that demonstrates the use of functions in your Python application. You’ll employ the PyCharm IDE for project development and management. The objective of this assignment is twofold: to deepen your understanding of how to implement functions and to refine your ability to convey complex information through a well-crafted video tutorial.
Objective
The main objectives of this assignment are:
- Gain a comprehensive understanding of how to use functions, with a particular focus on ‘if statements” and “loops” in Python programming.
- Continue to familiarize yourself with using PyCharm IDE for creating and managing a Python project.
- Learn the importance and implementation of control structures for enabling decision-making processes within a Python application.
Instructions
Topic Selection
Select a straightforward collection of applications to feature in your tutorial. Create an application that uses at least 4 different functions you have created. Be sure each one takes in at least one variable and returns out a value. Also use a couple global variables and global constants in your application.
Video Tutorial Creation
- Coding Walkthrough: Create a step-by-step video tutorial demonstrating the process of using proper functions.
Clarity and Communication
- Use clear and concise language to explain each step of the setup and coding process.
- Ensure that your instructions are easy to follow and suitable for an audience unfamiliar with functions.
- Include visual aids like annotations, highlighting, and cursor tracking to guide viewers’ attention.
Video Format and Length
- The video should be between 7 to 10 minutes in length.
- Use screen recording software to capture your coding process.
- You can use video editing software to enhance the clarity and quality of the tutorial.
Submission
After you create your video upload it to your YouTube channel that comes with your school email address. You can set your video to unlisted, but be sure to make sure it can be viewed. Be sure to write a brief description of your video in the YouTube video description.
Upload your YouTube video link to the comment section of this assignment.
Upload your .py file to this Assignment.
Prepare for an in-class quiz where you’ll be tasked with building a functional application that uses functions. Ensure you’re equipped with the skills to gather user input, establish variables, perform calculations, and generate output using f-strings using functions to pass and return values.