HCI 2. Getting Started with Python
Uploaded by adrianwang2003 · 28 May 2024
Preview
Hwa Chong Institution H2 Computing 1 2 Getting Started with Python Learning Outcome Python is a high -level, general -purpose programming language for solving problems on modern computer systems. The official online resources can be found at www.python.org, and its popularity has generated many websites and YouTube channels for self-learning. Three tools that we can use to write a program and test it. Python Shell After downloading Python, launch the IDLE to open a Python shell . Shell is useful for experimenting with short expressions or statements to learn new features of the language. Python File When we need to construct complex programs and test them, we can create and save files in program libraries to reuse or share with others. Open a New File in Shell and save the program files use .py extention. Coding Standards Use indentation and white space Use naming conventions (e.g. meaningful identifier names) Write comments (name of programmer, date written, program description and version book-keeping/control) Programming Elements and Constructs Understand the different data types: integer, real, char, string and Boolean Use common library functions for input/output, strings and mathematical operations Character Encoding Give examples of where and how Unicode is used Use ASCII code in programs
Hwa Chong Institution H2 Computing 2 We can then run Python program files within IDLE using menu option F5 for Windows. Here is a sample program for your first experiment. Then we run the file in Python Shell. Running Jupyter Notebook on the school laptop Look for Computing Software shortcut (shown below) on the desktop. Double click on the shortcut to open Windows Explorer. In Windows Explorer, a list of shortcuts is listed. Double click on the Jupyter Notebook shortcut to launch the application.
Hwa Chong Institution H2 Computing 3 A console windows will be launch prior to the browser. Do not close the console windows. Take note that the console windows should remain open for Jupyter Notebook to work. Jupyter notebook home page will be shown in the browser. By default, the home page will display the files on the desktop. Jupyter Notebook File These files are saved in .ipynb extension. Click ‘New’ to create a new notebook in Python 3. Type the codes and run it by clicking the ‘Run’ button, or pressing ‘Ctrl’ + ‘Enter’. Here is the output. The convenience of using Jupyter Notebook is that we can write multiple programs in one file, by clicking the ‘+’ button.
Hwa Chong Institution H2 Computing 4 2.1 Comments and Docstrings Programs should be easily understood and modifiable by any users, so we need to insert comments to explain how we solve the problem and sometimes the meaning of the variable names we defined. Docstring for a paragraph of comments: For short explana
Content continues in the PDF.
Related notes
- VJC Chapter 21 SQLite with PythonNotes/Practices · 2025
- VJC Chapter 23 Web Applications PrinciplesNotes/Practices · 2025
- VJC Chapter 10 RecursionNotes/Practices · 2025
- VJC Chapter 20 SQLNotes/Practices · 2025
- VJC Chapter 16 Hash TableNotes/Practices · 2025
- VJC Chapter 22 NoSQLNotes/Practices · 2025

