Python 实例

Python 语法

例子解释:语法icon-default.png?t=N7T8https://www.w3school.com.cn/python/python_syntax.asp

print("Hello World!!! ")
#This is a comment.
print("Hello, World!")
"""This is a
multiline docstring."""
print("Hello, World!")

Python 变量

例子解释:变量

x = 10
y = "Bill"
print(x)
print(y)
x = "awesome"
print("Python is " + x)
x = "Python is "
y = "awesome"
z = x + y
print(z)

Python 数字

x = 10
y = 6.3
z = 2j

print(type(x))
print(type(y))
print(type(z))
x = 10
y = 37216654545182186317
z = -465167846

print(type(x))
print(type(y))
print(type(z))
x = 3.50
y = 2.0
z = -63.78

print(type(x))
print(type(y))
print(type(z))
x = 27e4
y = 15E2
z = -49.8e100

print(type(x))
print(type(y))
print(type(z))
x = 2+3j
y = 7j
z = -7j

print(type(x))
print(type(y))
print(type(z))

Python Casting

例子解释:Casting

x = int(1)
y = int(2.5)
z = int("3")
print(x)
print(y)
print(z)
x = float(1)
y = float(2.5)
z = float("3")
w = float("4.6")
print(x)
print(y)
print(z)
print(w)
x = str("S2")
y = str(3)
z = str(4.0)
print(x)
print(y)
print(z)

  • 8
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值