Before starting about this lesson
I want to say a function may have two things. They are,
1.
An effect
2.
A result
Also the third point is important
it is argument(s).
In Python, depending on the
individual needs, they may accept any number of arguments as many as necessary
to perform their tasks. So we should note here that, any number includes
zero – some Python functions don’t need any argument.
print("Hello World!")
We can see the string is
delimited with double quotes. That double quotes make the string. Almost anything
we put inside the quotes will be taken literally, not as code, but as data.
This function,
1.
Takes it arguments.
2.
Converts them into human-readable form if needed
3.
Sends the resulting data to the output device
This function accept any type of
arguments and not evaluate anything.
Python's syntax is quite specific in this area. Unlike most
programming languages, Python requires that there cannot be more than
one instruction in a line.
A line can be empty but it must not contain two, three or
more instructions. This is strictly prohibited.
Note: Python makes one
exception to this rule - it allows one instruction to spread across more than
one line (which may be helpful when our code contains complex constructions).
The print () function with the escape and newline characters (\n)
Here both the backslash and the n form a special symbol named a newline character which urges the console to start a new output line.
If we want to put just one backslash inside a string, don't forget its escaping nature so, we have to double it.
Otherwise it will give an error.
No comments:
Post a Comment