Python With Spyder 3: Functions and Scoping

preview_player
Показать описание
This is the 3rd in a series of videos providing a tutorial on Python 2.7 using Anaconda Python and the Spyder IDE. The topics covered in this video are functions and variable scoping.
Рекомендации по теме
Комментарии
Автор

Very helpful, especially for beginner with 0 coding experience! Thx!!!

o_ol
Автор

I go to University of Illinois at Chicago and takes a CS class with Dr. Sloan and he doesnt go over any of the specifics. He just babbles about how far computers have come in lecture, etc. I guess I'm going to take your online course as a supplement to get some meat in my CS diet. Thank you for this!

david_m
Автор

I assigned the variables inside the function to become A, B, and C, just in order to tell them apart from the global variables. I find it easier for beginners to learn what is happening this way, without mixing up what is happening. My code looks like this:


x = 1
y = 2
z = 3

def f(A=0, B=0, C=0):
out = A**2 + B**2 + C**2
return out

print "f1 = ", f(x, y, z)

print "f2 = ", f(x, y)

print "f3 = ", f(B=y, C=z)

print "f4 = ", f(B=x, C=y)

print "f5 = ", f(0, 1, 2)


And this would return:
f1 = 14
f2 = 5
f3 = 13
f4 = 5
f5 = 5

Just thought that this might be helpful.

jeanapp_
Автор

how can I make the output (Y) appears in the variable explores?

marangoisa
Автор

when using conditionals in my spyder I type "

age=21

if age < 16:
print(" You cant drive ")
if age > 16
print(" you can drive ")

But a TypeError that says " '<' is not valid between str. int.
What is wrong?
THANKS Dr. Easton
GOD

thewildernessoutdoorboys
Автор

Hello, I kept getting this error.

print myfun(5)
^
SyntaxError: invalid syntax

even though I copied exactly what you written there. Please help

Charlie-tbjp