Python introductory tutorial NO.1 Print your Pokemon with python

Python introductory tutorial NO.1 Print your Pokemon with python

Let's start writing our first python code through an interesting example.
The basic python syntax involved in this article is: print output function, assignment, string

print()

print() is a built-in function of python, used to print output, and is one of the most common functions.
Some friends may be a little confused about the word printing. It should be noted that printing here refers to when we run a python program, print() is used to output the running result of the program to the computer screen. We can use the following Two examples to deepen your understanding!

Code one:

a = 8
b = 10
c = a + b
c

Python introductory tutorial NO.1 Print your Pokemon with python
We can see that the local area of ​​pycharm's running results is blank, and no results appear. Next, let's see what it looks like after adding print()?

Code two:

a = 8
b = 10
c = a + b
print(c)

Python introductory tutorial NO.1 Print your Pokemon with python
Through the comparison of the two pieces of code, we can know that if we want to see the computer give us feedback results, we must print what we want to the computer screen through print()!
One thing to note is that the'=' in a = 8 here is not the equal sign in our mathematical symbols, but the assignment sign. The equal sign in python is represented by two consecutive equal signs: == of
this code The word order is: Assign 8 to the letter a, a here is a variable we defined, and its capacity is very small, can only put a value, when you want to put a new value, its original value Will be covered, we understand it through a piece of code.

a = 8
print(a)   #输出结果为:8
a = 3
print(a)   #输出结果为:3

String

String is a commonly used data type in python, it is any text enclosed in ('or ")," or "" itself is just a representation, not a part of the string (the quotation marks here are English quotation marks)
Chinese characters and letters are all character strings. The numbers enclosed in quotation marks are also character strings. The numbers without quotation marks are of digital type and not string type. We will talk about this in the next section.

'我是一个字符串'
print('我是一个字符串')     #输出结果为:我是一个字符串
"我也是一个字符串"
print("我也是一个字符串")     #输出结果为:我也是一个字符串

What to do when there are multiple lines of strings? We can use'''

'''
我们是多行字符串
我们是多行字符串
我们是多行字符串
我们是多行字符串
'''

Let's print():

print(
'''
1.我们是多行字符串
2.我们是多行字符串
3.我们是多行字符串
4.我们是多行字符串
''')
#以下为输出结果
1.我们是多行字符串
2.我们是多行字符串
3.我们是多行字符串
4.我们是多行字符串

So if we want to print out the Pikachu below, what should we do? I think you already have the answer through the above example, just copy the following Pikachu and try it in the python compiler!

へ     /|
  /\7    ∠_/
  / │   / /
 │ Z _,< /   /`ヽ
 │     ヽ   /  〉
  Y     `  /  /
 イ● 、 ●  ⊂⊃〈  /
 ()  へ    | \〈
  >ー 、_  ィ  │ //
  / へ   / ノ<| \\
  ヽ_ノ  (_/  │//
  7       |/
  >―r ̄ ̄`ー―__|

The journey of a thousand miles begins with a single step. You have successfully taken the first step in learning python. We will gradually increase the difficulty in the next lesson. Are you ready?

Python zero foundation full set of video tutorial B site address

Guess you like

Origin blog.51cto.com/14121524/2542993