0

''' 你好呀

我试图找到一个简单的函数,可以用来估计航海者 1 号航天器的往返通信时间(从现在起 1、3、10 100 或 300 年)。

这是我目前掌握的信息,它应该是一个简单的函数,我理解数学。只需要语言。

谢谢

import time

def communication_time(days):

    distance_start = 0
    distance_now = 22944706739.083 #in km
    velocity_voy_1 = 16.9995 # in km/s
    speed_of_light = 299792 # km/s


distance = distance_start + velocity_voy_1 * time_since_start

round_trip_communication_time = (2 * distance_now/speed_of_light)

return 0

    print(abs(communication_time(0) - 146143.0) < 10)
    print(abs(communication_time(55) - 146682.0) < 10)
    print(abs(communication_time(365.25 * 6) - 167616.0) < 10)  
4

1 回答 1

0

我认为这就是你所追求的:

import time

distance_now = 22944706739.083 #in km
velocity_voy_1 = 16.9995 # in km/s
speed_of_light = 299792 # km/s

def where_will_voyager_be( days ):
    return distance_now + velocity_voy_1 * 86400 * days

def communication_time( distance ):
    return 2 * distance / speed_of_light

def comm_time_in_days( days ):
    dist = where_will_voyager_be( days )
    return communication_time( dist )

# How long is comm time now?

print( "Now:", comm_time_in_days(0), "s" )
print( "Next month:", comm_time_in_days(30), "s" )
print( "Next year:", comm_time_in_days(365.25), "s" )
print( "5 years:", comm_time_in_days(5 * 365.25), "s" )
print( "10 years:", comm_time_in_days(10 * 365.25), "s" )
print( "30 years:", comm_time_in_days(30 * 365.25), "s" )

输出:

Now: 153070.84071011236 s
Next month: 153364.79587902947 s
Next year: 156649.74489167825 s
5 years: 170965.3616179418 s
10 years: 188859.88252577122 s
30 years: 260437.96615708893 s
于 2021-08-16T03:46:51.537 回答