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 7563911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:47:06+00:00 2026-05-30T13:47:06+00:00

Given a function: def A(a, b, c): a *= 2 b *= 4 c

  • 0

Given a function:

def A(a, b, c):
    a *= 2
    b *= 4
    c *= 8
    return a+b+c

How can I set the ‘c’ var to be called-by-reference, so if i call d = A(a,b,c), c will point to the same int object, and be updated from within the function?

  • 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-05-30T13:47:07+00:00Added an answer on May 30, 2026 at 1:47 pm

    You’re getting into murky territory: you’re talking about declaring global (or nonlocal) variables in functions, which should simply not be done. Functions are meant to do one thing, and do them without the consent of other values or functions affecting their state or output.

    It’s difficult to suggest a working example: are you alright with having copies of the variables left behind for later reference? You could expand this code to pass back a tuple, and reference the members of the tuple if needed, or the sum:

    >>> def A(a, b, c):
            return (a*2, b*4, c*8)
    
    >>> d = A(2, 4, 8)
    >>> sum(d)
    84
    >>> d[-1] #or whatever index you'd need...this may serve best as a constant
    64
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a function object, how can I get its signature? For example, for: def
Please tell me what will the call to given function return and how? The
How do I call the correct overloaded function given a reference to an object
Given the following function: def foo(a, b, c): pass How would one obtain a
Given that a function a_method has been defined like def a_method(arg1, arg2): pass Starting
Given a function, let's say atoi, how can I find the header file I
I wrote a function like def cmd_run(host=localhost, port=8000): Run server at given host port
I am looking to replicate a given object function across various model files As
How can I bind arguments to a Python function so that I can call
if i have a function A,which can apply a certain rule on a given

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.