Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello!New to python!
#1
Hello!i am 17 years old and i started studying python in my school!
My teacher gave us some exercises and told us to find the mistakes in the code and correct them.
i have the following code:

a=1
for i in range(1.0, 10.0):
    a =* (i**2) + (i**(1/2))
print(a)
and the result to this one should be 635083338027.779

the mistakes i have found or at least i think they are the ones in the bold.

1.range takes only integers so that should be range(1,10)
2.it should be only =

am i correct for these points??
Now,when i run it the result is 84.

Can someone please explain me what changes i have to do so the result be the underline one?
can you help me?

ok buran!
i am sorry.My mistake
Reply
#2
You are correct that there is mistake on line#3, but it's not what you think it is.
Hint:
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
oh my god!It was so simple???Thanks!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020