We take an example. Let’s assume you go to a new city and you need a hotel for a night's stay. You can ask the hotel manager about the room rent. You expect that if you are booking a room in a hotel, the bed with mattresses would be there. You further expect TV, carpet, washrooms, etc. You will probably not ask for the availability of these things from the hotel manager. If you have some special requirements, you will tell only those requirements to the manager like internet connectivity, room service for dinner, etc.
In the case of functions, they come with pre-defined features. They can do calculations or generate results as per your requirement but if you want, you can ask functions to customize some of the features.
Always keep in mind that inputs to the functions
are provided inside the brackets and are separated by commas.
In the first program, we had a print function and
the input to the print function was provided inside the bracket. Now, if we
want to print multiple lines. This can be done by using multiple print
functions as under
print(“Hello world”) print(”welcome to python”) |
The output generated by the above code will be two lines
Hello world welcome to python |
print(“Hello world”, end=” “) print(”welcome to python”) |
Hello world welcome to python |
print(“Hello world\nwelcome to python”) |
Hello world welcome to python |
Try this one
print(“Hello world”,end=”apple”) |
Try this one
print("hello","world","welcome","to","python") |
hello world welcome to python |
Each word was supplied by adding commas inside the print function. The print function has added space between the words before printing them.
In short, you have various functions in python, and functions can be called by their names for executions and special instruction to each function can be provided inside the brackets. If a function can accept more than one instruction, they are given inside the bracket and each of them is separated by commas.