Exercises -L4-Q1
Write Python code that initializes a tuple of
strings representing different emotions [i.e.,
happy,sadfear, surprisel.Write code that
prints the number of elements in the tuple, the
first element,and the last element.
2
IHint:You can use the len function to
determine how many elements are in the tuple
and then use that information to print the last
element.
Python Programming
关于#python#的问题,请各位专家解答!
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- Python-ZZY 2021-10-04 17:34关注
首先翻译一下,然后再给代码
编写Python代码初始化的元组 表示不同情绪的字符串[例如, 快乐,悲伤恐惧、惊讶。编写代码, 输出元组中的元素个数 第一个元素和最后一个元素。 你可以使用len函数 确定元组中有多少元素 然后用这些信息打印最后一张 元素。
feel = ("happy", "sad", "fear", "surprise") print(len(feel)) print(feel[0]) print(feel[-1]) ''' len函数返回对象的长度 feel[0]返回feel元组的第一项 feel[-1]返回最后一项 '''
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 yolov8边框坐标
- ¥15 matlab中使用gurobi时报错
- ¥15 WPF 大屏看板表格背景图片设置
- ¥15 这个主板怎么能扩出一两个sata口
- ¥15 不是,这到底错哪儿了😭
- ¥15 2020长安杯与连接网探
- ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
- ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
- ¥16 mybatis的代理对象无法通过@Autowired装填
- ¥15 可见光定位matlab仿真