<jupyter_start><jupyter_text>Adding parameters to functions MotivationIn the previous units you have seen that you can use functions with parameters. There are cases, where no parameter isneeded in a function, for example a function for some kind of greeting, which should always be the same. Or a functionwhich will write the current time in a predefined format to a terminal or a log.Parameters, however make it possible to customize these functions to your need. In case of the above examples, you couldadd a name to the greeting to personalize it or use a parameter in the *current time*-function to change the formattingof the output, e.g. 24h/12h format.  Parameters make it possible to *recycle* a function for different inputs and do the same operation on different values. Using parametersA function has an optional parameter list. This means that a function has either:- no parameter- one parameter- multiple parametersThe following cell contains examples of functions with different parameter lists.<jupyter_code>def the_answer_to_everything():
    return 42


print(
    "What is the Answer to Life, The Universe, and Everything?",
    the_answer_to_everything(),
)


def sum(a, b):
    return a + b


print("What is the sum of 39 and 3?", sum(39, 3))<jupyter_output><empty_output><jupyter_text>ExerciseNow it is your turn. Write a Python function that checks whether a given string is a[palindrome](https://en.wikipedia.org/wiki/Palindrome).  Examples of palindromes are Anna, Otto, racecar or 24742. Sopalindromes are words or phrases that read the same backward and forward.The return value of your function should simply be `True` or `False`, depending on whether the string passed as aparameter is a palindrome or not.  Default Values It is also possible to define default values for parameters. These default values are used if no value is passed for aparameter upon calling the function.The following example shows a function for multiplying a number by a certain factor. The parameter factor is set to thedefault value `2`. The function can now be called with or without passing the parameter factor.<jupyter_code>def multiply_with_factor(number, factor=2):
    return number * factor


print(multiply_with_factor(5))
print(multiply_with_factor(5, 3))<jupyter_output><empty_output><jupyter_text>So far, functions in our examples have been called by passing parameters according to the order of the parameter list.But Python also offers the possibility to address particular parameters using their names. Addressing function parameters using their names makes especially sense if it is combined with standard values. A goodexample for this are the parameters of the `print()` function already mentioned. You can access the `docstring` offunctions in Jupyter Notebooks pretty easily by entering the function name (without brackets!) followed by a "?" into acell and executing it:<jupyter_code>print?<jupyter_output><empty_output><jupyter_text>Otherwise in the [Python Standard library](https://docs.python.org/3/library/functions.htmlprint) it is defined asfollows:```print(* objects, sep = ' ', end = '\n', file = sys.stdout, flush = False)```The `print()`function defines the parameters `sep` and `end`, with the default values `' '` and `'\n'` respectively. Fornow, we are ignoring the other parameters.  Using the parameter `sep` we can provide a different separator for the parameters of the `print()` function.  Using the `end` parameter, we can provide a different value to end the line (instead of the[newline](https://en.wikipedia.org/wiki/Newline) escape sequence). Of cause, its also possible to combine both.<jupyter_code>print("Happy", "Python", "programming")
print("Happy", "Python", "programming", sep=" 🐍 ")

print("Happy", "Python", "programming", end=" 👍")
print()
print("Happy", "Python", "programming", end=" 👍", sep=" 🐍 ")<jupyter_output><empty_output><jupyter_text>Appendix: Escape charactersTo be able to display some special characters in Python, there are so-called[escape characters](https://docs.python.org/3/reference/lexical_analysis.htmlstring-and-bytes-literals).These are introduced with a backslash `\` and have special[meanings]((https://www.w3schools.com/python/gloss_python_escape_characters.asp)) (table not complete):| Character | Meaning              || --------- | -------------------- || `\n`      | Line break, new line || `\t`      | Tabulator            || `\"`      | Quotation mark       |A short addition to the last entry in the table: If you want to make a quotation mark in a string, you can use this.Quiz question: Why is the `0` of the second loop placed behind the numbers of the first loop? How can this be changed?<jupyter_code>for i in range(5):
    print(i, end=" ")

for i in range(5):
    print(i, end="\n\n")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.089059580651858, 'fraction_numerical': 0.005812746522731991, 'mean_word_length': 4.804819277108434, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 5, 'lorem ipsum': 0, 'www.': 1, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '607286', 'license': 'CC0-1.0', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1238, 'n_words': 602, 'path': 'week_5/week_5_unit_3_addparameter_notebook.ipynb', 'repo_name': 'ceedee666/opensap_python_intro', 'size': '4817'}