题目
题目

Fal25_CS003C_74229 Ch. 7 Pre-Quiz (Remotely Proctored)

单项选择题

In the code snippet below, if the file contains the following words: apple, pear, and banana stored one per line, what would be the output? infile = open("input.txt", "r") for word in infile : word = word.rstrip() print(word)

选项
A.apple pear banana
B.apple pear banana
C.apple, pear, banana
D.apple pear banana
查看解析

查看解析

标准答案
Please login to view
思路分析
The question asks what the printed output would be when a file contains the lines: apple, pear, and banana, each on its own line, and the code reads the file line by line, strips the trailing newline, and prints the word. Option 1: 'apple\npear\nbanana'. This option correctly represents three......Login to view full explanation

登录即可查看完整答案

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

更多留学生实用工具

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