Python Beginner Tutorial 2 - Functions and Variables

Recommended Posts


This tutorial covers the creation of basic functions and how to define variables. After watching this video you should be able to define functions with zero or one argument, create variables, and understand the basics of scope in python.

Post questions and comments specifically related to this video below.

Share this post

Link to post
Share on other sites

Hello, Your videos are extremely helpful and I learning how to code little by little each day.

I do have a particular question on a part in the video.

At 9:40 of the video, could you re-explain that area to me again? Thanks


Share this post

Link to post
Share on other sites

Sure! See the code below with comments and some changed names to make it easier to understand. My bad on that originally.

def main():

def myPrintFunction(somethingToPrint):
# This will not work because aGlobalVariable has not been defined yet

# Global variable. Typically defined at the top of the file but does not need to be. That is best practice

aGlobalVariable = "This is a global variable." 

# Call the main function. This will print aGlobalVariable

# Directly call the print function. This will print aGlobalVariable again to illistrate it is in fact global

# Define another variable
otherVariable = "Something else" 

# This will print otherVariable by calling our myPrintFunction that then calls the print function.

Let me know if you need me to clarify anything specifically.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now