Python's understandable syntax - for a starter on python user


I’m starting to learn python.
I didn’t understand what is the logic about the syntax of defining a function is like this example:

def input(1,2):
return output

and not something like:
input(1,2) >> output

and i’m asking that because it’s supposed to be much easier to pronounce it without the terms “def”, “return” and the colons.
*(when i used “>>” for my suggest to change the syntax, it’s not have to that type for pronounce, it could be something else).

thank you

Usually functions can have a lot of activities happening. To define it in one line quickly becomes cumbersome and harder to read.

Example (imagine typing anything longer than this in one line)

def compare(num1, num2):
	sum = num1 + num2
	diff = num1 - num2
	product = num1 * num2
	print(f"Properties of {num1} and {num2}:\n")
	print(f"Their sum is {sum}")
	print(f"Their difference is {diff}")
	print(f"Their product is {product}")



Properties of 6 and 3:

Their sum is 9
Their difference is 3
Their product is 18

1 Like

Having said that, there are one liner functions called lambda functions. But don’t worry about these yet, you’ll learn about them later in the course

1 Like