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.
・ People who started studying python ・ People who feel that they lack experience in python ・ Love
・ This article is based on the python3 system. Since he is using 3.7, he has little knowledge about 3.8 at this time.
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
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.
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.
This is easy to understand.
'hello_worlds' == 'hello_worlds' # True
'goobye_world' == 'hello_worlds' # False
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