不知道为何程序没有输出 | python | python 技术论坛-金年会app官方网

问题是把秒转换为时分秒,不知为何一直没有输出导致marking过不了

time = int(input(“input a time in seconds: “)) # get input for time in seconds
hours = time // 3600 # calculate hours
remaining_seconds = time % 3600
minutes = remaining_seconds // 60 # calculate minutes
seconds = remaining_seconds % 60 # calculate seconds
print (“the time on earth is”,hours,”hours”,minutes,”minutes and”,seconds,”seconds.”)# out put the result

讨论数量: 5
jason990420

代码没有错, 不知道图片中的是什么软件的介面 ?

5个月前

python3的话,应该是最后一行print后面多了一个空格

4个月前
jason990420

python3 的话,应该是最后一行 print 后面多了一个空格

有空格, 没有问题 !

whitespace is mostly ignored, and mostly not required, by the python interpreter.

d:\>python
python 3.12.4 (tags/v3.12.4:8e8a4ba, jun  6 2024, 19:30:16) [msc v.1940 64 bit (amd64)] on win32
type "help", "金年会app官方网 copyright", "credits" or "license" for more information.
>>> print      ("hello world !!!")
hello world !!!
4个月前

我这就可以

4个月前

小问题=大灾难 ,引号问题。 time = int(input("input a time in seconds: ")) # get input for time in seconds hours = time // 3600 # calculate hours remaining_seconds = time % 3600 minutes = remaining_seconds // 60 # calculate minutes seconds = remaining_seconds % 60 # calculate seconds print("the time on earth is", hours, "hours", minutes, "minutes and", seconds, "seconds.") # output the result

3个月前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
网站地图