This Python script is full of syntax, runtime, and semantic errors. Please identify and correct these errors, such that code becomes fully executable and outputs the following message on the screen when running from the Git Bash command line The life expectancy for the millennials is projected to be 120 years! (But don't believe it...) A recent study published in the journal of Nature, discovered that over the past century, although life expectancy has significantly increased due to technological advances, the maximum life span of the oldest people in the world has not changed much. Cardano was the first to introduce complex numbers of the form a + sqrt(-b) into algebra, but he had misgivings about it. In his solution to an algebra equation, he encountered the solution 5 + sqrt(-15) for the unknown, which is now mathematically represented by (5+3.872983346207417j) in Python, which can also be obtained as the addition of real and imaginary numbers in Python like this 5 + sqrt(-15) = (5+3.872983346207417j), which can also be manually stated as (5+3.872983346207417j) One final note: In python the sqrt function from math and cmath modules are different. The sqrt function that returns "float" results is sqrt from the math module. Therefore, if using the math module, then, sqrt(25) = 5.0000, which is a float (real number). Also note that by convention, 0**0 = 1 in Python. And division by 0, will give you a runtime exception: 1/0 = NaN code to be fix !# \usr\bin\env 'python' _life_expectancy = 120; print( '\n' + 'The life expectancy for the millennials is projected to be %% years! (But don't believe it...)' + '\n', % {_life_expectancy}l ): print( ''' A recent study published in the journal of Nature, discovered that over the past century, although the life expectancy has significantly increased due to technological advances, the maximum life span of the oldest people in the world has not changed much. """ from cmath import sqrt # cmath function always return complex numbers from math import sqrt # math function always work with and return real numbers print (""" Cardano was the first to introduce complex numbers of the form a + sqrt(-b) into algebra, but he had misgivings about it. \ In his solution to an algebra equation he encountered the solution 5 + sqrt(-15) for the unknown, which is now mathematically represented by \n \n \ {first:} \n\nin Python, which can also be obtained as an addition of real and imaginary numbers in Python like this \n\n\ 5 + sqrt(-15) = {second:}, \n\n which can also be manually stated as {third:} \n \ """ % format( second=complex(5,-15) , first=5+sqrt(-15) , third=5+3.872983346207417i ) ) print(''' One final note: \n \tIn python the sqrt function from math and cmath modules are different. \tThe sqrt function that returns "float" results is sqrt from math module. \tTherefore, if using math module, then, \t\tsqrt(25) = {:.4f}, \twhich is obviously a float (real number). ''' .format(sqrt(25)) ) print(''' Also note that by convention, 0**0 = {first:d} in Python. And division by 0, will give you a runtime exception: 1/0 = {second:} ''' .format(first=0**0,second=1/0) )
This Python script is full of syntax, runtime, and semantic errors. Please identify and correct these errors, such that code becomes fully executable and outputs the following message on the screen when running from the Git Bash command line
The life expectancy for the millennials is projected to be 120 years! (But don't believe it...) A recent study published in the journal of Nature, discovered that over the past century, although life expectancy has significantly increased due to technological advances, the maximum life span of the oldest people in the world has not changed much. Cardano was the first to introduce complex numbers of the form a + sqrt(-b) into algebra, but he had misgivings about it. In his solution to an algebra equation, he encountered the solution 5 + sqrt(-15) for the unknown, which is now mathematically represented by (5+3.872983346207417j) in Python, which can also be obtained as the addition of real and imaginary numbers in Python like this 5 + sqrt(-15) = (5+3.872983346207417j), which can also be manually stated as (5+3.872983346207417j) One final note: In python the sqrt function from math and cmath modules are different. The sqrt function that returns "float" results is sqrt from the math module. Therefore, if using the math module, then, sqrt(25) = 5.0000, which is a float (real number). Also note that by convention, 0**0 = 1 in Python. And division by 0, will give you a runtime exception: 1/0 = NaN
code to be fix
!# \usr\bin\env 'python'
_life_expectancy = 120; print( '\n' + 'The life expectancy for the millennials is projected to be %% years! (But don't believe it...)' + '\n', % {_life_expectancy}l ):
print( '''
A recent study published in the journal of Nature, discovered that over the past century,
although the life expectancy has significantly increased due to technological advances,
the maximum life span of the oldest people in the world has not changed much.
"""
from cmath import sqrt # cmath function always return complex numbers
from math import sqrt # math function always work with and return real numbers
print ("""
Cardano was the first to introduce complex numbers of the form a + sqrt(-b) into algebra, but he had misgivings about it. \
In his solution to an algebra equation he encountered the solution 5 + sqrt(-15) for the unknown, which is now mathematically represented by \n \n \
{first:} \n\nin Python, which can also be obtained as an addition of real and imaginary numbers in Python like this \n\n\
5 + sqrt(-15) = {second:}, \n\n
which can also be manually stated as
{third:} \n
\
""" % format( second=complex(5,-15) , first=5+sqrt(-15) , third=5+3.872983346207417i ) )
print('''
One final note: \n
\tIn python the sqrt function from math and cmath modules are different.
\tThe sqrt function that returns "float" results is sqrt from math module.
\tTherefore, if using math module, then,
\t\tsqrt(25) = {:.4f},
\twhich is obviously a float (real number).
''' .format(sqrt(25))
)
print('''
Also note that by convention, 0**0 = {first:d} in Python.
And division by 0, will give you a runtime exception: 1/0 = {second:}
''' .format(first=0**0,second=1/0)
)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)