Python Programming for Beginners: A Simple and Easy Introduction by Shanal Nathoo

Python Programming for Beginners: A Simple and Easy Introduction by Shanal Nathoo

Author:Shanal Nathoo
Language: eng
Format: azw3
Published: 2017-07-15T07:00:00+00:00


Suggested Exercise: Create a combination of a string and numbers out for yourself using IDLE

Worked Example:

Observe the two different ways of defining a function

Notice the output values depending on what is requested

Points of note in the above example:

Any of the two different ways of defining a function can be used depending on a user’s preference because the output will be the same (output for function2 is not shown in the above example to avoid repetitiveness).

The correct output that we want printed is: function1()

The input “print(function 1())” has an output “None”. This is because using the print command on the function invokes the data about the function to be printed - and in our chosen definition there is no return function value.

Printing a function name without the “ () ” will result in the function not being invoked. Therefore, the output will be the object value (eg. <0x02DBA9CO>)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.