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

Python learning 6.15

編輯:Python

Formatting output variables

name = " Daming "
print(" My name is %s, Please take good care of me !" % name)

Take an integer variable

student_no = 1
print(" My student number is %06d" % student_no)

floating-point

price = 8.5
weight = 7.5
money = price *weight
print(" Apple unit price %.2f element / Jin , bought %.2f element / Jin , Need to pay %.4f element %(price,weight,money))

Define a decimal scale, The output data scale is 10.00%

scale = 0.1
print(" The data scale is %.2f%% %(scale *100))

The concept and naming requirements of identifiers

Letter , Underline , Digital composition
Cannot start with a number
Cannot have the same name as the keyword

keyword

Has a special identifier
import: Import a toolkit

python Naming rules

python Identifiers in are case sensitive

= There should be a space left and right
python in , If the variable name needs to be composed of two or more words , You can name it in the following way
Use lowercase letters for each word
Use... Between words _ Underline connection

Hump naming hair
Little hump
The first word begins with a lowercase letter , Follow on initial capital
Hump
The first letter of each word is capitalized

if Introduction to basic syntax of statements

if The conditions to judge
When conditions are met , What to do
The code is indented with a tab key , perhaps 4 A space – Spaces are recommended


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