We will more about functions and modules in later sessions. ![]() In our example, print function takes the string as the argument and displays it. Like for sin(x) function, we need to pass an argument which is the measure of an angle sin(x).įunctions may take more than one argument also. There are three types of Python functions:Ī) Python build-in functions: They come with Python itself and you can use them directly like print.ī) Python modules – They also come with Python but to use them, you need to import them from their parent space like ‘sin’, ‘cos’ etc.Ĭ) User-Defined Functions – Functions which a user can code themselves like finding the speed of a vehicle if we know the distance travelled in time.įunctions may take arguments to evaluate something. ![]() ![]() There are functions which can perform both the above activities also. With this skill youll be able to write and build complex and powerful Python programs. Generally, a Python function performs two activities:Ī) Cause some effect – like print functionī) Evaluates some value – like sum, sin, cos which we will see later Python function is a piece of code that performs some action or causes some effect. Let’s put some attention and time to see what functions are: Speed up programming with in-line prompts, auto-indentation, intuitive prompts and more to assist new and experienced coders. ![]() It takes the string as an input/argument and displays the string on the console. So print is a function that displays the desired result for you.
0 Comments
Leave a Reply. |