{"action":"created","comment":{"url":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/comments/71325018","id":71325018,"diff_hunk":"@@ -1,191 +1,186 @@\n Functions\n *********\n \n-You can think of functions as actions, verbs, or commands \n-and you can think of parameters as adverbs: 'run, quickly'\n+A functions is some code which has been given a name and which can be used\n+wherever you need it in your program. When we use a function we say we are\n+\"calling\" it.\n \n-Functions are special objects that contain code.\n+Some examples of functions we've already used are ``print``, ``int`` and\n+``type``.\n \n-When you call them, using special syntax `()`, you execute the\n-code they contain.\n+    >>> print(\"hello\") hello\n \n-::\n+The ``print`` function simply prints out what is between the brackets. We use\n+one value, or \"argument\", when calling ``print``, but some functions can be\n+called with zero arguments, for example the ``exit`` function:\n \n-    >>> turtle.forward             # functions have names\n-    <function turtle.forward>\n-    >>> turtle.forward(10)         # actioned by use of '()'s\n+    >>> exit()\n \n+Other functions require more than one argument, for example the ``max``\n+function:\n \n-All turtle instructions are examples of calling functions attached \n-to the turtle object.\n-\n-`print` is another function::\n-    \n-    >>> print('hello')\n-\n-`print` simply prints its parameter to the console.\n+    >>> max(1, 2)\n+    2\n+    >>> max(-1000, 1000, 0)\n+    1000\n \n .. tip::\n \n-    Functions and methods are very similar. \n-    Methods exist on objects however functions stand alone.\n-\n+   Like everything else in Python, functions are objects. Function objects\n+   contain code which you run using the brackets containing whatever arguments\n+   that function needs.\n \n-Function objects\n-================\n \n-A function like everything in Python is an object. Function objects are different in that they contain blocks of code.\n+Defining and using functions\n+============================\n \n-Functions help in letting programmers organise and reuse code. They help create new abstractions.\n+Functions help you to organise your code better. You can split up complicated\n+tasks into several smaller, simpler ones. And they allow you to reuse code\n+without repeating it.\n \n-Function objects have names. The name is assigned at the same time you define a function.\n+Definining functions\n+--------------------\n \n-defining\n---------\n+Every function has to be \"defined\" before it can be used. To define a function\n+you use ``def``:\n \n-Creating function objects requires special syntax::\n-\n-    >>> def my_function():\n-    ...     print('hello')    # Note 4 space indentation\n+    >>> def say_hello(name):\n+    ...     print(\"hello \" + name + \"!\")\n     ...\n-    >>> type(my_function)\n-    function\n-\n-The ``def`` keyword is followed by the function object name, followed by () and then a colon. \n-\n-example::\n-\n-    def going_nowhere():\n-        turtle.forward(50)\n-        turlle.backward(50)\n-\n-Note:\n-\n-* The body of a function is the following block of code.\n-* A block is defined by a colon, and one or more indented lines.\n-* The indents are 4 spaces. The block ends on the first non indented line. (Take care to use spaces and not tabs for indenting)\n-\n-Usage\n------\n-\n-We 'call' functions by adding `()` at the end of their names. \n-This is syntax unique to functions. It means action the function objects' code block.\n-\n-\n-IndentationError\n-----------------\n-\n-Indentation is the number of spaces from the left hand side. In python it defines blocks of code. \n-\n-If you get this kind of error::\n-\n-    >>> def awef():\n-    ... print('hi')\n-      File \"<stdin>\", line 2\n-        print('hi')\n-            ^\n-    IndentationError: expected an indented block\n-\n-It simply means the indentation wrong. Here the programmer has\n-forgotten to add 4 spaces on the new line after the colon.\n-\n \n-Arguments\n-=========\n-\n-We saw names generalise code and eases code reuse. This is also true of functions that take arguments.\n+The ``def`` keyword is followed by the function name, then the names of any\n+arguments the function requires inside brackets, and then a colon. On the\n+following lines you write the block of code for the function indented by four\n+spaces, like it's indented when you write an ``if`` or ``while`` block. We call\n+this a \"definition\".\n \n-Compare this function without arguments:: \n+Here's an example of a definition of a function called \"going_nowhere\" which\n+doesn't have any arguments:\n \n-    def draw_right_angle():\n-        turtle.forward(10)\n-        turtle.left(90)\n-        turtle.forward(10)\n+    >>> def going_nowhere():\n+    ...     turtle.forward(50)\n+    ...     turlle.backward(50)\n+    ...\n \n-to this one with arguments:: \n+.. tip::\n \n-    def draw_right_angle(length):\n-        turtle.forward(length)\n-        turtle.left(90)\n-        turtle.forward(length)\n+   It's important to indent the code in a function definition by four spaces. If\n+   you don't you'll see an error saying:\n \n-The second function is more flexible. It can be used to move by any length.\n+   ``IndentationError: expected an indented block``\n \n-The argument acts as a *variable* only defined inside the function's code block.\n+Using functions\n+---------------\n \n-Functions can have many arguments:: \n+Once you've defined a function you can use, or \"call\", it as many times as you\n+need it by putting the function name followed by the brackets containing the\n+arguments the function requires.\n \n-    def move_diagonally(angle, length):\n+    >>> say_hello(\"Barry\")\n+    hello Barry!\n+    >>> say_hello(\"Paul\")\n+    hello Paul!\n+    >>> s_club_7 = [\"Rachel\", \"Jo\", \"Bradley\", \"Tina\", \"Jon\", \"Hannah\", \"Paul\"]","path":"source/functions.rst","position":173,"original_position":173,"commit_id":"6ed5e13003ec332f0fc5f3b3d174754bc53b73c8","original_commit_id":"6ed5e13003ec332f0fc5f3b3d174754bc53b73c8","user":{"login":"susiecoleman","id":6666113,"avatar_url":"https://avatars.githubusercontent.com/u/6666113?v=3","gravatar_id":"","url":"https://api.github.com/users/susiecoleman","html_url":"https://github.com/susiecoleman","followers_url":"https://api.github.com/users/susiecoleman/followers","following_url":"https://api.github.com/users/susiecoleman/following{/other_user}","gists_url":"https://api.github.com/users/susiecoleman/gists{/gist_id}","starred_url":"https://api.github.com/users/susiecoleman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/susiecoleman/subscriptions","organizations_url":"https://api.github.com/users/susiecoleman/orgs","repos_url":"https://api.github.com/users/susiecoleman/repos","events_url":"https://api.github.com/users/susiecoleman/events{/privacy}","received_events_url":"https://api.github.com/users/susiecoleman/received_events","type":"User","site_admin":false},"body":"Enjoying the s club reference :P","created_at":"2016-07-19T12:08:21Z","updated_at":"2016-07-19T12:08:21Z","html_url":"https://github.com/gu-lseg/intro-to-programming/pull/33#discussion_r71325018","pull_request_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/33","_links":{"self":{"href":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/comments/71325018"},"html":{"href":"https://github.com/gu-lseg/intro-to-programming/pull/33#discussion_r71325018"},"pull_request":{"href":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/33"}}},"pull_request":{"url":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/33","id":77883889,"html_url":"https://github.com/gu-lseg/intro-to-programming/pull/33","diff_url":"https://github.com/gu-lseg/intro-to-programming/pull/33.diff","patch_url":"https://github.com/gu-lseg/intro-to-programming/pull/33.patch","issue_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/issues/33","number":33,"state":"open","locked":false,"title":"Functions review ","user":{"login":"maxspencer","id":951849,"avatar_url":"https://avatars.githubusercontent.com/u/951849?v=3","gravatar_id":"","url":"https://api.github.com/users/maxspencer","html_url":"https://github.com/maxspencer","followers_url":"https://api.github.com/users/maxspencer/followers","following_url":"https://api.github.com/users/maxspencer/following{/other_user}","gists_url":"https://api.github.com/users/maxspencer/gists{/gist_id}","starred_url":"https://api.github.com/users/maxspencer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxspencer/subscriptions","organizations_url":"https://api.github.com/users/maxspencer/orgs","repos_url":"https://api.github.com/users/maxspencer/repos","events_url":"https://api.github.com/users/maxspencer/events{/privacy}","received_events_url":"https://api.github.com/users/maxspencer/received_events","type":"User","site_admin":false},"body":"This PR relates to issue #11.\r\n\r\nI found this lesson was quite full on jargon and have tried to make it more example-oriented. For example, I replaced the \"Function scope\" section with a much simpler tip which poses a question about what will happen when a function's argument has the same name as a global variable. I felt this was appropriate for our use.\r\n\r\nThe diff isn't great, sorry.","created_at":"2016-07-18T21:37:46Z","updated_at":"2016-07-19T12:08:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"14e159a53159a33540e226135877ea8f596371a9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/33/commits","review_comments_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/33/comments","review_comment_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/issues/33/comments","statuses_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/statuses/6ed5e13003ec332f0fc5f3b3d174754bc53b73c8","head":{"label":"gu-lseg:functions-review","ref":"functions-review","sha":"6ed5e13003ec332f0fc5f3b3d174754bc53b73c8","user":{"login":"gu-lseg","id":17179555,"avatar_url":"https://avatars.githubusercontent.com/u/17179555?v=3","gravatar_id":"","url":"https://api.github.com/users/gu-lseg","html_url":"https://github.com/gu-lseg","followers_url":"https://api.github.com/users/gu-lseg/followers","following_url":"https://api.github.com/users/gu-lseg/following{/other_user}","gists_url":"https://api.github.com/users/gu-lseg/gists{/gist_id}","starred_url":"https://api.github.com/users/gu-lseg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gu-lseg/subscriptions","organizations_url":"https://api.github.com/users/gu-lseg/orgs","repos_url":"https://api.github.com/users/gu-lseg/repos","events_url":"https://api.github.com/users/gu-lseg/events{/privacy}","received_events_url":"https://api.github.com/users/gu-lseg/received_events","type":"Organization","site_admin":false},"repo":{"id":61215608,"name":"intro-to-programming","full_name":"gu-lseg/intro-to-programming","owner":{"login":"gu-lseg","id":17179555,"avatar_url":"https://avatars.githubusercontent.com/u/17179555?v=3","gravatar_id":"","url":"https://api.github.com/users/gu-lseg","html_url":"https://github.com/gu-lseg","followers_url":"https://api.github.com/users/gu-lseg/followers","following_url":"https://api.github.com/users/gu-lseg/following{/other_user}","gists_url":"https://api.github.com/users/gu-lseg/gists{/gist_id}","starred_url":"https://api.github.com/users/gu-lseg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gu-lseg/subscriptions","organizations_url":"https://api.github.com/users/gu-lseg/orgs","repos_url":"https://api.github.com/users/gu-lseg/repos","events_url":"https://api.github.com/users/gu-lseg/events{/privacy}","received_events_url":"https://api.github.com/users/gu-lseg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gu-lseg/intro-to-programming","description":"programming intro for complete beginners using python","fork":true,"url":"https://api.github.com/repos/gu-lseg/intro-to-programming","forks_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/forks","keys_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/teams","hooks_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/hooks","issue_events_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/issues/events{/number}","events_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/events","assignees_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/assignees{/user}","branches_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/branches{/branch}","tags_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/tags","blobs_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/git/refs{/sha}","trees_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/statuses/{sha}","languages_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/languages","stargazers_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/stargazers","contributors_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/contributors","subscribers_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/subscribers","subscription_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/subscription","commits_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/commits{/sha}","git_commits_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/git/commits{/sha}","comments_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/comments{/number}","issue_comment_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/issues/comments{/number}","contents_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/contents/{+path}","compare_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/merges","archive_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/downloads","issues_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/issues{/number}","pulls_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls{/number}","milestones_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/milestones{/number}","notifications_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/labels{/name}","releases_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/releases{/id}","deployments_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/deployments","created_at":"2016-06-15T14:43:22Z","updated_at":"2016-06-22T12:42:17Z","pushed_at":"2016-07-19T12:02:14Z","git_url":"git://github.com/gu-lseg/intro-to-programming.git","ssh_url":"git@github.com:gu-lseg/intro-to-programming.git","clone_url":"https://github.com/gu-lseg/intro-to-programming.git","svn_url":"https://github.com/gu-lseg/intro-to-programming","homepage":null,"size":457,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":20,"forks":0,"open_issues":20,"watchers":1,"default_branch":"master"}},"base":{"label":"gu-lseg:master","ref":"master","sha":"a904c38ac3f228fea207394e17dc99662e7dc63a","user":{"login":"gu-lseg","id":17179555,"avatar_url":"https://avatars.githubusercontent.com/u/17179555?v=3","gravatar_id":"","url":"https://api.github.com/users/gu-lseg","html_url":"https://github.com/gu-lseg","followers_url":"https://api.github.com/users/gu-lseg/followers","following_url":"https://api.github.com/users/gu-lseg/following{/other_user}","gists_url":"https://api.github.com/users/gu-lseg/gists{/gist_id}","starred_url":"https://api.github.com/users/gu-lseg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gu-lseg/subscriptions","organizations_url":"https://api.github.com/users/gu-lseg/orgs","repos_url":"https://api.github.com/users/gu-lseg/repos","events_url":"https://api.github.com/users/gu-lseg/events{/privacy}","received_events_url":"https://api.github.com/users/gu-lseg/received_events","type":"Organization","site_admin":false},"repo":{"id":61215608,"name":"intro-to-programming","full_name":"gu-lseg/intro-to-programming","owner":{"login":"gu-lseg","id":17179555,"avatar_url":"https://avatars.githubusercontent.com/u/17179555?v=3","gravatar_id":"","url":"https://api.github.com/users/gu-lseg","html_url":"https://github.com/gu-lseg","followers_url":"https://api.github.com/users/gu-lseg/followers","following_url":"https://api.github.com/users/gu-lseg/following{/other_user}","gists_url":"https://api.github.com/users/gu-lseg/gists{/gist_id}","starred_url":"https://api.github.com/users/gu-lseg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gu-lseg/subscriptions","organizations_url":"https://api.github.com/users/gu-lseg/orgs","repos_url":"https://api.github.com/users/gu-lseg/repos","events_url":"https://api.github.com/users/gu-lseg/events{/privacy}","received_events_url":"https://api.github.com/users/gu-lseg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gu-lseg/intro-to-programming","description":"programming intro for complete beginners using python","fork":true,"url":"https://api.github.com/repos/gu-lseg/intro-to-programming","forks_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/forks","keys_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/teams","hooks_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/hooks","issue_events_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/issues/events{/number}","events_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/events","assignees_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/assignees{/user}","branches_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/branches{/branch}","tags_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/tags","blobs_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/git/refs{/sha}","trees_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/statuses/{sha}","languages_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/languages","stargazers_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/stargazers","contributors_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/contributors","subscribers_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/subscribers","subscription_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/subscription","commits_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/commits{/sha}","git_commits_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/git/commits{/sha}","comments_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/comments{/number}","issue_comment_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/issues/comments{/number}","contents_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/contents/{+path}","compare_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/merges","archive_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/downloads","issues_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/issues{/number}","pulls_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls{/number}","milestones_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/milestones{/number}","notifications_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/labels{/name}","releases_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/releases{/id}","deployments_url":"https://api.github.com/repos/gu-lseg/intro-to-programming/deployments","created_at":"2016-06-15T14:43:22Z","updated_at":"2016-06-22T12:42:17Z","pushed_at":"2016-07-19T12:02:14Z","git_url":"git://github.com/gu-lseg/intro-to-programming.git","ssh_url":"git@github.com:gu-lseg/intro-to-programming.git","clone_url":"https://github.com/gu-lseg/intro-to-programming.git","svn_url":"https://github.com/gu-lseg/intro-to-programming","homepage":null,"size":457,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":20,"forks":0,"open_issues":20,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/33"},"html":{"href":"https://github.com/gu-lseg/intro-to-programming/pull/33"},"issue":{"href":"https://api.github.com/repos/gu-lseg/intro-to-programming/issues/33"},"comments":{"href":"https://api.github.com/repos/gu-lseg/intro-to-programming/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gu-lseg/intro-to-programming/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/gu-lseg/intro-to-programming/statuses/6ed5e13003ec332f0fc5f3b3d174754bc53b73c8"}}}}
{"actor":{"display_login":"susiecoleman"}}