Simple Function in Python
Level 364 keystrokes
This defines a function that returns a greeting and prints 'Hello, Alice!'. Functions encapsulate reusable code.
Python code
# def keyword defines a new function# greet is the function name, name is the parameter (input)1def greet(name): # return sends a value back to where the function was called # f-string creates the greeting with the name embedded2 return f"Hello, {name}!"3 # Call the function with "Alice" as argument# The returned string is passed to print()4print(greet("Alice"))Output
Hello, Alice!
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
"× 4(× 3)× 3,× 1:× 1!× 1{× 1}× 1