1

I was trying to explain how my code worked when I started to talk about print() and was confused as to whether it was a command or a function.

I understand that you can define functions using def x where x is the name of the function, but what is the difference and could someone show me examples?

Thanks.

Anya
  • 395
  • 2
  • 13
  • 4
    I don't believe "command" is a formal term for any construct in Python. You might be looking for "statement". In Python 2, `print x` is a statement, whereas in Python 3, `print` is a function. – jtbandes Mar 05 '17 at 22:13
  • There are no "commands" in Python. You probably confuse them with statements. A function definition `def` is a statement. A function call `print()` is a statement, too. So, `print()` is both a function call and a statement. – DYZ Mar 05 '17 at 22:14
  • What about methods? http://stackoverflow.com/questions/155609/difference-between-a-method-and-a-function – OneCricketeer Mar 05 '17 at 22:14
  • @cricket_007 So, what about them? – DYZ Mar 05 '17 at 22:15
  • So there are functions and statements? – Anya Mar 05 '17 at 22:15
  • 1
    There are many types of statements in Python: https://docs.python.org/3/reference/simple_stmts.html. A function call is one of them. A function definition is another. – DYZ Mar 05 '17 at 22:16
  • 1
    @user82395214 Java does _not_ call functions "functions". All Java "functions" are methods. – DYZ Mar 05 '17 at 22:17

0 Answers0