程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

20 day zero foundation self-study Python | day3 print | notes

編輯:Python

Hello everyone , I'm Ning Yi .

In this class, let's talk about some Python Basic knowledge of .

1、print Print

print() It is the most commonly used Python function , Not one of them. , Can't understand the code, find him , Come to him when you have problems , The inspection procedure also looks for him , A warm man .

It's easy to use .

Basic grammar :

print(" Output content ")

Now let's print out the first sentence ~

(1) Open the terminal

Terminal open mode :

Mac: Start up stage Search for terminal

Windows: Start Search for cmd

(2) Get into Python Interactive environment

Windows The environment is input at the terminal python.

Mac The environment is input at the terminal python3.

appear python Version and prompt >>>, It means that you have successfully entered the interactive environment .

We can at the prompt >>> Type in Python Code .

(3) Enter the code

At the prompt >>> Type in print("Hello World”) Back carriage return , The system will print it out Hello World.

>>> print("Hello World") # Input Hello World # Output 

Some friends may have some questions here , Why not use the code editor we installed last class to write code , Instead, write in the terminal .

You can write code in both the terminal and the code editor , We often test some simple functions in the terminal , Edit complex functions in the code editor .

The content of the previous lessons is relatively simple , We write directly in the terminal , Later, it will gradually go to the code editor , So after the course , You can write code in two ways .

2、 notes

A note is actually a paragraph of text , We want to add a textual explanation to the code , I don't want this text explanation to be run as code .

At this time, you can use comments .

function 、 Class must be annotated with a block , Code key parameters and key positions need to add line comments , You also need to avoid unnecessary comments .

Basic grammar :

(1) Single-line comments

If the comment has only one line , Put a pound sign in front of it # Can .

# Output Hello world( I am a comment )print('Hello world') # I'm also a commentator ( This is not recommended )

(2) Multiline comment

If you want multi line comments , Use three English single quotation marks in pairs (''' ''') Or the Pair three English double quotation marks (""" """) Wrap the text .

""" I am a comment with three double quotation marks """''' I am a comment with three single quotation marks '''

Adding comments to code is a very good habit , Especially in teamwork , Adding comments can help others quickly understand our code .

Mind map summary :

Click to follow ,Python Get started and don't get lost ~


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved