{"cells":[{"metadata":{},"cell_type":"markdown","source":"Loop and Functions\nA function is a block of code which only runs when it is called.\nData can be passed into functions.\nA function can also return a value"},{"metadata":{"trusted":true},"cell_type":"code","source":"df = [2,6,3,7,8,3,1,5,4,7,3,8,2,7]\nless_than_5 = 0\ngreater_than_5 = 0\nfor i in df:\n    if i>5:\n        greater_than_5 = greater_than_5 + i\n    else:\n        less_than_5 = less_than_5 + i\nprint(greater_than_5,  less_than_5)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"lst = [2,6,3,7,8,3,1,5,4,7,3,8,2,7]\nless_than_5 = 0\ngreater_than_5 = 0\nfor i in lst:\n    if i>5:\n        greater_than_5 = greater_than_5 + i\n    else:\n        less_than_5 = less_than_5 + i\nprint(greater_than_5,  less_than_5)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def hello_world():\n    return('Hello')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"val = hello_world()\nprint(val)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}