<jupyter_start><jupyter_text>Hello WorldIn this section, you will learn:- Saying "Hello World!" in Python.- Basic programming concepts of `function`, `literal`, `string`, `docstring`, `comment`, and `whitespace`.- That there is a style in programming and the style matters. 1 Your First ProgramWe follow the tradition from C programming language to say "Hello World" as the first program in learning a programming language. In Python, it is pretty simple. If you know how to say it in other programming languages like C or Java, you will appreciate its simplicity and elegance. Nonetheless, for a beginner, this single line of code has a lot of constructs/concepts in it.<jupyter_code>print('Hello World!')<jupyter_output><empty_output><jupyter_text>Part 1: `print``print` is the name of a Python's built-in function that displays (prints) something to your computer console:- A function is a piece of program that performs a specific task. Here, it displays a message to your computer sonsole. A `console` is your terminal (Mac OS or Linux) or commmand line (Windows) screen.- The `print` function is provided by the Python interpreter, thus it is a `built-in` function. Your program will define many functions to perform different tasks for your problem domain. These functions are application functions, not built-in functions.  - A function, as defined in math, takes some values as its input and produce an output. Those input values are called `arguments` of a function. Part 2: `()`The `()` is a pair of parentheses that separates a function name from its arguments. The arguments (input) of the function are put inside a pair of parenthese after a function name. Part 3: `'Hello World!'`The `'Hello World!'` is the input for the function. It is the single argument in the above function call.- It is a `string literal`.- The `string` is the data type of `'Hello World!'`. A data type defines a set of data that share some common properties. For example, a `string` has a sequence of characters quoted in a pair of single quotation marks.- A `literal` is a programming notation/representation for a fix value in source code. Here, you want to say the sequnence of characters of `Hello World!` that is a string data type in Python. Python requires that string literals be quoted in a pair of single quotation marks.- You will see that different data types have different notations for their corresponding fixed values. All together: `print('Hello World!')`When you write a function name, followed by a parenthese and its arguments inside the parenthese, you `call` the function to perform a specific task for the specific arguments.Because calling a function is an essential thing in programming, it has different names that have the same meaning:- `call` a function: a function `call`- `execute` a function: a function `execution`- `invoke` a function: a funciton `invocation`- `apply` a function to some arguments: a function `application`It is also common to say `call upon a function`, `execute/invok/apply/run a function`, or `start a function`.Together, `print('Hello World!')` is a function call or a function execution. It is executed by Python to display the "Hello World!" to the console.  2 Notations for String LiteralsA string is a sequence of characters. A **String Literal** is a specific string in source code. Becuase string literals are useful in many places in source code, Python has three notations for string literals. You can use a pair of single quotations, a pair of double quotations, or a pair of triple quotations.- single quotation marks: `'Hello Wordl!'`- double quotation marks: `"Hello World!"`- triple quotation marks: `"""Hello World!"""`The following three lines of code perform the same taks: write the sequnce of characters of `Hello World!` to the console:<jupyter_code>print('Hello World!')
print("Hello World!")
print("""Hello World!""")<jupyter_output><empty_output><jupyter_text>Of course, Python define three notations purposely: they are used in different places. You will find out.  3 DocstringWhen you open a source code file, what do you want to see first?A thousand lines of Python source code? Probably not.Yes, you want to see a description/summary of this code file. You want to see the document first to get a better understanding of the purposes and functions of the code before diving into the details. An experienced programmer knows two best practices in programming:- You write code for people to read, not for computers. In average, for a line of code, you or your colleagues will read/change it more than 10 times. It is better to document the code.- Code and documentation must reside in the same place. Keeping the code and document consistent and easy to find is an essential task of programming.Python uses a string enclosd by a pair of tripple quotation marks for inline code documentation -- such a string is called a **docstring**. You should write doctsring at the top of a code file (.py file) or when you define a function. Python interpreter ingores docstrings.<jupyter_code>"""The following code demos the different notation of string literals"""

print('He said: "Hello Wordl!"')
print("She said: 'Hello World!'")
print("""He said: "Hello Wordl!" and She said: 'Hello World!'""")<jupyter_output><empty_output><jupyter_text>In the above code, the docstring documents the purpose of the following code. For a large project that has many source code files, the inline documents have tremendous value for code maintenance. As shown in the above code, you can use single quotation marks inside a pair of double quotation marks or vise versa. You can use both single quotation marks and dobule quotation marks inside a pair of triple quotation marks. Triple quotation marks are used primarily in two cases:- To write doctstring.- To write a string that has many single/double quotation marks.If you want represent the two characters of `Hi` in your code, which notation do you use?<jupyter_code>"""Which notation do you use? """

print('Hi')
print("Hi")
print("""Hi""")<jupyter_output><empty_output><jupyter_text>4 Code CommentsIt is a best practice to write comments about code that is not obvious. Good comments are for human being and they are part of the source code that help code maitenance in the long run. Python intepreter ignores comments. You begin a comment with the `` character. It can be in a seperate line or at the end of a line of code. The following shows a docstring, a comment line and an end-line comment.<jupyter_code>"""Demo a comment line and an end-line comment"""

# Reserve triple quotes for docstring, not for simple string literal
print("""Hi""") 

# Which of the following? 
print('Hi') # a pair of single quotation marks
print("Hi") # a pair of double quotation marks<jupyter_output><empty_output><jupyter_text>5 WhitespacesThere are blank lines and space characters in the above code. Together they are called whitespaces. White spaces are primarily for two puporses:- To makr a boundary between different programming constructs. For example, two lines of code are separated by a new line character.- To structure the code more readable.A whitespace character maybe invisible (for example, a new line character) but occupies an area in a file. You should use blank lines and spaces to have a better code layout.- Use a blank line to seperate different sections of code- Use a space to separate different constructs. For example, separate code from its end-line comments.  6 The Zen of PythonThe simplicity and elgance of Python are not by accident, they are the result of a long endeavor directed by principles. According to [Zen of Python in Wikipedia](https://en.wikipedia.org/wiki/Zen_of_Python)> The Zen of Python is a collection of 19 "guiding principles" for writing computer programs that influence the design of the Python programming languageYou can open "Easter Egg" in Python with code:<jupyter_code>import this<jupyter_output>The Zen of Python, by <NAME>

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!<jupyter_text>These are the coding principles you should follow in your programs too. If you like, you may want to [sing along](https://youtu.be/i6G6dmVJy74?t=33) when you write Python progrom.   7 Style GuideThe foregoing principle are abstract. Python has an official document describing concrete coding conventions. It is called [PEP 8 -- Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/). PEP stands for "Python Enhancemment Proposal". PEPs are suggested standard from Python community. PEP 8 has rules such as:- Limit all lines to a maximum of 79 characters.- Indentation: Use 4 spaces per indentation level.- Variable and constant naming conventions.The good news is that VS code Python extension has a tool that check the code style for you. The tool is often called a `lint` or `linter`. When you install the `Python` extension in VS Code, the Python lint is included and enabled. It can format your code automatically according to defined styles that you can customize.However, not every detail of programming can be covered by rules.  For example:<jupyter_code># Which style to use? 
print('Hi') # a pair of single quotation marks
print("Hi") # a pair of double quotation marks<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup