First Python 3rd Edition

I'm tired of Java at work and on holidays, so I'll flirt with Python. The English version seems to be up to the 5th edition.

Chapter 1 Q & A about Python

  1. What are the six benefits of using Python? --Software quality, productivity, portability, rich libraries, easy component integration, and fun programming. In particular, software quality and productivity are the reasons why Python is the programmer of choice.
  2. Name four well-known companies and organizations that use Python. --Google, ILM (Industrial Light & Magic), Jet Propulsion Laboratory, ESRI, etc. It's safe to say that almost every company involved in software development now uses Python in some way. Some use it to develop products for sale to customers, while others use it to create small scripts for software testing, system management, and more.
  3. What are the drawbacks of Python? --The downside of Python is performance. The performance is inevitably lower than that of compiler languages such as C and C ++. However, its performance is practical. For almost any purpose, it's not too late to use. In most cases, Python code runs at almost the same speed as code written in C. Tasks are often passed to compiled C code inside the Python interpreter. For programs where speed is very important, you can combine Python scripts with extensions written in a compiler language such as C. A numerical calculation program is an example.
  4. What can you do with Python? --With Python, you should be able to do almost anything you can do with your computer. In addition to web site construction and game development, it can also be applied to robot development and spacecraft control.
  5. What is import this a command for? --Import this is one of Python's hidden features, and you can run it to learn more about Python's basic ideas. You should be familiar with how to execute this command in the next chapter.
  6. Why do you often see the word “spam” in the code examples in this book? —— That's because the name Python comes from the British comedy unit Monty Python. The word “spam” appears in Monty Python's “spam sketch” control. "Old couples try to place an order in a popular dining room, but all menus include spam. Customers are only viking and even singing songs that praise spam for no reason ..... The content is "." Spam is often used as a variable name in Python scripts.

Chapter 2 Executing a Python program

  1. What is a Python interpreter? --A Python interpreter is a program for executing Python programs.
  2. What is the source code? --Source code is a set of statements written in text format. The file containing the source code is a text file, usually with a “.py” extension.
  3. What is bytecode? --Bytecode is low-level code that Python can compile source code for. Bytecode files are automatically given the ".pyc" extension.
  4. What is PVM? --PVM is an abbreviation for Python Virtual Machine. Python's "runtime engine", which is responsible for reading and executing bytecode.
  5. What are the variations of the Python execution system? --Psyco, Shedskin, Frozen Binaries, etc.
  6. What is the difference between CPython, Jython and IronPython? --CPython is standard Python. Jython and IronPython are compatible with Java environment and .NET environment, respectively. A Python implementation. Each has a different compiler.

Chapter 3 How to start the program

  1. How to start an interactive session? --On Windows, to launch an interactive session, select the Python entry from All Programs on the Start menu, then select the item called Python (command line). Also, on other platforms, you can do the same by typing the command python in the system console window (on Windows, use the command prompt window). Another method is to start IDLE. This is because the main Python Shell window becomes an interactive session. If the Python installation directory is not specified in the shell environment variable PATH setting, for example, instead of just typing python, go to the Python installation directory or the full path to the Python executable file. You may have to enter (for example, C: \ Python25 \ python for Windows).
  2. Where do I enter the system command line when launching a module file? --The system console for each platform is where you enter the system command line. In the case of Windows, it is a command prompt window. On UNIX, Linux, Mac OS X, etc., it is an xterm or terminal window.
  3. On Windows, there are two problems with how to run the program by clicking the file icon. what is that? ――First of all, the execution result is displayed for a moment and then disappears immediately. This means that virtually no one can see the result of the run (you can solve this problem with a built-in function called raw_input). Another problem is that Python error messages disappear in a blink of an eye, so no one can see them (this problem occurs if you develop using the system command line or an IDE such as IDLE). not).
  4. When do I have to reload a module? --Python imports (loads) modules only once per process by default. If you make changes to the source code and want the changes to take effect without stopping and restarting Python, you'll need to reload. The target module must be imported at least once in order to reload. This issue usually does not occur when you run your code using an IDE such as the system command line, icon clicks, or IDLE. This is because the module will run with the latest version of the source code each time.
  5. What are the steps to run a program in IDLE? --From the [Run] menu of the window with the code to be executed displayed in the text edit window Select the item called Run Module. Then, the source code displayed in the window is executed as a top-level script file, and the execution result is displayed in the main window (Python Shell window).
  6. There are two main issues with using IDLE. what is that? --IDLE may hang depending on the type of program. In particular, multithreading Lucis threading is a fairly advanced technique and is at high risk for GUI programs (not covered in this document). It's also worth noting that IDLE has useful features designed to make programming easier for beginners. This is because some of these features have no application other than the IDLE GUI. For example, running a module in an IDLE environment is the same as importing a module, and variables in that code are automatically available to IDLE's interactive sessions thereafter. In other environments, this is not the case and can be confusing.
  7. What is a namespace? How does it relate to module files? --A namespace is a set of variables (names). Python modules also have the aspect of a collection of various "variables (names)" that can be used in Python programs, and all modules are automatically namespaced. It is a set of variables (names) that are assigned at the top level. Dividing the program into modules can also help prevent variable collisions. Each module is a self-contained nominal space, so as long as it is defined in a separate module, there will be no conflicts, even if the variables have the same name.

Recommended Posts

First Python 3rd Edition
First time python
First Python 3 ~ First comparison ~
First time python
First Python ~ Coding 2 ~
First python [O'REILLY]
A * algorithm (Python edition)
PyQ ~ Python First Steps ~
First Python image processing
[Python] Python / Scikit-learn's first SVM
First Python miscellaneous notes
[Python] Chapter 01-01 About Python (First Python)
Python 2 series and 3 series (Anaconda edition)
PyTorch C ++ VS Python (2019 Edition)
CI environment construction ~ Python edition ~
First neuron simulation with NEURON + Python
Python installation (Mac edition) (old)
First simple regression analysis in Python
Python
First Python 3 ~ The beginning of repetition ~
Tower of Hanoi-Recursive / Non-recursive (Python edition)
Web scraping with Python First step
First Python 3 ~ Extra: Numerical Random Fantasy ~
"Effective Python 2nd Edition" Chapter 3 <Functions>
[GUI with Python] PyQt5-The first step-
Prepare your first Python development environment
[Python3] Development environment construction << Windows edition >>
Python (from first time to execution)
Time series plot started ~ python edition ~
C / C ++ programmer challenges Python (first step)
See python for the first time
[2021 version] Python installation Windows 10 (64bit) edition
Python dummy data generation (address edition)
The first step in Python Matplotlib
Introduction to Python Django (2) Mac Edition
Generate a first class collection in Python
CGI server (1) python edition in one line
Displaying candlestick charts in Python (matplotlib edition)
Continuously play the first Python Sukusta MV
Raspberry Pi Security Infrared Camera (Python Edition)
"Effective Python 2nd Edition" Chapter 1 <Pythonic Thinking>
Predictive statistics (practice edition multiple regression) python
CPLEX Python API self-made manual LP edition
Python basic operation 3rd: Object-oriented and class
Ant book with python (chapter3 intermediate edition ~)
[Python] First data analysis / machine learning (Kaggle)
MongoDB for the first time in Python
Get Started with TopCoder in Python (2020 Edition)
Technology that supports Python Descriptor edition #pyconjp
Run Python code on A2019 Community Edition
I tried scraping Yahoo weather (Python edition)
"First Elasticsearch" starting with a python client
Displaying candlestick charts in Python (Plotly edition)
Algorithm learned with Python 3rd: Radix conversion
Python environment preparation (venv first time use)
Python standard library: First half (Python learning memo ⑧)
Algorithm Introduction Implement 4 types of sorting in Python from pseudo code of 3rd edition