This introduction covers Python basics for new programmers: what the language is used for, how to set up a simple program, and how to work with variables, data types, and operators. It summarizes the subjects listed in the source article; it is not a complete programming course.
What is Python?
Python is a high-level programming language known for readable syntax and a broad range of uses. It is commonly used in web development, data science, automation, games, artificial intelligence, and Internet of Things projects. Python programs are typically run using a Python interpreter; implementation details can vary.
Install and run a first program
Install Python using the instructions for your operating system. One editor option mentioned is Visual Studio Code. You can create a .py file, use print() to display output, and run the program from an editor or the command line. Verify that the version and interpreter selected by your editor are the ones you intend to use.
Variables and common data types
A variable is a name that refers to a value. Common built-in data types include:
- Numbers: integers such as
5and floating-point values such as3.14. - Strings: sequences of text, usually written inside single or double quotation marks.
- Booleans: the values
TrueandFalse. - Lists: ordered collections that can be changed.
- Tuples: ordered collections that cannot be changed after creation.
- Dictionaries: collections of key–value pairs.
- Sets: collections of distinct values.
Follow Python’s naming rules when choosing variable names. The right data structure depends on how you need to store and use the values.
Three groups of operators
- Arithmetic operators perform calculations such as addition, subtraction, multiplication, and division.
- Logical operators combine or invert conditions, including
and,or, andnot. - Comparison operators compare values, for example for equality or whether one value is greater or less than another.
After learning these basics, practice by writing small programs, running them, and checking the output. Installation steps and editor interfaces can change, so consult current documentation for the Python version and tools you choose.
Contact
For a personal-finance consultation, contact Kanngongkanngoen on LINE.
