不知道为何程序没有输出

问题是把秒转换为时分秒,不知为何一直没有输出导致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

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

6个月前 评论

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

5个月前 评论
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", "copyright", "credits" or "license" for more information.
>>> print      ("Hello World !!!")
Hello World !!!
5个月前 评论

我这就可以

5个月前 评论

小问题=大灾难 ,引号问题。 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

5个月前 评论

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