Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Study Questions
#3
You are on the right track. The thing is, your function is returning a value, which can be used outside of the function but you need to have a variable to hold that value so that you can utilize it, say in a 'print()' function.

For example:
def sums(num1, num2):
    total = num1 + num2

    return total

answer = sums(5, 5)
print("Answer = ", answer)
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Messages In This Thread
Study Questions - by captainflint - Jan-31-2018, 03:09 PM
RE: Study Questions - by j.crater - Jan-31-2018, 04:09 PM
RE: Study Questions - by sparkz_alot - Jan-31-2018, 09:24 PM
RE: Study Questions - by captainflint - Feb-01-2018, 11:16 AM
RE: Study Questions - by Mekire - Feb-01-2018, 12:45 PM
RE: Study Questions - by captainflint - Feb-01-2018, 03:11 PM
RE: Study Questions - by gruntfutuk - Feb-01-2018, 06:01 PM
RE: Study Questions - by captainflint - Feb-02-2018, 12:27 PM
RE: Study Questions - by DeaD_EyE - Feb-02-2018, 12:55 PM

Forum Jump:

User Panel Messages

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