Skip to content
← Back to Community
Help me to solve this problem.
Profile icon
ruchiyadav

A python script to print the docstring(documentation string) of the input function?

Answered by ash15khng [earned 5 cycles]
View Answer
Voters
Profile icon
MAISHASIMI
Profile icon
MikayelSargsyan
Profile icon
YousefAhmed8
Profile icon
SimranBisWas
Profile icon
ruchiyadav
Comments
hotnewtop
Profile icon
ash15khng

You can get the docstring of a function by calling its __doc__ property (there are 2 underscores). An example:

def function(): "This is the docstring of the function" print("abcd") function() # prints abcd print(function.__doc__) # prints this is the docstring.....
Profile icon
ruchiyadav

I cleared my hands on with this help. thank you @ash15khng

Profile icon
ash15khng

@ruchiyadav Nice! Would you mind marking my comment as the answer? Thanks!

Profile icon
nj2079

@ash15khng , @ruchiyadav - can you help me to solve this hands on - its weird - not sure why I am missing

Profile icon
oshiva

how did u do it?? @ruchiyadav

Profile icon
ReshmaGadde1

@ruchiyadav will you share me the exact answer please to solve the handson

Profile icon
PaoloAmoroso

Here's a starting point:

def print_docstring(obj): """Print the docstring of the argument.""" docstring = obj.__doc__ if docstring: print(docstring) else: print('NO DOCSTRING')
Profile icon
MAISHASIMI

Write an input statement that asks the user for their name and stores it in a variable.

Profile icon
MAISHASIMI

Today you will build an app that helps students calculate their semester average for a class given three marking period grades. Read the directions and type each line of code below the corresponding commented instruction.

Write a print statement that tells the user about the purpose of this app

Profile icon
YousefAhmed8

how can i find the right algorithm for this code

Profile icon
NareStepanyan

How do you define a problem statement (English) with user input, user output, Tuple, conditionals and mathematical computation and solve this problem using Python.

Profile icon
oshiva

PLEASE HELP

Problem Statement
Write a python script to print the docstring(documentation string) of the input function.

Instructions
Open the app.py file using vim editor vim app.py.
Press i to insert content in the file.
Write the required python code.
Press the Esc key, and type :wq in the editor to save the file.
Execute the script with command python3 app.py | tee output.txt.
Hint:
use help() function to get the docstring

help()

Welcome to Python 3.6's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at https://docs.python.org/3.6/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics". Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

Profile icon
VaradarajamMadd

What is the correct answer for Write a python script to print the docstring(documentation string) of the input function.?

can u plz help me