Finding the mean | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Finding the mean

if i have this code: Start = int('input( enter number to start at') X = int(input('enter number to end with') Sum=0 for i in range(start, x+1): Sum += 1 print('from start to end total is {}'.format(Sum / (i)))

11th Jun 2019, 7:42 PM
Ranking
Ranking - avatar
11 Answers
+ 2
what timezone are you from that your anwsering so fast/do you even sleep 😅😅
11th Jun 2019, 9:35 PM
Anton Böhler
Anton Böhler - avatar
+ 5
ok- it take me some time to fix it all. Sorry to say there is hardly a line of code without an issue 🤒 But don’t worry, you will learn about this. It‘s too late for me now. so please try to compare your code carefully with the revised code. I did not only fix syntax errors and some math problems, i also corrected some variable names that are named exactly like a python object which should not be. please keap in mind that python is case sensitive so upper or lowercase matters. #Finding the mean #if i have this code: start = int(input('enter number to start at')) x = int(input('enter number to end with')) sum1=0 for i in range(start, x+1): sum1 += i print('Mean is {}'.format(sum1 / len(range(start, x+1)))) If you need to have more explanations give me a feedback. So i will come back tomorrow. A last comment: As i saw that you have not done the python course here at SoloLearn. i would encourage you to do so. It‘s worth !!
11th Jun 2019, 9:07 PM
Lothar
Lothar - avatar
+ 2
well hope you don't have a burnout ... 🤯 good luck!
11th Jun 2019, 9:38 PM
Anton Böhler
Anton Böhler - avatar
+ 2
Id be ok but really thanx
11th Jun 2019, 9:39 PM
Ranking
Ranking - avatar
+ 2
the last line in the code just puts the result of "sum1 / len(range(start, x+1))" where the "{}" is an other way to achieve a similar result woulde be like this: print("from start to end total is" + str(sum1 / len(range(start, x+1))))
11th Jun 2019, 9:41 PM
Anton Böhler
Anton Böhler - avatar
+ 1
I am trying to understand what is happening at the last line of code can some one break it down for me please i would be ever so grateful
11th Jun 2019, 7:43 PM
Ranking
Ranking - avatar
+ 1
The code should be taking in a number lets say the number is 0 and taking a final number lets say that number is 3 What should happen is 0+1+2+3 / by the amount of numbers in this range which is 4? am i correct here? can a professional confirm this please? i am new and just want to know if my understanding is sound
11th Jun 2019, 7:45 PM
Ranking
Ranking - avatar
+ 1
Whats this
11th Jun 2019, 8:10 PM
Ranking
Ranking - avatar
+ 1
I am new so that link didnt help me i need someone to break it down in baby language for me please really glad you respond and i am grateful but i didnt get the gist of the problem from your link please guide me with this example, that which was sent confused me and im trying to gain my intuitive understand slow and steady
11th Jun 2019, 8:13 PM
Ranking
Ranking - avatar
+ 1
K i will try again! Thank you again for your expertise! I signed up for 3 courses external this one and i just left all of them at the start. i had loads of questions and they weren't helping me understand. So i decided before i waste money again i will try to get my hands dirty and understand what is really happening by my own errors rather than watching and not getting the understanding that is required to become a pro! So this far i habe understood loads this way. i tying to gather a little more confidence
11th Jun 2019, 9:32 PM
Ranking
Ranking - avatar
+ 1
No actually my sleeping patterns are rrslly bad health wise and well i really wanna learn so its driving me to learn
11th Jun 2019, 9:37 PM
Ranking
Ranking - avatar