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

Python learning (I)

編輯:Python

Python Language :

Python Our design is very readable , Compared with other languages, English keywords are often used , Some punctuation marks in other languages , It has a more distinctive grammatical structure than other languages


Simple code :

import turtle
# Width 
turtle.width(5)
# Color 
turtle.color("red")
# Draw a radius of 50 The circle of 
turtle.circle(50)
# # Move forward 
turtle.goto(100, 0)
turtle.circle(50)




Python Base number :
except 10 Base number , There are three other bases :
0b or 0B For binary
0o or 0O For octal
0x or 0X For hexadecimal

# The result is 5
print(0b101)
# Print as 8
print(0o10)
#d Print as 255
print(0xff)

String to integer :
turn int The number after the decimal point will be cleared directly

# The result is 1
print(int(1.8))
# The result is 2
print(round(1.8))

Chained assignment :

# The result is both 123
x = y = 123
print(x, y)

The same operator :

#is and == The difference between :
# == Used to determine whether the values of reference variables and reference objects are equal , By default, the _eq_() Method 
# is Used to determine whether two variable reference objects are the same , That is, the address of the comparison object , Determine whether two identifiers refer to the same object 
# is not Is to determine whether two identifiers refer to different objects 
a = 1
b = 1
# The result is true
print(a == b)
# The result is false
print(a is not b)

All right. , Let's share today , Thank you for browsing !


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