Python Interactive Guide - Step 1: Basic Syntax and Data Types (1) - Comments, Screen Output
- This course, Python Interactive Guide, is designed to help you learn the basics of Python programming through hands-on, interactive examples.
- The “Style Guide” sections introduce clean coding practices, mainly based on PEP8.
- You can run and experiment with every code example.
Feel free to try things out - reloading the page will reset everything.
Step 1: Basic Syntax and Data Types
1.1. Comments
- Lines beginning with a hash symbol (
#
) are interpreted as comments. - Comment lines do not affect the execution of the program but are used to explain how the program works.
- Everything from the hash symbol to the end of the line is considered a comment.
- After the
#
, add 1 space before beginning your comment text. - When adding a comment after a code statement, include at least 2 spaces between the code and the comment.
1.2. Screen Output
- To display data on the screen, use the
print
function. - Strings are enclosed in double quotes (
"
) or single quotes ('
).
- By default, the print function inserts a newline at the end.
- If you don’t want to include a newline, specify an empty string (
''
) for theend
parameter.
Output the string “Hello, World!” in a single line by using two print statements - one for “Hello,” and one for " World!".
I Created a Python Code Playground
I created a Python Code Playground that allows you to execute Python code in a web browser.
Technically, it uses Pyodide and Monaco Editor, and was created with the help of GitHub Copilot.
(Recent LLMs are very convenient as they can generate working code just by describing what you want to do.)
Motivation
I created this tool because I thought it would be convenient to have an easy-to-use execution environment when writing Python-related articles on this blog.
Stream ChatGPT Responses Using LangChain
In this post, we’ll dive into how to use LangChain to stream real-time responses from ChatGPT.
1. Installation
First, install langchain
along with its OpenAI extension, langchain-openai
.
Text-to-SQL with LangChain (2) - Agent
Continuing from last post, we’ll explore the implementation of ‘Text-to-SQL’, where you can query database information in natural language and get answers, based on LangChain’s Quickstart documentation.
In this post, we’ll look into the operation of an agent created using the create_sql_agent
function.
-
In this article, we’re using LangChain version
0.2.0
.Text-to-SQL with LangChain (1) - Chain
In this post, we’ll dive into how to set up Text-to-SQL with LangChain, guided by the Q&A over SQL+CSV Quickstart.
-
We’ll be using LangChain version
0.2.0
.
-