For mean, another clean way to do this, without using a for loop would be: def mean(nums): return sum(nums) / len(sums) print(mean([2, 5, 9, 8, 6, 2, 5, 4])) # this will print the mean of this list of numbers. We defined a function called mean, and have a parameter of "nums" that will pass through it. We then used the return function to take the sum(nums) and divide them by the length(nums). Finally, we called the mean function with a random list of numbers! Should equal 5.25, or if you wanted only integers and no float (decimal numbers), you could add a second divide symbol .... return sum(nums) // len(sums) = 5
@parasthakur9842
Жыл бұрын
it showing type error
@AnilGupta-xc8pt
3 ай бұрын
Here sums is not defined 😅😅
@venkannababu1986
2 жыл бұрын
Here is the code for multiple modes in the list. def find_mode(list_n): #let convert list into sets so no duplicates new_set = set(list_n) new_list = list(new_set) counts = [] for i in range(len(new_list)): counts += [list_n.count(new_list[i])] max_count = max(counts) index = counts.index(max_count) print(new_list[index],end=" ") for i in range(index+1,len(counts)): if(max_count == counts[i]): print(new_list[i],end=" ") # Taking the input as integers using the map function list_n = list(map(int,input().split())) #calling function find_mode(list_n)
@almightysun7407
Жыл бұрын
Thanks this tutorial was so good and easy to understand! :)
@louierattatouie
2 жыл бұрын
Thank you so much for this tutorial! You are a great help! Definitely subscribing!
@vazhaabdu4529
4 жыл бұрын
Nice video,however,the code you wrote for fining mode will only work finding one mode.and in most cases there are multiple modes in lists.also if your list has same amount of different numbers(for example [2,2,3,3]) then it will still say that mode is 2 in this case when there is no mode.
@NOBODY-ye3px
4 жыл бұрын
could you pls write the code for the same , pls
@venkannababu1986
2 жыл бұрын
here is the code for the multiple modes in the list. def find_mode(list_n): #let convert list into sets so no duplicates new_set = set(list_n) new_list = list(new_set) counts = [] for i in range(len(new_list)): counts += [list_n.count(new_list[i])] max_count = max(counts) index = counts.index(max_count) print(new_list[index],end=" ") for i in range(index+1,len(counts)): if(max_count == counts[i]): print(new_list[i],end=" ") # Taking the input as integers using the map function list_n = list(map(int,input().split())) #calling function find_mode(list_n)
@engineer_story6198
2 жыл бұрын
Thanks for sharing video
@peddannaganjayela6779
3 жыл бұрын
If mode > 1 then it is not working
@nikhilmehra1216
5 жыл бұрын
thank you so much
@renee3901
2 жыл бұрын
IDK why you didn't show how to find median if we have 5 numbers / if there was one number in middle
@easydatascience2508
Жыл бұрын
see mine too. Most of the Python tutorials in the playlist. And R beginning course too.
@ladislousfarawadya5115
3 жыл бұрын
the program only shows one mode even if there are two, anyways thanks a lot
@borykalderassoumou1778
2 жыл бұрын
This mode coding is only for an unimodal distribution. How about a multimodal i.e bimodal?
@shobriarnanta1032
3 жыл бұрын
why the total = 0 in mean?
@srimanikanta3472
2 жыл бұрын
what we do, when we have execute more no of modes in a given list. how can we run
@guttamuneendra12339
2 жыл бұрын
How to print two modes in single line ( if Two modes in list)
@rinkirout2329
2 жыл бұрын
Not defined mean in median
@johnkiruba6236
4 жыл бұрын
How come the tuple values change once after declared? In a list of no recurring numbers how does the func returns the least value in the list? I mean where does the sort happen? Please Explain! thank you.
@bikramchettri9405
5 жыл бұрын
Hey how can we add input field dynamically ?
@PortEXE
5 жыл бұрын
You can use the input function! So if you were to say: user_string = input("Please enter a string: "), it would set whatever the user typed equal to the user_string variable.
@bikramchettri9405
5 жыл бұрын
@@PortEXE I'm talking about adding a dynamic input field to a form using add more field. Something like this oneway.cab/outstation.php
@paulmcgreevy4173
Жыл бұрын
can you show this while not using a cut and paste from another site? where would the numbers we want a mean, median and mode from be actually typed into the code and how?
@bilalwarsi33
4 жыл бұрын
what's that ' != 0 ' in the median part? I tried it out and it said invalid syntax, i need help, thanks.
@PortEXE
4 жыл бұрын
It means not equal. It’s likely something else that’s causing the error.
@bilalwarsi33
4 жыл бұрын
PortEXE thanks!
@majorgeneral2812
Жыл бұрын
You said simple? .......head explodes in shear stupidity.
@yohomietony3945
5 жыл бұрын
When I try the mode, the answer is always the first number in the list. Ex. (3,4,5,5,6) the mode should be 5 but it outputs 3. Could you see if it does the same thing for yours?
@yasaswinidesu2225
4 жыл бұрын
Keep the return statement at the end of the for loop. I guess you kept at the end of if statement
@aqua6150
4 жыл бұрын
@@yasaswinidesu2225 CAn you send the code to calculate mode please..
@aqua6150
4 жыл бұрын
@@yasaswinidesu2225 hey I am from cse-D
@elieledouxjobin163
3 жыл бұрын
it is no working
@elieledouxjobin163
3 жыл бұрын
yes
@elieledouxjobin163
3 жыл бұрын
^
@noufalsuhaim2728
3 жыл бұрын
what if i want to enter the size of the list and then enter my list and calculate it ?
Пікірлер: 37