I am a first time user, but need some urgent simple help.
I have information that is local to a function,but I want to use this information in another function called getInput. I will show example below. I have tried placing information in main, but it keeps coming up with nameA not defined.
nameA and name B appear in the printIntro, and I have obtained these values from raw_input, and they are included in print statements and work fine.
I wish to include these values in getInput()
in a print statement
print nameA "has a probability of", a (a and b are local to the getInputs)
print nameB "has a probability of", b
Bartonc or anybody else can you help
Thanks Jen
5 6203
Hi America,
Welcome to TSDN. I'm sure you will find a wealth of information available in the various forums. These can be found by selecting a link to a drop-down list on the blue menu bar near the top of the screen. Unfortunately, I am not sure of the language you are using and can't redirect this post.
I hope the experts in the relevant forum can assist with your enquiry.
Hi,
Thanks for reply.
I am using Python Programming.
Bartonc will be your man (as you suggested earlier)......
I will move this to the Python Forum and alert him to it.....
Bartonc will be your man (as you suggested earlier)......
I will move this to the Python Forum and alert him to it.....
Thanks for your efficiency.
bvdet 2,851
Expert Mod 2GB
I am a first time user, but need some urgent simple help.
I have information that is local to a function,but I want to use this information in another function called getInput. I will show example below. I have tried placing information in main, but it keeps coming up with nameA not defined.
nameA and name B appear in the printIntro, and I have obtained these values from raw_input, and they are included in print statements and work fine.
I wish to include these values in getInput()
in a print statement
print nameA "has a probability of", a (a and b are local to the getInputs)
print nameB "has a probability of", b
Bartonc or anybody else can you help
Thanks Jen
I am not sure what you are trying to do because you did not show us much of your code. I would suggest that you try returning values from one function into another function as arguments: - def printIntro(a,b):
-
nameA = 'Case 1'
-
nameB = 'Case 2'
-
print nameA, "has a probability of", a
-
print nameB, "has a probability of", b
-
-
def getInput():
-
a = 0.75
-
b = 0.5
-
return a, b
-
-
if __name__ == '__main__':
-
printIntro(*getInput())
Sign in to post your reply or Sign up for a free account.
Similar topics
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {...
|
by: jr |
last post by:
Sorry for this very dumb question, but I've clearly got a long way to go!
Can someone please help me pass an array into a function. Here's a starting
point.
void TheMainFunc()
{
// Body of...
|
by: jeffg |
last post by:
The answer probably is staring me in the face and I don't see it, so
I'll just ask.
I try to limit the scope of variables and avoid global variables. But
sometimes I get stumped by the following...
|
by: Gregory Piñero |
last post by:
Hey guys, would someone mind giving me a quick rundown of how
references work in Python when passing arguments into functions? The
code below should highlight my specific confusion:
<code>
...
|
by: zholthran |
last post by:
Hi folks,
after reading several threads on this issue (-> subject) I fear that I
got a problem that cannot easily be solved by the offered workarounds
in an acceptable way, at least not with my...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |