Lecture/Python Basic

Introduction to Python

NoxLuna 2025. 5. 2. 10:34

0. Learning Objectives

• Understand what Python is.
• Learn the characteristics of Python and comprehend its features.
• Explore what can be done using Python.


1. Introduction to Python


1) What is Python?

Python is a dynamically typed language that can be used by both beginners and experts. It is an interpreted language, meaning it can execute source code directly and interpret it during execution. This type of language is also referred to as a scripting language. In contrast, compiled languages convert source code into executable binary files before running.

Python supports multiple programming paradigms, allowing flexibility in how programs are structured.

The name “Python” refers to a large snake from Greek mythology that lived in a cave on Mount Parnassus. This is why Python’s logo features two snakes mirroring each other.

python logo


2) Features of Python

Dynamically Typed Language

Python uses dynamically typed variables. This means variable types are determined at runtime. There is no need to declare a type when creating a variable, and the type can change depending on the value assigned. A single function can work with various data types.

This is a common feature among scripting languages. You can think of a dynamically typed variable as one whose type is determined when a value is assigned, or as a reference to a storage location holding the value. Although the two concepts differ technically, they function similarly in practice.

Advanced Built-in Objects

A major strength of Python is its powerful built-in data structures. It offers high-level data types such as:
• Lists
• Tuples
• Sets
• Dictionaries (hash maps)
• Big Integers

These are available without needing to import external libraries.

Open Programming Environment

Python modules and classes are all open. This can be a disadvantage since it lacks access control features like hiding or write protection, which may lead to inconsistent code. However, this is usually not an issue as Python is generally not used for low-level system programming. Python also supports reflection, allowing access to variables and functions by name. While this lowers security, it significantly enhances flexibility and integration with code from other languages.

Glue Language

Python is considered a glue language because it can integrate components written in other languages or be used within other applications. Libraries like NumPy and Pandas owe their existence to this feature. Python’s success in data science is largely due to this integration capability.


3) History of Python

Guido van Rossum

Python development began in 1989 by Guido van Rossum at CWI.
Python 2:
• Released on October 16, 2000
• Included a garbage collector and Unicode support
• Gained strong community support
• Official support ended on January 1, 2020
Python 3:
• Released on December 3, 2008
• Not backward-compatible with Python 2
• Many new features from 2.6 and 2.7 were integrated
• Reorganized standard library
• Improved Unicode support (e.g., u"string" → "string")
• print became a function (print() instead of a statement)



4) Core Philosophy of Python

“Beautiful is better than ugly.”

Python enforces indentation. Unlike other languages that recommend it, Python requires it for correct execution. Python syntax is now widely used even in pseudocode due to its clarity.

“Explicit is better than implicit.”

Explicit code is immediately understandable. In contrast, implicit code requires additional effort to understand. Python avoids features like ambiguous increment/decrement operators and complex for-loops, promoting clarity.

“Simple is better than complex.”

Python prioritizes simplicity. Features like list comprehensions and tuple unpacking allow complex tasks to be written simply.

“Complex is better than complicated.”

Even if complexity is unavoidable, it should remain understandable and not convoluted.

“Readability counts.”

This encapsulates all previous philosophies. Readable code reduces errors, eases maintenance, and is crucial for collaborative work. Readability benefits all programming languages, not just Python.



5) What Can You Do with Python?

While Python is used in many domains, it has limitations in performance-critical applications due to being an interpreted language. It is slower than native compiled languages like C/C++ or intermediate languages like Java/C#.

What Python Can Do:
• Data Science (Big Data Analysis, Regression, Visualization)
• Artificial Intelligence and Deep Learning
• Web Server Programming
• Automation Tools
• Data Crawling

What Python Cannot Do Well:
• High-performance computing (e.g., games, heavy desktop applications)
• System-level programming (e.g., OS development)



Representative Python Use Cases

Data Science

• Big Data Analysis using NumPy, Pandas
• Frequently used alongside R
• Handles statistical analysis, regression, numerical computation
• Data Visualization with tools like Matplotlib and Seaborn

Artificial Intelligence & Deep Learning
• TensorFlow and Keras: Core libraries for deep learning
• PyTorch: Widely used in AI research
• Strong library support for data processing and visualization

TensorFlow vs. Keras


Web Server Programming
• Django: A full-featured Python web framework
• Enables Python-based web servers
• Commonly used alongside JavaScript and Java

Automation
• Factory Automation: Cross-platform scripts for industrial automation
• Work Automation: Batch processing, more versatile than shell scripts
• Simulation Support: Pre/post-processing tasks for simulation systems

Data Crawling
• Seamless database integration
• Batch processing with databases
• Web Crawling: Using libraries like BeautifulSoup
• Support for various NLP libraries, including Korean-language processing


반응형