# Homework 2, Question 3 (Median)

 0 Hello everyone, I wasn't going to post anything regarding this question -although it was graded as an incorrect answer- as i haven't used any of the predefined procedures. But i saw allot of posts answering the same questions and they did not use any of the predefined procedures (bigger & biggest) and there answers were somehow correct while mine wasn't!, although i have tested the code repeatedly and it was working correctly. This is my code if anyone finds anything wrong with it please let me know. def median(a,b,c): if a < b and c > b or c < b and a > b: med = b if c < a and b > a or b < a and c > a: med = a if b < c and a > c or a < c and b > c: med = c return med print median(67,98,45)  Mind you there weren't any instructions that we must use the 'bigger' or 'biggest' procedures. asked 08 Mar '12, 17:21 AlKhozaee, B... 13●1 accept rate: 0% Anton Golov ♦ 13.3k●21●74●174

 3 Did you test it on repeated values such as (2,1,1)? It gets to return med without having assigned a value to med. answered 08 Mar '12, 17:24 fnenu-1 ♦♦ 18.5k●19●81●231
 2 Your code does not consider the case where any of the numbers are identical. Ex: (1, 1, 2). answered 08 Mar '12, 17:22 David Harris 8.1k●21●55●111 How on earth didn't i think of that? I can't believe that it slipped my mind! Thanks for the quick reply. (08 Mar '12, 17:28) AlKhozaee, B...
 0 same happened to me code worked "perfect" - but I forgot to test the case when 2 numbers a re equal. did that now (after it all was graded) and yes, my code gives out the wrong answer for that case. sigh my code was sooo simple :P def median(a,b,c): if a
Question text:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

×15,274
×1,718
×76
×43