An astrophysics lab is developing software to calculate the escape velocity of various exoplanets.
The formula to calculate the escape velocity of a spherical celestial body is:
v=2GMRv = \sqrt{\frac{2GM}{R}}v=R2GM
A program and subprogram have been started to carry out this calculation, but are incomplete.
Q05.py:# Q05.py - Unfinished program
# Do not change the existing input statements
def calculate_escape_velocity():
# Add parameters and calculation here
pass
# Main program
mass = float(input("Enter the mass of the planet (kg): "))
radius = float(input("Enter the radius of the planet (m): "))
# Call the subprogram and print the formatted result
Amend the program and subprogram to meet the following requirements:
11186.273 or 2375.400).Do not add any additional functionality.
Save your amended code as Q05FINISHED.py
Practise Edexcel GCSE Computer Science Subprograms with exam-style questions for GCSE Computer Science. 29 questions covering Built-in and user-devised subprograms, Functions versus procedures, and Global and local variables, matched to the Edexcel GCSE Computer Science (1CP2) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.