Computers and Technology, 16.06.2021 22:10 ErickN7597
Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a function named newton. This function expects the input number as an argument and returns the estimate of its square root. The program should also include a main function that allows the user to compute the square roots of inputs from the user and python's estimate of its square roots until the enter/return key is pressed.
My code:
import math
tolerance = 0.00001
def newton(x):
estimate = 1.0
while True:
estimate = (estimate + x/estimate) /2
difference = abs(x - estimate**2)
if difference <= tolerance:
break
return estimate
def main():
while True:
x = input("Enter a positive number or enter/return to quit: ")
if x==" ":
break
x = float(x)
print("The program's estimate of the square root of",x,"is", round(newtown(x),2))
print("Python's estimate is:",math. sqrt(x))
main()
it keeps coming up with a syntax error --invalid syntax for line 23 except:
Answers: 3
Computers and Technology, 21.06.2019 17:00
Which process would best represent the opposite of exhausting air from a system?
Answers: 2
Computers and Technology, 23.06.2019 17:10
Ac++an of of pi. in , pi is by : pi = 4 – 4/3 + 4/5 – 4/7 + 4/9 - 4/11 + 4/13 - 4/15 + 4/17 . ., to pi (9 ). , if 5 to pi,be as : pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 = 4 – 1. + 0.8 - 0. + 0. = 3.. atoofbe to pi?
Answers: 2
Computers and Technology, 23.06.2019 19:50
Which feature is selected to practice and save the timing of a presentation
Answers: 1
Computers and Technology, 24.06.2019 08:00
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a...
Computers and Technology, 16.01.2021 06:40
Computers and Technology, 16.01.2021 06:40
Mathematics, 16.01.2021 06:40
Arts, 16.01.2021 06:40
Chemistry, 16.01.2021 06:40
Physics, 16.01.2021 06:40
Mathematics, 16.01.2021 06:40
Mathematics, 16.01.2021 06:40
Biology, 16.01.2021 06:40
Health, 16.01.2021 06:40
Mathematics, 16.01.2021 06:40
English, 16.01.2021 06:40
Mathematics, 16.01.2021 06:40