I'm pretty new to python, and I'm currently having problems carrying a value inside a function, to be used again by another function.
I'm not sure if that make sense, and I don't really have a good simple example, sorry.
And since I'm totally new to programming I might just be misunderstanding what a function really does.
3 1586 bartonc 6,596
Recognized Expert Expert
I'm pretty new to python, and I'm currently having problems carrying a value inside a function, to be used again by another function.
I'm not sure if that make sense, and I don't really have a good simple example, sorry.
And since I'm totally new to programming I might just be misunderstanding what a function really does.
I hope this helps with some basic understanding of the way functions work: - # functions receive values in the parameters given in the fuction call
-
# and return values that they produce using the return statement
-
-
def Add(x, y):
-
return x + y
-
-
def Multiply(a, b):
-
c = a * b
-
return c
-
-
d = Add(1, 2)
-
print d
-
-
e = Multiply(d, 6)
-
print e
I hope this helps with some basic understanding of the way functions work: - # functions receive values in the parameters given in the fuction call
-
# and return values that they produce using the return statement
-
-
def Add(x, y):
-
return x + y
-
-
def Multiply(a, b):
-
c = a * b
-
return c
-
-
d = Add(1, 2)
-
print d
-
-
e = Multiply(d, 6)
-
print e
Yes, that really helped thanks, program works fine now : D.
I didn't actually know you could assign a variable to a function.
bartonc 6,596
Recognized Expert Expert
Yes, that really helped thanks, program works fine now : D.
I didn't actually know you could assign a variable to a function.
I remember programming in Pascal. Back then we were force to make a distinction between functions and procedures. For Python this is not so. But there some little pieces of trivia that is good to know... - When a function (or method of an object) does not explicitly return a value, Python automatically returns None.
- Even if a function returns a value you are not require to assign it to a variable.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ralph Freshour |
last post by:
I was reading about PHP variable scoping - it doesn't seem to support
carrying any variables from one web page to another - how is this
usually done? I have a lot of php variables created on my...
|
by: G |
last post by:
Hello,
Is it possible to send form values from PAGE1 to PAGE2, and then retain the
form info for PAGE3 without using cookies, sessions or DB storage? Also, I
dont want to repost page2 to page3...
|
by: Richard |
last post by:
My employer currently pays me $1/hour when I carry a pager. I have to
carry the pager every fourth week. The problem is that my employer
insists that I be available when I'm carrying the pager. ...
|
by: Ivan Shevanski |
last post by:
Alright heres my problem. . .Say I want to carry over a variable from one
function to another or even another run of the same function. Is that
possible? Heres a quick example of what I'm talking...
|
by: Ani |
last post by:
Hi,
I need to carry the user input across pages and then at
the end insert all the values into the DB. How do I best
accomplish this task in ASP.Net. I am a novice , please
give me some simple...
| |
by: Matt |
last post by:
I have the following in a page and I am trying to update a record on
the next page but for some reason the form data is not carrying over.
Any ideas why?
<form name=nxtlupdate method=post...
|
by: devonknows |
last post by:
Hi, im having trouble carrying variables across a form, ive looked on here and other sites but cant find anything that helps me, or i might not be searching for the right terms, so i though i would...
|
by: Kurrent |
last post by:
I have some data from text fields that are being passed over through a
form that I am displaying with the $_POST superglobal. Once i have
echo'd out this data onto the next page, i'd like to...
|
by: Jeff |
last post by:
I've been struggling with this for a while.
Here's what I'm trying to do:
private function makeMiniTemplate($ARRAY){
/*
$ARRAY looks like this:
$ARRAY='Some Value';
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |