Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arithematic average
#5
(Nov-17-2023, 01:20 PM)deferender Wrote: Now im fine.

doing this.

def find_average(num_a: int, num_b: int) -> float:
    average = (num_a + num_b) // 2
    return average

print(find_average(18, 8))
Thank you all!

That's fine, but it's not at all flexible. What if you have more than two numbers? The main points about coding a function, is that said function should do as its name suggest and be useful for more than one particular circumstance.

In fact, what you have there does not even work correctly.
Sig:
>>> import this

The UNIX philosophy: "Do one thing, and do it well."

"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse

"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
Reply


Messages In This Thread
Arithematic average - by deferender - Nov-17-2023, 10:58 AM
RE: Arithematic average - by rob101 - Nov-17-2023, 11:15 AM
RE: Arithematic average - by Larz60+ - Nov-17-2023, 11:22 AM
RE: Arithematic average - by deferender - Nov-17-2023, 01:20 PM
RE: Arithematic average - by rob101 - Nov-17-2023, 02:41 PM
RE: Arithematic average - by deanhystad - Nov-17-2023, 05:10 PM
RE: Arithematic average - by deferender - Nov-17-2023, 08:39 PM
RE: Arithematic average - by Pedroski55 - Nov-18-2023, 10:51 AM

Forum Jump:

User Panel Messages

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