Before writing Python code

What is Python in the first place?

Python is a programming language developed by the Dutchman Guido van Rossum in 1991. Generally, as the scale of a program grows, the code becomes harder to read, but Python is a language that is easy for beginners to handle with the aim of eliminating such inconvenience. In addition, famous companies such as Google have also introduced it, and it can be said that it is a language that has been attracting attention in recent years. Python is commonly referred to as an object-oriented programming language. There are various definitions of object-oriented programming, but I interpret it as a method aimed at actively reusing code and shortening the total time required for system development.

What can you do with Python

・ Machine learning ・ Data analysis

There are many things you can do with Python, but here we will focus on machine learning and data analysis.

Machine learning

Machine learning is the clarification of these characteristics from a large amount of data and the prediction of the outcome of an event. Machine learning learning methods are classified into three types: supervised learning, unsupervised learning, and reinforcement learning. Supervised learning is machine learning in which the desired result is prepared in advance and how close the computer can predict the result. On the other hand, a learning method in which correct data is not prepared is called unsupervised learning. Unsupervised learning can be used to examine the correlation between two events. Reinforcement learning is a learning method that aims to maximize the rewards that can be obtained in situations where there are infinite behavior patterns. For example, a method is adopted in which rules such as shogi and go are input to a computer in advance, and when a choice that leads to a win is made, a reward is given accordingly and learning is performed.

Data analysis

Data analysis is the process of collecting and organizing data for some purpose to find valuable meaning. As a basic data analysis flow

    1. Issue setting
  1. Data collection
    1. Data preprocessing
  2. Data visualization Will be.
1. 1. Issue setting

As mentioned earlier, data analysis aims to find valuable meaning, so it is necessary to define what kind of results should be obtained for success.

2. Data collection

There are roughly three ways to collect data. The easiest way is to use a dataset published by a public institution, which saves you time because someone else has already collected the data. The second method is to extract data from the in-house database. Knowledge of SQL is required to do this. The last is how to collect data by Web API (Application Programming Interface) and Web scraping. Web API is an interface between a server and a client that is called over a network using the HTTP protocol. Web scraping is a technology that acquires and downloads necessary data from a website, and the program that does it is called a scraper.

3. 3. Data preprocessing

Even if the data is successfully collected, the data that lacks the answer to an item can adversely affect the overall result, so the data must be processed. In addition, it is necessary to convert character strings (categorical data) into continuous data so that statistical analysis is possible.

4. Data visualization

Visualization of data in Python can be achieved by using the following modules. When it comes to writing long code in Python, you'll need to split the file to reduce unexpected errors. The file divided at this time is called a module. ・ Matplotlib ・ Pandas ・ Seaborn etc.

Python's strengths

・ Since the code is simple, it is suitable for beginners ・ Abundant libraries and frameworks

Suitable for beginners because the code is simple

One of the features of Python is that the code is simple. Sure, I've been studying programming as a beginner, but I feel that the code is simpler and the functions can be implemented more easily than Javascript, for example. Javascript uses unique characters when defining constants and variables, but Python does not need to use such characters, it is defined by simply assigning a value to a variable. I will continue to cite Javascript to emphasize the simplicity of Python code.

script.js


const score = 60;
if(score >= 80){
  console.log('good');
}else{
  console.log('so so....');
}

script.py


score = 60
if score >= 80:
    print('good')
else:
    print('so so...')

As you can see, in python, indentation must be performed when using conditional branching, but it is simpler than other languages.

Rich in frameworks

A framework is a pre-collection of frequently used programs. One of the strengths of Python is that using a framework allows you to develop quickly because you don't have to develop from scratch, which improves productivity. For example, Python frameworks include useful frameworks such as Django, Flask, and Bottle.

reference

[Which one should I learn? Compare Python and JavaScript] (https://se.miyabikno-jobs.com/comparison-python-js/) [[Preserved version] I tried to summarize what you can do with Python, which is a hot topic now, so that even those who have no programming experience can understand it] (https://dividable.net/python/how-python-is-useful/) [What is Python? Easy-to-understand explanations for beginners from language features to learning methods] (https://www.sejuku.net/blog/7720) [[Python] Concept and writing of object-oriented programming] (https://www.headboost.jp/python-objective-paradigm/#4)

Recommended Posts

Before writing Python code
python character code
Basic Python writing
[Python] Algorithm-aware code
Python code acceleration approach
Rewrite Python2 code to Python3 (2to3)
infomap python draw code
About Python3 character code
Python Requests status code
OpenCV basic code (python)
A memorandum when writing experimental code ~ Logging in python
Tips to look at before you start writing Python
Python with VS Code (Windows 10)
Python code memo for yourself
[Python] Frequently used library code
Debug Python with VS Code
2.x, 3.x character code of python
Stop Omxplayer from Python code
Python frequently used code snippets
Generate QR code in Python
[Python] Sample code for Python grammar
Character code learned in Python
Convert python 3.x code to python 2.x
Document Python code with Doxygen
Python code for writing CSV data to DSX object storage
Python hand play (argparse minimum code)
That Python code has no classes ...
Python
[Python] Generate QR code in memory
Minimum grammar notes for writing Python
Automatically format Python code in Vim
[Code] Module and Python version output
Python CSV file reading and writing
Write selenium test code in python
Reading and writing NetCDF with Python
Execute Python code from C # GUI
Python parallel / parallel processing sample code summary
A note for writing Python-like code
Check python code styles using pep8
Reading and writing CSV with Python
Easy Python to learn while writing
Reading and writing text in Python
[Python] Read the Flask source code
Code tests around time in Python
[VS Code] ~ Tips when using python ~
Install python with mac vs code
When writing a program in Python
What Emacs users should know when writing python code in Sublime Text
Installation of Visual studio code and installation of python
Fourier series verification code written in Python
Execute Python code on C ++ (using Boost.Python)
python> link> strftime () and strptime () behavior / code
Write test-driven FizzBuzz code using Python doctest.
Getting Python source code metrics using radon
[Python3] Rewrite the code object of the function
Template for writing batch scripts in python
Enumerate duplicate combinations (C ++) → Add Python code
Reading and writing JSON files with Python
python> coding guide> PEP 0008 --Style Guide for Python Code
A tool for easily entering Python code
Run Python code on A2019 Community Edition