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)  )

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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) 

)

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education