Note: This article starts with a python environment in place
Nice to meet you, in this article I would like to write the first thing I learned in python.
I think this is the first thing a beginner will learn when learning python. Anyway, write the following code in the interactive code and press enter.
hello.py
print("hello world")
Try running it. Then it should come out like this.
hello.py
hello world
It just used the print function to print the characters in the double quotes as a string. A character string is a series of characters. Even one character can be read as a character string. However, the character string cannot be calculated because it is different from the number due to characters. The command is simply a command to display hello world.
Mr. a wants to calculate 1 + 1, but I don't know. I decided to calculate using python. But I'm in trouble because I can't get an answer. The code of Mr. a is as follows.
asan.py
print("1 + 1")
Execution result
asan.py
1 + 1
As you may have noticed, this will display it as a string. So to go back from a string to a number, write:
asannotameni.py
print(1 + 1)
Execution result
asannotameni.py
2
Now you have a 1 + 1 answer. In this way, python has to use strings and numbers properly.
This time, I wrote a little about the print function. Next time I will write in more detail. Please read it again next time.
Mr. a submitted a 1 + 1 question to the school, but he made a mistake and submitted it as 1 + 1. And he said he tried again, laughing at everyone alone.
Recommended Posts