共計 217 個字符,預(yù)計需要花費 1 分鐘才能閱讀完成。
可以使用 Python 內(nèi)置的 max() 函數(shù)來求三個數(shù)中的最大值。
方式一:使用 max() 函數(shù)傳入三個數(shù)作為參數(shù)
a = 3
b = 5
c = 2
max_value = max(a, b, c)
print(max_value)
輸出結(jié)果為:
5
方式二:將三個數(shù)放入一個列表中,然后使用 max() 函數(shù)求列表中的最大值
numbers = [3, 5, 2]
max_value = max(numbers)
print(max_value)
輸出結(jié)果為:
5
丸趣 TV 網(wǎng) – 提供最優(yōu)質(zhì)的資源集合!
正文完