<jupyter_start><jupyter_text>Use parameters to specify variability in functionsAnother interesting aspect of functions is that variables created inside them exist only inside the function. For example, this code would fail because we create the rocket_number variable inside the function`and then try to use it outside the funciton. Python doesn't know about that variable outside the funciton so it will produce an error.<jupyter_code>def output_rocket_text():
    rocket_number = 1
    print("Rocket will launch soon!")

output_rocket_text()
print(rocket_number)<jupyter_output><empty_output><jupyter_text>Along with this, if you have variables created outside a function you can access them inside a function but you can't change them.<jupyter_code>rocket_text = "We will launch in"
def output_rocket_text():
    rocket_text = rocket_text + " two days"

output_rocket_text()<jupyter_output><empty_output><jupyter_text>As you can see, this cod eproduces an error as well, because we are trying to modify a variable that was created outside a function.To combat this, we can do one of two things:- Make a variable a global variable- Give a variable to the function, so it knowns what the variable is and then return itThe easiest weay to change the value of a variable inside a funciton is to make it a global variable. Everything in the program can modify a global variable, even if it is modified inside a function. To make a somethin a gloval variable, you must make a variable before you call the function and then include a line in your function that gives the global variable name:<jupyter_code>rocket_text = "We will launch in"

def output_rocket_text():
    global rocket_text
    rocket_text  = rocket_text + " two days"

out_rocket_text()
print(rocket_text)<jupyter_output>We will launch in two days<jupyter_text>Another way to modify variables inside a function is to use parameters. Parameters are when you give a function knowledge of a variable when you call it. To tell Python you want your functions to have parameters, use the following code:<jupyter_code>def output_rocket_text(text_input):
    text_input = text_input + " two days"
    return text_input

rocket_text = "We will launch in"
new_rocket_text = output_rocket_text(rocket_text)
print(new_rocket_text)<jupyter_output>We will launch in two days
{'fraction_non_alphanumeric': 0.04735256134309083, 'fraction_numerical': 0.00043047783039173483, 'mean_word_length': 5.402203856749312, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '358349', 'license': 'MIT', 'n_tokens_mistral': 646, 'n_tokens_neox': 631, 'n_words': 304, 'path': 'code_control_statements/parameters_in_functions.ipynb', 'repo_name': 'Jeffresh/Discover-role-python-space-exploration', 'size': '2323'}