Modules/PythonCrashcourse
Verfasst: Freitag 19. April 2019, 09:09
Hi ich bräuchte mal eure hilfe undzwar versteh ich dass nicht ganz so richtig
8-17. Styling Functions:Choose any three programs you wrote for this chapter,
and make sure they follow the styling guidelines described in this section .
Undzwar solle ich meine funktionen stylen dies hab ich denke ich mal gemacht ist dies den richtig
def make_shirt(size, text='I like you'):
""" make a shirt """
print("I make a shirt with the size " + size.title())
print("I will say " + text.title())
make_shirt('medium')
make_shirt(size='large')
styling functions
Every function should have a comment that explains concisely what
the function does. This comment should appear immediately after the
function definition and use the docstring format. In a well-documented
function, other programmers can use the function by reading only the
description in the docstring. They should be able to trust that the code
works as described, and as long as they know the name of the function,
the arguments it needs, and the kind of value it returns, they should be
able to use it in their programs.
If you specify a default value for a parameter, no spaces should be used
on either side of the equal sign:
def function_name(parameter_0, parameter_1='default value')
The same convention should be used for keyword arguments in function calls:
function_name(value_0, parameter_1='value'
Dies versteh ich garnicht wie will es den gehen einfach so in der funktion einen wert einzugeben ohne eine zuweisung ?
mfg
fakhro
8-17. Styling Functions:Choose any three programs you wrote for this chapter,
and make sure they follow the styling guidelines described in this section .
Undzwar solle ich meine funktionen stylen dies hab ich denke ich mal gemacht ist dies den richtig
def make_shirt(size, text='I like you'):
""" make a shirt """
print("I make a shirt with the size " + size.title())
print("I will say " + text.title())
make_shirt('medium')
make_shirt(size='large')
styling functions
Every function should have a comment that explains concisely what
the function does. This comment should appear immediately after the
function definition and use the docstring format. In a well-documented
function, other programmers can use the function by reading only the
description in the docstring. They should be able to trust that the code
works as described, and as long as they know the name of the function,
the arguments it needs, and the kind of value it returns, they should be
able to use it in their programs.
If you specify a default value for a parameter, no spaces should be used
on either side of the equal sign:
def function_name(parameter_0, parameter_1='default value')
The same convention should be used for keyword arguments in function calls:
function_name(value_0, parameter_1='value'
Dies versteh ich garnicht wie will es den gehen einfach so in der funktion einen wert einzugeben ohne eine zuweisung ?
mfg
fakhro