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

Python of day and night exploration

編輯:Python
# This is a comment , The canonical format of comments ,# Followed by a space , In order to ensure the tidiness of notes 
print(' How do you do ')
# python It's an explanatory language , The code should be interpreted and executed , Must pass python Interpreter translation can only be executed 
# Using breakpoints , Step by step 
# Make a comment , Shortcut keys still apply , Don't think about spaces ( Light bulbs can solve all Space question !!!)
""" This is a multiline comment , And you can wrap lines """
print(" How do you do ")
# Arithmetic operator 
a = 10 + 2
print(a)
b = 10 - 2
print(b)
c = 10 * 2
print(c)
d = 10 / 2
print(d)
d = 10 // 2 # Double backslashes Rounding off of business , Single backslash calculation , Keep decimals for quotient 
print(d)
a = 10 % 3
print(a)
a = 2 ** 3 # Multiplication 
print(a)
# Operators also apply to strings 
print("$$$$$")
print('$' * 5)
# python In double quotation marks 、 Single quotation marks make no difference 
# python There is no need to specify the variable type in , Digital data and non digital data ( character string 、 list 、 Tuples 、 Dictionaries )
name = ' Xiao Ming '
sex = True
height = 180.5
weight = 70.0
# Tuples 、 Dictionaries 
# String splicing Same as string; + The unsupported operation is int+string
a = ' Xiao '
b = ' bright '
print(a + b)
# Keyboard entry , Use input function 
price = input(" Please enter the apple price ")
weight = input()
price = float(price)
weight = float(weight) # float and string Multiplication is actually OK 
print(price * weight) #10*2.5 700.0 ?
# Report errors :TypeError: can't multiply sequence by non-int of type 'float'
# input() The function inputs a string format , Use forced type conversion 

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