My Blog
Articles related to programming, computer science, technology and research.

19/04/2018 Categories: Python Programming. No Comments on Expression Evaluation in Python Programming

Contents1 Introduction to Expression Evaluation2 Literal Expressions3 Binary Expressions4 Unary Expressions5 Compound Expressions6 Variable Access Expressions Introduction to Expression Evaluation   A Python program contains one or more statements. A statement contains zero or more expressions. Python executes a statement by evaluating its expressions to values one by one. Python evaluates an expression by evaluating […]

Introduction to Expression Evaluation

 

A Python program contains one or more statements. A statement contains zero or more expressions. Python executes a statement by evaluating its expressions to values one by one. Python evaluates an expression by evaluating the sub-expressions and substituting their values.

 

Literal Expressions

 

A literal expression evaluates to the value it represents. Following are some examples of literal expressions:

 

 

Binary Expressions

 

A binary expression consists of a binary operator applied to two operand expressions. Examples:

 

 

Unary Expressions

 

An unary expression contains one operator and single operand. Examples:

 

 

Compound Expressions

 

In a binary or unary expression, if an operand itself is an expression, such expression is known as a compound expression. Examples:

 

 

Variable Access Expressions

 

A variable access expressions allows us to access the value of a variable. Examples:

 

 

Related Links:

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll Up