题目
题目

FIT9136 Introduction to Python programming - S2 2025

单项选择题

Your GPS app returns coordinates as a tuple:coords = (40.7128, -74.0060) You want to change the latitude from 40.7128 to 41.0000. Which code snippet is valid?

选项
A.a. coords[0] = 41.0000 print(coords)
B.b. coords = (41.0000,) + (coords[:1]) print(coords)
C.c. coords[0] = 41.0000 print(coords)
D.d. coords = (41.0000,) + (coords[1:]) print(coords)
查看解析

查看解析

标准答案
Please login to view
思路分析
We start by restating the problem: we have a GPS coordinate pair as a tuple coords = (40.7128, -74.0060) and we want to change the latitude (the first element) from 40.7128 to 41.0000. We need to evaluate each option for validity in Python and whether it achieves the desired result. Option a: coords[0] = 41.0000 print(coords) This attempts to assign a new value to an element of a tuple. Tuples are immutable in Python, meaning their elem......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!