8000 c9-python-getting-started/13 - Functions at master · hamyct/c9-python-getting-started · GitHub
[go: up one dir, main page]

Skip to content
{"payload":{"allShortcutsEnabled":false,"path":"13 - Functions","repo":{"id":210619647,"defaultBranch":"master","name":"c9-python-getting-started","ownerLogin":"hamyct","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2019-09-24T14:12:31.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/30110335?v=4","public":true,"private":false,"isOrgOwned":false},"currentUser":null,"refInfo":{"name":"master","listCacheKey":"v0:1614332192.240556","canEdit":false,"refType":"branch","currentOid":"b09501b9f7dfc42daf9d63b9b26b2006fa1b04f2"},"tree":{"items":[{"name":"README.md","path":"13 - Functions/README.md","contentType":"file"},{"name":"code_challenge.py","path":"13 - Functions/code_challenge.py","contentType":"file"},{"name":"code_challenge_solution.py","path":"13 - Functions/code_challenge_solution.py","contentType":"file"},{"name":"get_initails_function.py","path":"13 - Functions/get_initails_function.py","contentType":"file"},{"name":"get_initials.py","path":"13 - Functions/get_initials.py","contentType":"file"},{"name":"getting_clever_with_functions_harder_to_read.py","path":"13 - Functions/getting_clever_with_functions_harder_to_read.py","contentType":"file"},{"name":"print_time_function.py","path":"13 - Functions/print_time_function.py","contentType":"file"},{"name":"print_time_function_different_messages.py","path":"13 - Functions/print_time_function_different_messages.py","contentType":"file"},{"name":"print_time_function_fix_import.py","path":"13 - Functions/print_time_function_fix_import.py","contentType":"file"},{"name":"print_time_repeated_code.py","path":"13 - Functions/print_time_repeated_code.py","contentType":"file"},{"name":"print_time_with_message_parameter.py","path":"13 - Functions/print_time_with_message_parameter.py","contentType":"file"}],"templateDirectorySuggestionUrl":null,"readme":{"displayName":"README.md","richText":"\u003carticle class=\"markdown-body entry-content container-lg\" itemprop=\"text\"\u003e\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch1 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eFunctions\u003c/h1\u003e\u003ca id=\"user-content-functions\" class=\"anchor\" aria-label=\"Permalink: Functions\" href=\"#functions\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eFunctions allow you to take code that is repeated and move it to a module that can be called when needed. Functions are defined with the \u003ccode\u003edef\u003c/code\u003e keyword and must be declared before the function is called in your code. Functions can accept parameters and return values.\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://docs.python.org/3/tutorial/controlflow.html#defining-functions\" rel=\"nofollow\"\u003eFunctions\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"def functionname(parameter):\n # code to execute\n return value\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003efunctionname\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eparameter\u003c/span\u003e):\n \u003cspan class=\"pl-c\"\u003e# code to execute\u003c/span\u003e\n \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003evalue\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/article\u003e","errorMessage":null,"headerInfo":{"toc":[{"level":1,"text":"Functions","anchor":"functions","htmlText":"Functions"}],"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fhamyct%2Fc9-python-getting-started%2Ftree%2Fmaster%2F13%2520-%2520Functions"}},"totalCount":11,"showBranchInfobar":true},"fileTree":{"":{"items":[{"name":"10 - Complex conditon checks","path":"10 - Complex conditon checks","contentType":"directory"},{"name":"11 - Collections","path":"11 - Collections","contentType":"directory"},{"name":"12 - Loops","path":"12 - Loops","contentType":"directory"},{"name":"13 - Functions","path":"13 - Functions","contentType":"directory"},{"name":"14 - Function parameters","path":"14 - Function parameters","contentType":"directory"},{"name":"15 - Packages","path":"15 - Packages","contentType":"directory"},{"name":"16 - Calling APIs","path":"16 - Calling APIs","contentType":"directory"},{"name":"17 - JSON","path":"17 - JSON","contentType":"directory"},{"name":"18 - Decorators","path":"18 - Decorators","contentType":"directory"},{"name":"2 - Print","path":"2 - Print","contentType":"directory"},{"name":"3 - Comments","path":"3 - Comments","contentType":"directory"},{"name":"4 - String variables","path":"4 - String variables","contentType":"directory"},{"name":"5 - Numeric variables","path":"5 - Numeric variables","contentType":"directory"},{"name":"6 - Dates","path":"6 - Dates","contentType":"directory"},{"name":"7 - Error handling","path":"7 - Error handling","contentType":"directory"},{"name":"8 - Handling conditions","path":"8 - Handling conditions","contentType":"directory"},{"name":"9 - Handling multiple conditions","path":"9 - Handling multiple conditions","contentType":"directory"},{"name":"Slides","path":"Slides","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":"CODE_OF_CONDUCT.md","path":"CODE_OF_CONDUCT.md","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"SECURITY.md","path":"SECURITY.md","contentType":"file"}],"totalCount":23}},"fileTreeProcessingTime":7.665566,"foldersToFetch":[],"treeExpanded":true,"symbolsExpanded":false,"csrf_tokens":{"/hamyct/c9-python-getting-started/branches":{"post":"aKhpjyQ0e68dtH2eemU9WeuQv4M1WkHCEvOP8TKo2Iy6zhWl2F8NOMgG3giuTqtqDF016z3onG6q4yUfiSgIsQ"},"/hamyct/c9-python-getting-started/branches/fetch_and_merge/master":{"post":"vOo5qwRg9u3qy4yNjBVUHTM7kXY2kxazQGx0Q17iGutUyj4F1b-X73khwbh4mNoZwmhBm4iz0_Xu1h46-eHXKw"},"/hamyct/c9-python-getting-started/branches/fetch_and_merge/master?discard_changes=true":{"post":"NWEyAbIU8hOGbVDUOYAxzM27uVFBcXg-ygwqsb4sBEzdQTWvY8uTERWHHeHNDb_IPOhpvP9RvXhktkDIGS_JjA"}}},"title":"c9-python-getting-started/13 - Functions at master · hamyct/c9-python-getting-started","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1ae9fa256942.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}
0