Python 2.7 Tutorial Pt 6

Python PictureIn this video I’ll explain how to use functions in Python 2.5 through 2.7. I’m going to cover how to:

  • Create Functions
  • Pass Values to Functions
  • Create Default Values
  • Except Unlimited Arguments
  • Except Unlimited Key Value Pairs
  • Use Recursion
  • and more…

Like always, the code follows the video. If you have any questions or comments leave them below. And, if you missed my other Python Tutorials they are available here:

Here is Some Code that Demonstrates using Python Functions

#! /usr/bin/python

# Define a docstring a special function attribute
globalVariable = 10

def addNumbers(NumOne=1,NumTwo=1):
‘Adds the numbers passed to it’
return NumOne + NumTwo

def addUndefNums(NumOne=1,NumTwo=1,*args):
‘Adds the numbers passed to it’
finalValue = NumOne + NumTwo
if args:
for i in args:
finalValue += i
return finalValue
else:
return finalValue

def scopeFunction():
mainNumber = 10
print id(mainNumber)
print “mainNumber equals”, mainNumber, “in function scopeFunction”
return

def changeGlobal():
globals()[‘globalVariable’] = 20
return

def createDict(**kvargs):
for i in kvargs:
print i, kvargs[i]
print type(kvargs[i])

print type(kvargs)
print kvargs
return

def factorial(num):
if num == 1:
return 1
else:
return num * factorial(num – 1)

def printNames(first,last):
pass

def main():

# Demonstrate difference between global & local scope
mainNumber = 5
print “mainNumber equals”, mainNumber, “in function main”
scopeFunction()
print “mainNumber equals”, mainNumber, “after scopeFunction”
print id(mainNumber)

# Force a global variable to change
print “globalVariable before changeGlobal =”, globalVariable
changeGlobal()
print “globalVariable after changeGlobal =”, globalVariable

# Create a function with a docstring
print addNumbers(1)
print addNumbers.__doc__

# Add undefined number of numbers with a tuple
print addUndefNums(1,2,3,4,5,6,7,8)

# Create a dictionary
createDict(Name=’Derek’, Age=35, YearBorn=1974)
createDict(Cust1=(‘Derek’,35,1974),Cust2=(‘Sally’,25,1984),Cust3=(‘Paul’,15,1994))

# Demonstrate Recursion
print factorial(3)

“””
Demonstrate Recursion
def factorial(3):
if 3 == 1:
return 1
else:
return 3 * factorial(2)

def factorial(2):
if 2 == 1:
return 1
else:
return 2 * factorial(1)

def factorial(1):
if 1 == 1:
return 1

“””

if __name__ == ‘__main__’: main()

Python 2.7 Tutorial Pt 5

Python How ToIn this Python Video Tutorial I focus on looping in Python 2.5 through 2.7. I explain how to use the while loop and the many ways to use the for loop.

Along the way I explain how the in operator is used in Python and the range function.

Like always, the code follows the video. If you have any questions or comments leave them below. And, if you missed my other Python Tutorials they are available here:

Continue reading Python 2.7 Tutorial Pt 5

Python 2.7 Tutorial Pt 4

Python 2.7 TutorialI continue the Python 2.7 Tutorial by explaining a couple new things. I first go over how to turn your Python code into an executable application.

I then cover Python Conditionals. Conditionals are used to perform certain actions under one condition and other actions based on other conditions. In Python you can do this either with an IF Statement, or with something called a Conditional Expression.

Like always, the code follows the video. If you have any questions or comments leave them below. And, if you missed my other Python Tutorials they are available here:

Continue reading Python 2.7 Tutorial Pt 4

Python 2.7 Tutorial Pt 3

PythonIn part 3 of my Python 2.7 Tutorial, I explain how to use the Dictionary, Print method and how to work with String methods.

If you haven’t seen part 1 or 2 definitely look at them first or you’ll be very confused Python 2.7 Tutorial Part 1 and Python 2.7 Tutorial Part 2.

All of the code I use in these tutorials follow the video and can be used however you’d like.

If you have any questions or comments leave them below.

Continue reading Python 2.7 Tutorial Pt 3

Python 2.7 Tutorial Pt 2

Python Picture

I continue with my Python 2.7 tutorial here. If you missed part one (How Dare You) you must watch it first at Python 2.7 Tutorial. Otherwise you’ll be confused. I specifically explain how to use Python Lists, Tuples and Dictionaries. These work very similar to arrays in other languages.

An array is a variable that contains multiple values. Think of an array as a box that contains many other boxes, that all contain values. These values can be a mixture of different data types (ints, floats, strings). Here is how Python Lists, Tuples, and Dictionaries differ:

Continue reading Python 2.7 Tutorial Pt 2

Python 2.7 Tutorial

Python How ToI asked you guys what video I should do next, and based on your votes you wanted a Python 2.7 Tutorial! Because of the tremendous interest, I will be rolling out a Massive tutorial for Python. I actually did one on Python 3.0 if you want that instead though. Here it is Python How to Video Part 1.

The tools I use in this tutorial include the Eclipse IDE and Pydev. I document how to install them in the video below, but also in this article Free IDE.

Now on with the video. All of this code will work with Python 2.5 thru 2.7. The code will follow the video. If you have any questions or comments leave them below. Here is all the code from the entire tutorial in a zip archive.

Continue reading Python 2.7 Tutorial

What Should I Do

QuestionI’ve recently been hit with a ton of requests for tutorials. I want you all to know I received them and plan to do them as soon as possible, but I need help ranking them.

Below I’m listing all of the tutorials that you have been requesting. Who ever comments first will decide which tutorial I do next. If your second in line, your tutorial will go next and so on.

Because I’ve received so many requests for a Python 2.7 Tutorial, I will cover that next. Then I’ll move on to your other requests.

Continue reading What Should I Do

How to Knit Part 2

How To KnitMy wife’s first knitting video was a hit! So, here my wife continues teaching how to knit. Here is a link to the first tutorial How to Knit.

Specific knitting techniques covered include:

  • Purl Stitch
  • Stockinette Stitch
  • Rib Stitch

She is planning on creating a tutorial that will teach you how to make a Twitter Fail Whale. Leave any comments or suggestions on what you’d like to see in future tutorials.

Financial Statements Video Pt 3

YouTube LogoIn this video I finish off my Financial Statements Video Tutorial with a ton of examples. I specifically cover the following topics:

  • How Financial Statements are Effected when the Cost of Inventory Changes
  • First In First Out versus Last In First Out Inventory Usage
  • How to Use and Read a Cash Flow Statement
  • How to Treat Fixed Assets and What they are
  • How to Handle Depreciation of Fixed Assets

This tutorial was fun to put together. Thanks to Anne and Kara for suggesting that I create it. I think I succeeded in explaining the basics of Financial Statements in an understandable way.

If you have any questions or comments leave them below. If you want me to do a future tutorial on a specific topic, leave it below as well!

[adsense]

Till Next Time

Think Tank

Financial Statements Video Pt 2

Puzzled About DerivativesIn this article I provide you with two videos that will explain how to read financial statements.

In the first video, I cover how the following effect your financial statements: Paying off Debt, Hiring an Employee, Buying with Credit, the Accrual Method, the Cash Method.

In the second video, I cover how product and service business balance sheets differ. I compare accrual method income statements to cash method income statements.

If you didn’t see the first video check that out here Financial Statements Video Pt 1.

Continue reading Financial Statements Video Pt 2

Financial Statements Video

Puzzled About DerivativesIn this video tutorial I explain how to create financial statements. I use an example business and walk you though how balance sheets and income statements are effected by business transactions.

I also go over and explain the following:

  • Assets
  • Equity
  • Liabilities
  • Accounts Receivable
  • Notes Payable
  • Accounts Payable
  • Prepaid Expenses

Continue reading Financial Statements Video

Service Business Financial Statements

Puzzled About DerivativesKara wrote in and asked me to further explain the difference between a service business’s financial statements and that of a product business. I’ll provide another example that should make it more understandable. Definitely check out my previous tutorial before reading this. It is available here The Balance Sheet.

Ever since you made all that money with Mark, your employee, you have been fixated on franchising. Many friends want to learn how to caricature and you want to try out cost method accounting (tax benefits)!

You decide to teach your caricature methods to your friends and help them market for a flat fee of $500. You start your new franchise service called Cartoon You.

Continue reading Service Business Financial Statements

The Balance Sheet Pt 2

Puzzled About DerivativesIn this article I’m going to continue explaining how to use balance sheets. If you missed my previous tutorial check it out here The Balance Sheet.

Before I begin I received a request to better explain the difference between Accounts Payable and Notes Payable.

  • Accounts Payable: Short term loans that are normally due in full within a month. This loan doesn’t have interest attached if it is paid on time.
  • Notes Payable: Long term loans that require interest payments

You should now understand the difference, but if not leave a comment below.

Continue reading The Balance Sheet Pt 2

Decision Making Videos

Brain IdeasHere I finish going over how people go through the process of Decision Making. If you haven’t, watch the first Decision Making videos here. Each person makes each decision in very specific ways. If you understand how they make decisions you will find it very easy to negotiate and persuade them into believing what ever you would like.

To find out how they make decisions, you just need to ask them one question. If you then structure your negotiation in a way that is compatible with their way of making decisions you dramatically increase your persuasiveness.

In the videos here and in the previous article, I teach you the questions to ask and all of the many ways people make decisions. These are high level negotiation techniques and if you want to see them put into use in a more understandable way, check out my sales technique videos. (They are free also)

Continue reading Decision Making Videos

The Balance Sheet

Puzzled About DerivativesAnne wrote in and asked, “Can you to a tutorial on the balance sheet and the other financial statements. Is there a simple way to explain Financial Statements?”

Financial statements aren’t really that complicated in their basic forms. I’ll focus on explaining the balance sheet, with a little on Income Statements in this tutorial. I’ll explain how they are used step-by-step for an example caricature business.

Note: Each time I introduce a new item in the balance sheet I will place it in italics.

Continue reading The Balance Sheet

Cartoon Hands

Flash TutorialA couple of articles ago I provided you with a bunch of pre-drawn cartoon parts for Flash. That article is available here How to Draw. I also provided some tutorials on drawing the human face, eyes, nose, lips, etc.

I received an email requesting for me to provide pre-drawn cartoon hands from Clarence. So here are some vector drawn cartoon hands that you can use in Flash. Cartoon Vector Hands

You can do anything you would like with them. I hope to eventually provide an entire library of pre-drawn cartoon parts that you can use in Flash. I want to make it as easy as possible to animate cartoons in Flash, whether you can draw or not.

Continue reading Cartoon Hands

Decision Making

Brain IdeasJohn wrote in and asked for more videos on Decision Making. To be specific, how we make decisions based off of psychological research.

When we experience anything in life we leave out a large portion of the information. We ignore and generalize because there is just too much information to take in. The information that we do store, makes up our own personal version of what happened during any point in the past.

Our version is always going to be flawed, because of all the information we deleted. We then make decisions using our own personal reasoning process. This is known as our Meta Program. In the following videos, I’ll show you how everyone makes decisions through the use of Meta Programming.

Continue reading Decision Making

Flash Jib Jab Animation

Sarah Palin Jib Jab CartoonCarl wrote in and requested that I create a video on how to create Jib Jab Style Flash Animation. It is actually very simple to copy their overall style. I think the hardest thing to copy is their very funny songs and Jib Jab’s great composition work.

You can actually do a lot with Flash Animation. Actually most cartoons on Cartoon Network were created with Flash. I’m working on my own cartoon as we speak. If you have any specific tutorials you’d like to see on Flash Animation leave them in the comment section below.

Here is the link to the files I create in this tutorial Flash Jib Jab Animation. You are welcome to do whatever you’d like with them.

Continue reading Flash Jib Jab Animation

Interview Questions and Answers

How to Deal with PeopleA while back I received the following question from Paula “What are some typical interview questions? Can you list some interview mock questions from a typical interview and how to answer them? I especially want to be able to answer the weakness interview question.”

Archimedes recently asked me “How to give a favorable impression during an interview?”

A wrote an article in which I specifically answered this question and it can be found here Interview Typical Questions. You could also just watch the following video for the same information on Interview Questions and Answers. I go over:

Continue reading Interview Questions and Answers