Answered step by step
Verified Expert Solution
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)
2)
3)
4)
\# 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 definedStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started