Python to remember only with hello, worlds

Introduction

I decided to write an article to improve my technical skills and reconfirm my understanding in an environment where it is difficult to output due to my workplace. However, python articles are commonplace, so I think we should understand python only by hello, worlds, which is a path that everyone goes through as a means to find peculiarities. It's ridiculous to read.

Target audience of this article

・ People who started studying python ・ People who feel that they lack experience in python ・ Love

important point

・ This article is based on the python3 system. Since he is using 3.7, he has little knowledge about 3.8 at this time.

Main subject

1. String output

It is a character string output that cannot be avoided when talking about hello and worlds. Here, we will do hello, worlds with various approaches.

print('hello,worlds)
print('hello,' + 'worlds')
print({}.format('hello,worlds'))
hoge = 'hello,worlds'
print('%s' % hoge)

All of these are hello, worlds. Depending on the motivation of the author, this glue will continue forever

2. Conditional branch

As long as you can do conditional branching, you are already a full-fledged programmer. Most of the processing can be done by remembering a list of 0s and 1s or if.

if statement

hello_worlds = 'hello_worlds'
if hello_worlds == 'hello_worlds':
    print(hello_worlds)
else:
    print('goodbye worlds')

The if statement is now perfect. I think it's enough, but just in case, I will explain it in a little more detail. Operators used in if statements include operators that use characters such as not and is and operators that use symbols such as == and <. You can understand the meaning of the operator by looking at the letters and symbols, but if you stumble, it's the difference between is and ==. Note that the two are similar, but the ones to be compared are different.

== determines if the values are the same

This is easy to understand.

'hello_worlds' == 'hello_worlds' # True
'goobye_world' == 'hello_worlds' # False

is determines if the objects are the same

I also understand the feeling of wanting to say what an object is.

a = 'hello worlds'
b = a
c = 'hello worlds'
a is b # True
a is c # False

Programming is the unreasonableness that is said to be different even in the same hello worlds. To briefly explain an object, you can think of it as a product displayed on a shelf. It looks the same, but the contents are not always the same. Although a and c look the same, they are false because they are not the same. If you want to know more, it is recommended to check the identity and id functions.

Recommended Posts

Python to remember only with hello, worlds
Say hello to the world with Python with IntelliJ
Connect to BigQuery with Python
Connect to Wikipedia with Python
Post to slack with Python 3
Switch python to 2.7 with alternatives
Write to csv with Python
Python starting with Hello world!
[Python] Localize sound source only to human voice with ReSpeaker
Python: How to use async with
Link to get started with python
[Python] Write to csv file with Python
Create folders from '01' to '12' with python
Nice to meet you with python
Try to operate Facebook with Python
Output to csv file with Python
Convert list to DataFrame with python
MP3 to WAV conversion with Python
To do tail recursion with Python2
How to get started with Python
[Note] Hello world output with python
What to do with PYTHON release?
Unable to install Python with pyenv
How to use FTP with Python
How to calculate date with python
Useful to remember! 10 Python Standard Libraries
Easily post to twitter with Python 3
I want to debug with Python
How to change Django's SQLite3 uploaded to python anywhere with GUI only
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
Try to reproduce color film with Python
Try logging in to qiita with Python
Convert memo at once with Python 2to3
Memo to ask for KPI with python
Output color characters to pretty with python
Introduction to Python Image Inflating Image inflating with ImageDataGenerator
Output Python log to console with GAE
Convert Excel data to JSON with python
Convert Hiragana to Romaji with Python (Beta)
Fractal to make and play with Python
I wanted to solve ABC160 with Python
Connect to MySQL with Python within Docker
How to work with BigQuery in Python
[Introduction to Python] Let's use foreach with Python
Single pixel camera to experience with Python
[Python] Introduction to CNN with Pytorch MNIST
Convert FX 1-minute data to 5-minute data with Python
I want to analyze logs with Python
How to do portmanteau test with python
I want to play with aws with python
How to display python Japanese with lolipop
Trying to handle SQLite3 with Python [Note]
[Part1] Scraping with Python → Organize to csv!
Connect to s3 with AWS Lambda Python
Add Gaussian noise to images with python2.7
How to enter Japanese with Python curses
Convert HEIC files to PNG files with Python
Convert Chinese numerals to Arabic numerals with Python
Connect to pepper with PEPPER Mac's python interpreter
To work with timestamp stations in Python
[Python] How to deal with module errors