当前分类:300例题>>正文

Python示例:创建不同类型元组

来源:互联网   更新时间:2023年6月23日  

Python 示例

写一个 Python示例来创建不同类型的元组并打印出来。这个 Python 示例显示了整数、字符串、布尔、浮点、混合元组、元组内部的元组(嵌套元组)和列表元组的创建。

# Different Type Tuples

numericTuple = (10, 20, 30, 40, 50)
print("Numeric Tuple Items = ", numericTuple )

floatTuple = (10.25, 11.20, 19.37, 41.598)
print("Float Tuple Items = ", floatTuple )

stringTuple = ('orange', 'Mango', 'Grape', 'Apple')
print("String Tuple Items = ", stringTuple )

booleanTuple = (True, False, False, True, True)
print("Boolean Tuple Items = ", booleanTuple )

mixedTuple = ('orange', 25, 'Mango', 36.75, False, 10)
print("Mixed Tuple Items = ", mixedTuple )

nestedTuple = (10, 20, ('orange', 'Mango'), 30)
print("Nested Tuple Items = ", nestedTuple )

listTuple = (10, 20, ['Grape', 'Apple'], 70)
print("List Tuple Items = ", listTuple )

本文固定链接:https://6yhj.com/leku-p-4412.html  版权所有,转载请保留本地址!
[猜你喜欢]

标签: 论文查重