2.5 KiB
2.5 KiB
In [1]:
print("hello" * 3)hellohellohello
In [2]:
print("x = %d, y = %f" % (2, 3.0))x = 2, y = 3.000000
In [3]:
x = 3 + 2j
y = -1j
print(x * y)(2-3j)
In [4]:
strs = "abcdefg"
print(strs[0:7:1])
print(strs[1:3])
print(strs[1:])
print(strs[:3])
print(strs[:-1])
print(strs[-3:-1])
print(strs[-3:])
print(strs[:])
print(strs[::2])
print(strs[::-1])abcdefg bc bcdefg abc abcdef ef efg abcdefg aceg gfedcba
In [5]:
def minimal(x, y):
if x > y:
print("较小值为: ", y)
else:
print("较小值为: ", x)
a = float(input("请输入第一个数据: ")) # 输入了 5.4
b = float(input("请输入第二个数据: ")) # 输入了 6.8
minimal(a, b)较小值为: 5.4