We will more about functions and modules in later sessions. Our Python tutorials will cover all the fundamental concepts of Python. This makes Python a great language to learn for beginners. Fortunately for beginners, Python has a simple, easy-to-use syntax. It is used in machine learning, web development, desktop applications, and many other fields. ![]() ![]() In our example, print function takes the string as the argument and displays it. Python is a popular general-purpose programming language. 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. 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: 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. |