Notes/ML/microdegreemlpythonrecap1-201106-130921.ipynb

1 line
2.4 KiB
Plaintext
Raw Permalink Normal View History

2022-04-23 14:04:50 +00:00
{"cells":[{"metadata":{},"cell_type":"markdown","source":"## Python fundamentals:\n1. Condition checking\n2. Arrays/Lists\n3. Looping\n4. File I/O"},{"metadata":{},"cell_type":"markdown","source":"### Condition checking"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"a = 55\nb = 55\nif a>b:\n print(str(a) + \" > \" + str(b))\nelif a == b:\n print(str(a) + \" == \" + str(b))\nelse:\n print(str(a) + \" < \" + str(b))","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Array"},{"metadata":{"trusted":true},"cell_type":"code","source":"arr = [2, 4, 6, 8]\narr.append(11)\nfor el in arr:\n print(el)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Looping"},{"metadata":{"trusted":true},"cell_type":"code","source":"idx = 0\nwhile(idx < len(arr)):\n print(arr[idx])\n idx = idx + 1","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### File I/O"},{"metadata":{"trusted":true,"collapsed":true},"cell_type":"code","source":"fd = open(\"/kaggle/input/tips-data/tips.csv\", 'r')\nprint(fd.read())\nfd.close()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fd_o = open(\"/kaggle/working/sample.csv\", \"w+\")\nfd_o.write(\"Col1,Col2\\n2,4\")\nfd_o.close()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fd1 = open(\"/kaggle/working/sample.csv\", 'r')\nprint(fd1.read())\nfd1.close()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Installing 3rd party libraries which are not yet installed."},{"metadata":{"trusted":true},"cell_type":"code","source":"#Step-1\nimport pandas as PyPDF2\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#Step-2\n!pip install PyPDF2","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#Step-3:\nimport pandas as PyPDF2","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.7.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":4}