Computers and Technology

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:

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 23:30, yasarhan2
Match the following errors with their definitions. a. #name b. #value c. #ref d. 1. when a formula produces output that is too lengthy to fit in the spreadsheet cell 2. when you enter an invalid cell reference in a formula 3. when you type text in cells that accept numeric data 4. when you type in a cell reference that doesn’t exist
Answers: 1
image
Computers and Technology, 24.06.2019 12:00, exoticbunnylover123
Which spreadsheet operation does a look function perform?
Answers: 1
image
Computers and Technology, 24.06.2019 16:00, ramirez5571
"gps interaction and cognitive process" respond to the following: imagine that you have been asked to design a gps product that will have voice recognition and bluetooth capability. discuss and conceptualize a user interaction model. predict two (2) problems that may arise in gps products with voice recognition and bluetooth capability. recommend solutions for each of these issues. attention is one of the six cognition processes. when attention is applied to a design, the goal is to make it easier for the end user to quickly locate where he / she should type information on the computer or mobile device screen. compare and contrast how the google search engine and the microsoft bing search engine employ the attention cognition process. provide your opinion as to which search engine better employs the attention cognition process and explain why.
Answers: 3
image
Computers and Technology, 24.06.2019 22:00, justincsh7238
Ican’t open these when it’s just a comment. someone pls explain why this is happening
Answers: 1
Do you know the correct answer?
Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a...

Questions in other subjects:

Konu
Mathematics, 23.06.2019 19:40
Konu
Mathematics, 23.06.2019 19:40