Hello everyone,
Can someone kindly explain me what is the basic difference between python statements and expressions? I'm too much confused about them and cannot upgrade my knowledge about Python until I get a full grasp on them because they are everywhere! Some explanation with example may help me a lot.
Thanks in advance.

Recommended Answers

All 3 Replies

A statement in python is something that is already set as what is does, if is a statement, break is another, print is a statement.

An expression is something that evaluates to something. Such as adding numbers or strings together evaluates to something.

A syntactically marked group of lines is a statement in python. A statement with only one line is a simple statement (break, pass etc). A statement with more lines is a compound statement (if, for etc...)

Expression (statement) is a kind of simple statement, that usually gives back a value. And has the following sytax:
http://docs.python.org/reference/simple_stmts.html#expression-statements

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.