Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I keep getting an error with my code may you tell me what's wrong and write it so I can actually execute it. I

Hello I keep getting an error with my code may you tell me what's wrong and write it so I can actually execute it. I get a value error alot and its just not working

(Please use Python)

1)

image text in transcribed

image text in transcribed

2)

image text in transcribed

image text in transcribed

3)

image text in transcribed

image text in transcribed

4)

image text in transcribed

image text in transcribed

\# Using double precision to get the value of 010000000111111010111001 (in five decimals) val = float("0b" + "010000000111111010111001") print("\{:5f\}".format(val)) Traceback (most recent call last): File "main.py", line 2, in val = float("0b" + "010000000111111010111001") ValueError: could not convert string to float: ' 0 b010000000111111010111001' \# Using 3 digit chop arithmetic to get the result val = int ("0b+"01000000011111010111001",2) ** Process exited - Return Code: 0 ** Press Enter to exit terminal \# Using 3 digit rounding arithmetic to get the result val = round(float ("0b+"010000000111111010111001"),3) print("\{::3f\}".format ( val )) Traceback (most recent call last): File "main.py", line 2, in val=round(float("0b"+"010000000111111010111001"),3) valueError: could not convert string to float: ' 06010000000111111010111001 ' \# Absolute error abs_error = abs(val - float ("0b"+"010000000111111010111001")) \# Relative error rel_error = abs_error / float(" b"+ "01000000011111010111001") print("Absolute error: {:3f}". format(abs_error)) print("Relative error: {:3f}". format(rel_error) ) Traceback (most recent call last): File "main.py", line 2, in abs_error = abs(val - float("0b" + "o10000000111111010111001")) NameError: name "val' is not defined

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Theory And Applications 27th Australasian Database Conference Adc 20 Sydney Nsw September 28 29 20 Proceedings Lncs 9877

Authors: Muhammad Aamir Cheema ,Wenjie Zhang ,Lijun Chang

1st Edition

3319469215, 978-3319469218

More Books

Students also viewed these Databases questions