Open main menu

CDOT Wiki β

Changes

OPS435 Python3 Lab 3

4 bytes added, 14:01, 25 September 2019
PART 2 - Function that does not take argument but returns a string
== PART 2 - Function that does not take argument but returns a string ==
:#Let's create a function that '''returns''' some data to the caller after the function is called. This function does not print out any text: instead; it creates new objects and at the end , returns one of the object named '''greeting''', which is a string object containing 'Good Monring Terry'.<source lang="python">
def return_text_value():
name = 'Terry'
text = return_text_value()
</source>
:#Now the returned string from the function has been assigned to an object named "'''text'''". It can be used like any string object now.<source lang="python">
print(text)
</source>
1,760
edits