def get_trajectory_image(height, width=400): aspect = height / float(width) if height > 300: height = 300 width = height / aspect return height, width height, width = get_trajectory_image(600, 300) print(height, width)