473,396 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to get the middle value of a list in python?

1
how to get the middle number when,
1.the list have even number of values
2.the list have odd number of values
Nov 11 '12 #1
1 25486
bvdet
2,851 Expert Mod 2GB
Are you looking for the median? There are two middle numbers when there is an even number of values.

The median is the middle number of a sorted list of numbers. If the list has an even number of values, the median is calculated as the average of the two middle numbers.

The middle number of a list named "s" with an odd number of values is returned by
Expand|Select|Wrap|Line Numbers
  1. s[len(s)/2]
I will leave it to you to determine the other condition. Hint: You can use the modulo operator (%) to determine if the list has an even or odd number of values.
Nov 11 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: KT | last post by:
This might not be possible, but on the chance that it can - is there a way to do the following: Given a arbitray one dimesional value list: ('AALGX','12345','XXXXX','AAINX','AMMXX') Is there...
2
by: Mark | last post by:
Hello. I am using an Access listbox with RowSourceType set to "Value List." Some of the values that I want to add to the list contain characters that are interpreted as list delimiters when I...
2
by: sideejay | last post by:
I added some items to my value list in a table but I noticed the value list in the form did not get updated. Why is that? I would have figured they would have a relationship. It is a music...
1
by: de_ja | last post by:
HI, Thanks for assisting me with my previous query. I have almost completed my access database. And now in the process of optimising it. When I first developped the database I had...
2
by: emrodge | last post by:
Hi, I have a field which stores Client names, it is a lookup to a value list. There are around 100 client names currently and I can't seem to add any more values. Within 'Edit list items' the text...
2
by: Otter7 | last post by:
Hello! I am a beginner with MS Access 2007. Creating a complex DB and need assistance on lookup columns created through Lookup Wizard with Allow Edits in table field. When a user enters a new value...
0
by: bullfrog83 | last post by:
I'm working in an Access project (.adp) that's linked to a SQL Server db. What I can't get to work is the Allow Value List Edits option for a combobox. It works fine in a .accdb file. However, even...
8
by: Justin Ziegler | last post by:
and i want to assign these values to variables, but i want to assign the number with the middle VALUE, how do i go about doing that?
1
by: Yousaf Shah | last post by:
Hello everybody Suppose we have two bound combo boxes, "PositiveGPE_Finding" and "Lymphnode_Gp" respectively, in form named "History". "PositiveGPE_Finding" combo box have value list with Multiple...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.