30 lines
719 B
Markdown
30 lines
719 B
Markdown
---
|
||
title: expressions
|
||
tags:
|
||
- python
|
||
- expressions
|
||
- syntax
|
||
aliases:
|
||
- expression
|
||
- evaluate
|
||
---
|
||
|
||
> [!note] Concept
|
||
> An **expression** is a combination of **values**, **variables**, and **operators** that evaluates to a single value.
|
||
>
|
||
> > [!example] Examples
|
||
> > ```python
|
||
> > 2 + 3 # 5
|
||
> > 'a' * 3 # 'aaa'
|
||
> > myAge + 1 # if myAge is an integer
|
||
> > ```
|
||
>
|
||
> > [!important] Best Practices
|
||
> > - Expressions don’t store data — they compute and return a value.
|
||
> > - You can use expressions inside function calls, assignments, etc.
|
||
>
|
||
> > [!info] Related Notes
|
||
> > [[arithmeticOperators]]
|
||
> > [[booleans]]
|
||
> > [[typeConversions]]
|
||
> > [[pythonSyntaxOverview]]
|