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

  • Home
  • SEARCH
  • 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 6642651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:57:21+00:00 2026-05-25T23:57:21+00:00

Lets say I define a simple function which will display an integer passed to

  • 0

Lets say I define a simple function which will display an integer passed to it:

def funct1(param1):
    print(param1)
    return(param1)

the output will be the same but and I know that when a return statement is used in a function the output can be used again. Otherwise the value of a print statement cannot be used. But I know this is not the formal definition, Can anyone provide me with a good definition?

  • 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-25T23:57:22+00:00Added an answer on May 25, 2026 at 11:57 pm

    Dramatically different things. Imagine if I have this python program:

    #!/usr/bin/env python
    
    def printAndReturnNothing():
        x = "hello"
        print(x)
    
    def printAndReturn():
        x = "hello"
        print(x)
        return x
    
    def main():
        ret = printAndReturn()
        other = printAndReturnNothing()
    
        print("ret is: %s" % ret)
        print("other is: %s" % other)
    
    if __name__ == "__main__":
        main()
    

    What do you expect to be the output?

    hello
    hello
    ret is : hello
    other is: None
    

    Why?

    Why? Because print takes its arguments/expressions and dumps them to standard output, so in the functions I made up, print will output the value of x, which is hello.

    • printAndReturn will return x to the caller of the method, so:

      ret = printAndReturn()

    ret will have the same value as x, i.e. "hello"

    • printAndReturnNothing doesn’t return anything, so:

      other = printAndReturnNothing()

    other actually becomes None because that is the default return from a python function. Python functions always return something, but if no return is declared, the function will return None.


    Resources

    Going through the python tutorial will introduce you to these concepts: http://docs.python.org/tutorial

    Here’s something about functions form python’s tutorial: http://docs.python.org/tutorial/controlflow.html#defining-functions

    This example, as usual, demonstrates some new Python features:

    The return statement returns with a value from a function. return without an expression argument returns None. Falling off the end of a function also returns None.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
Let's say I want to have a function which reads data from the SerialPort
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
Lets say that you have websites www.xyz.com and www.abc.com. Lets say that a user
Lets say I have the following code: abstract class Animal case class Dog(name:String) extends
Lets say I have several web sites on my web server, all as applications
Lets say on MySQL database (if it matters).
Lets say I've got two interchangeable pieces of code and I want to figure
Lets say I have an array like this: string [] Filelist = ... I
I'm building a simple game which consists of Mobiles -- the in-game characters (Mobs).

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.