December 22nd, 2012, 05:26 PM
Python 3.3 Syntax question
So i am 15 and have decided to learn python. I have found a good tutorial which covers almost everything. I do have some questions that i deem important to know.
1. When creating this function how does "Fred" become the name since i see no name = "fred"
2. I have heard that you should not use white-space in python. Where can i use white-space and where can i not. I do not want to make any bad habits
December 22nd, 2012, 06:36 PM
1. The first (and only) parameter of the function is called "name". When you call the function with the argument "fred", that value is bound to the name "name" in the function's scope. Note, however, that you can explicitly call print_welcome(name="fred") instead, with the same result.
2. I'm not sure exactly what was meant here. Perhaps what whoever said this was trying to communicate is that whitespace (specifically indentation) is significant in Python.
December 22nd, 2012, 08:25 PM
And since white space significantly denotes blocks of statements, you must post python code in these forums within [code] tags. Please read and follow the link at my signature for more information.
[/code] are essential for python code and Makefiles!
December 22nd, 2012, 09:55 PM
This might explain the value of a function better:
print("A friendly welcome to " + name)
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25