Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8570495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:34:17+00:00 2026-06-11T18:34:17+00:00

I have a couple of functions which calculates different statistical data based on input

  • 0

I have a couple of functions which calculates different statistical data based on input dictionaries, e.g. max, min, sum, average, median.

I would like to combine all these functions into one instead of having them in different methods. so the caller can do something like below:

(minValue, averageValue, maxValue) = myFunction(min, avg, max, data, key, ...)

or

(minValue, maxValue) = myFunction(min, max)

I am new to python, I am trying to understand how this can be achieved using sets!
Please do not suggest other ways of solving this problem, as I am trying to learn python and python syntax as well. A small example would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:34:18+00:00Added an answer on June 11, 2026 at 6:34 pm
    def myFunction(data,*args):
        return tuple( f(data) for f in args) )
    

    So for example:

    myFunction(data, min, avg, max)
    # returns (min(data), avg(data), max(data)), and you can get them by
    minValue, averageValue, maxValue = myFunction(data, min, avg, max)
    

    If you want to include key:

    def myFunction2(data, *args, **kwargs):
        if 'key' not in kwargs:
            kwargs['key'] = lambda x: x # identity map (pass without a key)
        return tuple( f(data, key=kwargs['key']) for f in args )
    

    So for example:

    myFunction2(['a','bc','f'], min, max)          # ('a', 'f')
    myFunction2(['a','bc','f'], min, max, key=len) # ('a', 'bc')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code in a couple of different functions that looks something like
I have a couple of cumulative empirical density functions which I would like to
I have a couple of classes which functions are execute SQL statements against a
I have a couple of fairly simple javascript functions which animate the transition of
Based on this tutorial I have built a page which functions correctly. I added
I have a couple functions like this: object obj.getChild(childIndex) int obj.numChildren() So I am
I have a couple of functions inside a class that essentially do the same
I have the following couple of C pre-processor macros for creating test functions: //
I have a C program with a couple of static functions that are not
I have couple of dozen pieces of data that I need to save and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.