Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to print your pet elf with python

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces how to use python to print your pet elf, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.

Python print Pokemon

Print your pet elf with python

Let's start writing our first python code with an interesting example.

The basic syntax of python involved is: print output function, assignment, string

Print ()

Print () is a built-in function of python for printout 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 means that when we run the python program, print () is used to output the results of the program to the computer screen. We can deepen our understanding through the following two examples!

Code 1:

A = 8b = 10c = a + bc

Running result

We can see that the running result of pycharm is local blank, and there is no result, so let's see what it looks like after adding print ().

Code 2:

A = 8b = 10c = a + bprint (c)

Running result

Through the comparison of the two pieces of code, we can know that if we want to see the computer give us feedback, we must print what we want to the computer screen through print ()!

It should be noted that the'='in a = 8 here is not an equal sign in our mathematical symbol, but an assignment sign, and the equal sign in python is represented by two consecutive equal signs: = =

The word order of this code is as follows: assign 8 to the letter a, here is a custom variable, and its capacity is very small, can only put in a value, when you want to put a new value, its original value will be overwritten, we understand it through a piece of code.

A = 8print (a) # output result is: 8a = 3print (a) # output result is: 3 string

A string is a common data type in python. It is any text enclosed in (or ")." or "" itself is just a representation, not part of a string. (the quotation marks here are all English quotation marks.)

Chinese characters and letters are strings, and numbers with quotation marks are also strings. Numbers without quotation marks are numeric types, not string types. We'll talk about this in the next section.

'I am a string' print ('I am a string') # output result is: I am a string "I am also a string" print ("I am also a string") # output result is: I am also a string

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

'' we are multiline strings''

Let's print ():

Print (''1. We are multiline strings 2. We are multiline strings 3. We are multiline strings 4. We are multiline strings'') # the following is the output result 1. We are multiline string 2. We are multiline string 3. We are a multiline string 4. We are multiline strings.

So what if we want to print out the Pikachu below in its entirety? I think you already have the answer through the above example. Copy the following Pikachu and try it in the python compiler.

Thanks / | /\ 7 ∠ _ / / │ / / │ Z _ < / / `"│" / > Y` / / "●, ● ⊂⊃ < / ()" |\ < > ", _" │ / / "/" < |\\ "_" (_ / │ / / 7) | | / >-r pet elf-_ _ | this is the end of sharing about how to print your pet elf with python. I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report