4a. Please help me solve this python programming. There are two parts to this problem. Include screenshots of your code for better understanding :)
4a. Please help me solve this python programming. There are two parts to this problem. Include screenshots of your code for better understanding :)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
100%
4a. Please help me solve this python

Transcribed Image Text:Finally, add the following lines:
from math import *
x = sgrt (1 / 3)
print (x)
у %3D х * х * 3
print (y)
* 3
z = x
print (z)
Again, the values of y and z, if we have no roundoff error, should be 1 in both cases. Are the values 1? Make a
comment in your code answering the question.
Was that surprising? You should have seen from those examples that sometimes we will encounter issues due to
roundoff error and sometimes we won't. We can't always predict when roundoff error will be obvious.
Part B: Tolerances for Comparisons.
Add to your code from Part A the following lines to compare values of the variables b and e using the concept of
tolerance:
TOL =
le-10
# check if b and e are equal within specified tolerance
if abs (b
e) < TOL:
print ('b and e are equal within tolerance of', TOL)
else:
print ('b and e are NOT equal within tolerance of', TOL)
Add a similar tolerance check to your code for y and z.

Transcribed Image Text:Activity #1:
Create a Python file named Lab4a_Act1.py for the following three-part activity. Please separate the various
parts of your code with the following comment identifying the separate sections (copy/paste into your file with
the appropriate letter).
*## Part A ##:
Part A: Identifying floating-point problems.
First, type in and run the following program:
a = 1 / 7
print (a)
b = a * 7
print (b)
Notice that the value of a is rounded off. The value of b, if we have no roundoff, should be 1. Is it? Make a
comment in your code answering the question.
Now add the following lines:
C = 2 * a
d = 5 *
a
e
= c + d
print (e)
In this case, the value of e, if we have no roundoff, should be 1. Is it? Make a comment in your code answering
the question.
Expert Solution

Step 1
4a)
Code:
###########part A ############
a = 1/7 # 1/7 = 0.14285714285
print(a) #a is rounded off after 17 digits
b = a*7 #0.14258714285*7 = 1.0
print(b) # here b is 1 , it is computed like (1/7 )*( 7) = 1
c = 2*a # 2*(1/7) = 0.285714285
d = 5*a # 5*(1/7) = 0.714285714
e = c+d
print(e) #value of e is not 1 ,it has no roundoff
from math import *
x = sqrt(1/3)
print(x)#printing x
y = x*x*3 #value is 1 , like sqrt(x)*sqrt(x) = x, (1/3)*3 = 1
print(y)#printing y
z = x*3*x #it hs no roundoff
print(z)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY