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 !