mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-05-05 14:28:31 +00:00
Merge pull request #1015 from nero-luci/patch-2
Update python3.html.markdown. Changes to spacing and online resources
This commit is contained in:
commit
928afcc4c7
@ -276,7 +276,7 @@ empty_set = set()
|
|||||||
# Initialize a set with a bunch of values. Yeah, it looks a bit like a dict. Sorry.
|
# Initialize a set with a bunch of values. Yeah, it looks a bit like a dict. Sorry.
|
||||||
some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4}
|
some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4}
|
||||||
|
|
||||||
#Can set new variables to a set
|
# Can set new variables to a set
|
||||||
filled_set = some_set
|
filled_set = some_set
|
||||||
|
|
||||||
# Add one more item to the set
|
# Add one more item to the set
|
||||||
@ -394,7 +394,6 @@ our_iterator.__next__() # Raises StopIteration
|
|||||||
list(filled_dict.keys()) #=> Returns ["one", "two", "three"]
|
list(filled_dict.keys()) #=> Returns ["one", "two", "three"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
## 4. Functions
|
## 4. Functions
|
||||||
####################################################
|
####################################################
|
||||||
@ -410,7 +409,6 @@ add(5, 6) # => prints out "x is 5 and y is 6" and returns 11
|
|||||||
# Another way to call functions is with keyword arguments
|
# Another way to call functions is with keyword arguments
|
||||||
add(y=6, x=5) # Keyword arguments can arrive in any order.
|
add(y=6, x=5) # Keyword arguments can arrive in any order.
|
||||||
|
|
||||||
|
|
||||||
# You can define functions that take a variable number of
|
# You can define functions that take a variable number of
|
||||||
# positional arguments
|
# positional arguments
|
||||||
def varargs(*args):
|
def varargs(*args):
|
||||||
@ -418,7 +416,6 @@ def varargs(*args):
|
|||||||
|
|
||||||
varargs(1, 2, 3) # => (1, 2, 3)
|
varargs(1, 2, 3) # => (1, 2, 3)
|
||||||
|
|
||||||
|
|
||||||
# You can define functions that take a variable number of
|
# You can define functions that take a variable number of
|
||||||
# keyword arguments, as well
|
# keyword arguments, as well
|
||||||
def keyword_args(**kwargs):
|
def keyword_args(**kwargs):
|
||||||
@ -636,6 +633,7 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :(
|
|||||||
* [The Official Docs](http://docs.python.org/3/)
|
* [The Official Docs](http://docs.python.org/3/)
|
||||||
* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/)
|
* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/)
|
||||||
* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182)
|
* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182)
|
||||||
|
* [Python Course](http://www.python-course.eu/index.php)
|
||||||
|
|
||||||
### Dead Tree
|
### Dead Tree
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user