Home | | Problem Solving and Python Programming | Expressions and statements - Python

Chapter: Problem Solving and Python Programming : Data, Expressions, Statements

Expressions and statements - Python

An expression is a combination of values, variables, and operators.

Expressions and statements

An expression is a combination of values, variables, and operators.

Eg:

17

x

x + 17

Instructions that a Python interpreter can execute are called statements. A statement is a unit of code that the Python interpreter can execute. Two kinds of statement: print and assignment.

Eg:

a = 1 + 2 + 3 + \

4 + 5 + 6 + \

7 + 8 + 9

In Python, end of a statement is marked by a newline character. But we can make a statement extend over multiple lines with the line continuation character (\).

 

Python Indentation

Most of the programming languages like C, C++, Java use braces { } to define a block of code. Python uses indentation.

A code block (body of a function, loop etc.) starts with indentation and ends with the first unindented line. The amount of indentation is up to you, but it must be consistent throughout that block.

Generally four whitespaces are used for indentation and is preferred over tabs. Here is an example.



Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Problem Solving and Python Programming : Data, Expressions, Statements : Expressions and statements - Python |

Related Topics

Problem Solving and Python Programming : Data, Expressions, Statements


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.