Jun-22-2019, 06:23 PM
Greetings everybody,
First off, I'm a 71 year old retired male at home trying to learn python. No schools involved. I just thought this was the best forum to start. I'm using a book to study with. I’m running
MX Linux on a dell laptop. Python 3.5
I did this:
This is what it looks like:
{python} def myfuncttion( parameter1, parameter2 ):
return answer1, answer2, answer3
variable1, variable2, variable3 = myfunction(argument1, argument2)
I would like to know how to enter the cats names and get this function running.
I've tried running this thing about 20 different ways with different variable names and positions in the code.
I would just kike to learn how to do this, If i'm being a pain it probably isn't that important.
Thank you tofif
First off, I'm a 71 year old retired male at home trying to learn python. No schools involved. I just thought this was the best forum to start. I'm using a book to study with. I’m running
MX Linux on a dell laptop. Python 3.5
I did this:
def exponents( num1, num2, num3 ): answer1 = num1 * num1 answer2 = num2 ** 3 answer3 = num3 ** 4 return answer1, answer2, answer3 userNumber1 = input( "Enter a number: \n" ) userNumber2 = input( "Enter a number: \n" ) userNumber3 = input( "Enter a number: \n" ) userNumber1 = float( userNumber1 ) userNumber2 = float( userNumber2 ) userNumber3 = float( userNumber3 ) numberExponentiated = exponents( userNumber1, userNumber2, userNumber3 ) print( " The result of your Exponential Machinations is:", numberExponentiated ) # Not sure " Exponentiated " is the right word, but it works.It took me 5 minutes to do it. I'm trying to do the same thing using strings/text.
This is what it looks like:
def cat_names( str1, str2, str3 ): catName1 = input( "What was your first cats name:\n" ) catName2 = input( "What was your second cats name:\n" ) catName3 = input( "What was your third cats name:\n" ) names = catName1, catName2, catName3 return names print( "My first three cats were named:", str1 , str2, "and", str3 ) cat_names( str1 , str2, str3 )I had no problem with the math function, but I've been playing with this one for a week and have no idea why I get this error message:
Traceback (most recent call last): File "/home/Tofif/Documents/save to solve/cats.py", line 20, in <module> print( "My First 3 cats were named:", catName1, catName2, catName3 ) NameError: name 'catName1' is not definedIsn't catName1 defined in the user input request? I'm being totally blindsidded by this, and have no idea how to solve it. This was an example in my book, and this is what was stated:
{python} def myfuncttion( parameter1, parameter2 ):
return answer1, answer2, answer3
variable1, variable2, variable3 = myfunction(argument1, argument2)
I would like to know how to enter the cats names and get this function running.
I've tried running this thing about 20 different ways with different variable names and positions in the code.
I would just kike to learn how to do this, If i'm being a pain it probably isn't that important.
Thank you tofif