Python Forum
How to solve this task?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to solve this task?
#1
Imagine yourself as a space ranger. Create a function that has the distances from Earth to the five nearest
stars (find the distances and names of the stars on the Internet).The user enters the speed of his ship and receives time (in hours) in which it will reach each star.If it will take more than 10 years to travel, display on the screen the recommendation to work on the ship and the speed which is needed for the voyage to last less than 10 years.
import time
alphaCentauri = 4
alphaCentauriB = 4.5
barnard = 5
lumanSixteen = 6
wolfThree = 13
speed= int(input("скорость корабля:"))
time = alphaCentauri / speed  #other stars
print("время в часах:", time,"час(ов)" )
This is all that i could write
Reply
#2
Hint: use a list instead of five variables
stars = [('Alpha Centauri', 4), ('Alpha Centauri B', 4.5), ...]
Reply
#3
Here is how you can determine the hours and years that the journey will take at a given speed entered as kilometers per hour.
LIGHT_SPEED = 1079252849 # kilometers per hour
HOURS_PER_YEAR = 8766

alphaCentauri = 4

kilometers_per_hour = int (input ("Введите скорость в километрах в час:"))
speed = kilometers_per_hour / LIGHT_SPEED
years = alphaCentauri / speed
hours = years * HOURS_PER_YEAR

print("время в часах:", hours ,"час(ов)")
print ("Время в годах:", years, "год(ы)")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Stuck with using lists to solve task gery576 9 838 Jan-16-2024, 06:29 PM
Last Post: DPaul
  I need help to solve this task using while statement rico4pepe 6 9,279 Apr-02-2020, 11:34 AM
Last Post: pyzyx3qwerty

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020