Answer:
def newton(n):
#Define the variables.
t = 0.000001
esti = 1.0
#Calculate the square root
#using newton method.
while True:
esti = (esti + n / esti) / 2
dif = abs(n - esti ** 2)
if dif <= t:
break
#Return the result.
return esti
#Define the main function.
def main():
#Continue until user press enters.
while True:
try:
#Prompt the user for input.
n = int(input("Enter a number (Press Enter to stop):"))
#display the results.
print("newton = %0.15f" % newton(n))
except:
return
#Call the main function.
main()
Answer:
I'm guessing you want a function so...
def print_seconds(hours, minutes, seconds):
seconds += 3600 * hours + 60 * minutes
print(seconds)
return 0
Hope this helps. :)
Pablo can be a minimum of two pains and a maximum of four panes in a split screen worksheet.
function myFunction(num){
n = 0;
total = 1;
while (n < num){
total *= (num - n);
n+=1;
}
return total;
}
alert(myFunction(6));
I'm not too proficient in JavaScript but here's what the function would look like. I hope this helps!