Categories
Computer programming

Dealing with functions in python.

Functions or sometimes called as subroutines are important part of any computer language. Python is not an exception.

Function can be defined as program within a program.

like any program, functions must have three parts that is Input-Process-Output. In addition to this function must have a name.

In a typically written python functions look like this:

def name(input) :

BLOCK

return (output)

here name is whatever name you may give. Input is a comma seperated list of variables. Output is a single variable (can be list)

suppose we are designing singly reinforced rcc beam the function may look like.

def ast(moment, b,d, fck,fy):

steel=formula

return steel

Calling a function.

in your main program you can call a function in following way.

Steel=ast(650,230,900,25,500)

Exercise: write a function to find reinforcement.

Leave a Reply

Your email address will not be published. Required fields are marked *