436,433 views
37 votes
37 votes
Can someone help me? Also, please put it on a coding sheet so they will be no errors.

Can someone help me? Also, please put it on a coding sheet so they will be no errors-example-1
Can someone help me? Also, please put it on a coding sheet so they will be no errors-example-1
Can someone help me? Also, please put it on a coding sheet so they will be no errors-example-2
User Jon White
by
2.3k points

2 Answers

16 votes
16 votes

Answer:

See below

Step-by-step explanation:

For the sqrt(n) method your function call is incorrect. As candlejenner has correctly coded, the function call on line 14 should be

print (sqrt(25))

without quotes

That is my best guess.

For the checkout() method, I can't see the bottom of your code window so I do not know how you are calling this method. My code and run results are in the attached figure. This is from another course but is the exact same thing.

There is absolutely no difference between my code and yours except on line 19 I am calling the checkout() method

So see if that change works

Good Luck

Can someone help me? Also, please put it on a coding sheet so they will be no errors-example-1
User Billur
by
3.4k points
22 votes
22 votes

Answer:

try this

def sqrt(n):

approx = n / 2.0

better = (approx + n/approx)/2.0

while better != approx:

print (better)

approx = better

better = (approx + n/approx)/2.0

return approx

print (sqrt(25))

def checkout():

total = 0

count = 0

moreitems = True

while moreitems:

price = float(input('Enter price of item (0 when done): '))

if price != 0:

count = count + 1

total = total + price

print('Subtotal: ${:.2f}'.format(total))

else:

moreitems = False

average = total / count

print("Total items:", count)

print("Total price: ${:.2f}".format(total))

print("Average price: ${:.2f}".format(average))