Trying to wrap my head around python functions

I'm trying to print:

gibberish1
2

by using multiple functions.

I'm not sure in what way the functions should be called, what arguments said call(s) would require or the parameters I need for the functions in the scenario below.

__

How do I go about utilizing both functions in the following case?

def function_one():
    variable_one = 1
    variable_two = 2
    return variable_one, variable_two


def function_two():
    use_function_one_variable = 'gibberish' + str(variable_one)
    print(use_function_one_variable)
    print(variable_two)

The following code snippet:

def function_one():
    variable_one = 1
    variable_two = 2
    return variable_one, variable_two


def function_two():
    variable_one, variable_two = function_one()
    use_function_one_variable = 'gibberish' + str(variable_one)
    print(use_function_one_variable)
    print(variable_two)

function_two()

produces your desired output:

gibberish1
2

I can't wrap my head around functions, especially the "return", I can't wrap my head around functions, especially the "return" statement. (python). I've been studying python for a week now, and this has me really frustrated. To set the scene, the young and foolishly optimistic beginner developer tries his  That said, I'm trying to wrap my head around python and have a couple questions with classes and functions. Two notable questions: 1) Classes. How do you extend classes? I know its as easy as: class classname(a) do stuff But where does the parent class need to lie? In the same file? Can it lie in another .py file in the root directory? Can it

From function_two(), you have to call function_one():

def function_two():
    v1, v2 = function_one()
    use_function_one_variable = 'gibberish' + str(v1)
    print(use_function_one_variable)
    print(v2)

Python 3 OOP wrapping my head - Python, Hiya First off, massive fan of the python 3 book. I'm currently on ex_43 and I'm finding it difficult to wrap my head around Object Oriented  I'm trying to wrap my head around OOP but so far I feel like I'm just moving functions into classes and calling them methods. I am trying to create a "Rock Paper Scissors" game using OOP best practices.

def function_one():
    variable_one = 1
    variable_two = 2
    return variable_one, variable_two


def function_two():
    print_this_one, print_this_two = function_one()
    print_this_one += 'gibberish'
    print_this_two += 'more gibberish'
    print(print_this_one)
    print(print_this_two)

Frank Kane's Taming Big Data with Apache Spark and Python, Our lambda function takes in two values, shown as x and y, and says how do we entries per age; even I had a hard time wrapping my head around this at first. I’ve been really trying over the past year to wrap my head around python but thought I would never get it after trying a bunch of boring online courses. I recently got the book “Automate the boring stuff with python” (I’m about half way through) and it made me start thinking about things totally differently.

IIUC

If you want a function that prints just gibberish1, then you can do the following:

def gib():
    print('gibberish1')

Then if you type gib() it'll print what you're looking for.

If you want a function that prints a 2, you do basically the same:

def two():
    print(2)

If you want a function that concatenates both you need your number to be a string.

def gib2():
var1='gibberish1'
var2='2'
    print(var1+var2)

I can not do any of those kind of programming questions, include , Ok guys, I am stuck here again, have tried learning many different languages and each time I though the basics of OOP concepts many times, I still can't wrap my head around how to use a loop properly. This is my explanation of for loops in python (and pretty much most other languages). Functions have similar effect. I'm trying to wrap my head around using Jupyter notebooks for Python because so many of the machine learning examples use Jupyter notebooks. I, however, am used to having my Python scripts in a python folder on my Windows machine and then running the scripts when necessary with IDLE.

Each function has it's own local scope, so generally speaking, variables defined in that function can only be accessed from within it. One way around this is to pass the variables out of the function using return, which you're doing here.

In your code, when you call function one, it will return a tuple with variable_one and variable_two. To access those from function_two, you can call function_one from within it like so:

 def function_two():
    variable_one, variable_two = function_one()
    use_function_one_variable = 'gibberish' + variable_one
    print(use_function_one_variable)
    print(variable_two)

Java dev learning Python: what concepts do I need to wrap my head , Passing functions as parameters, returning them and assigning to variables is an instance method as if it were a regular function, pass it around, etc. Due to the fully dynamic nature of Python, you have nearly no static checks. Don't try to speed up a computational task by running it in parallel threads. I’ve been really trying over the past year to wrap my head around python but thought I would never get it after trying a bunch of boring online courses. I recently got the book “Automate the boring stuff with python” (I’m about half way through) and it made me start thinking about things totally differently.

Java dev learning Python, Having just functions (and no classes) in a module is perfectly fine. functions; you can handle an instance method as if it were a regular function, pass it around​, etc. Due to the fully dynamic nature of Python, you have nearly no static checks. Don't try to speed up a computational task by running it in parallel threads. I am trying to wrap my head around a piece of code from a text. Its a prelude to decorators, and apparently crucial to an understanding of them. But the example is rudimentary: from time import sleep, time def f(): sleep(.3) def g(): sleep

Cant wrap my head around Word Blanks - JavaScript, Dont know what needs to be done function wordBlanks(myNoun, myAdjective, myVerb, Cant wrap my head around Word Blanks Thinking thats how its done because im pretty sure i seen it like that, i will try re do it now! 2019 Web Developer Roadmap Python Tutorial CSS Flexbox Guide JavaScript Tutorial Python  Hi all, I'm trying to wrap my head around 'importing libraries' and ' pip'. It's one the things most tutorial just breeze by at the beginning. What exactly is the difference between 'pip' and 'import' TBH, I don't really understand it and I'll like to know it on a conceptual level.

Tkinter GUI Programming by Example: Learn to create modern GUIs , Python uses a method called __init__ in order to initialize each instance of a class. The easiest way to wrap your head around using classes is to see an The print function itself has been reused but has produced a slightly different  Extremely new to Python, in need of help for clarification of functions (self.learnpython) submitted 7 hours ago by Sirxi I've been trying to get into Python and have watched about ten hours of tutorials and courses on it.

Comments
  • Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license, for SE to distribute that content (i.e. regardless of your future choices). By SE policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: How does deleting work? ...
  • You can check by print(type(function_one())) that function_one() returns a tuple. Hence you can access any of its return values by indexing: e.g. the variable_one return value is accessed with function_one()[0], while the variable_two return value is accessed with function_one()[1].