06_Expressions and Variables

VFXPEDIA·2025년 4월 27일
0
post-thumbnail

Understanding Expressions

Estimated time needed: 10 minutes

Objectives

After completing this lab you will be able to:

  • Understand expressions in Python
  • Declare and use variables
  • Perform arithmetic operations

Table of Contents


Expressions

Expressions are the building blocks of Python computations.

# Basic arithmetic
100 + 60

Image Example

![Expression Example](06_Expressions and Variables_image_01.png)


Arithmetic Operations

You can perform arithmetic using operators like +, -, *, /, and //.

# Subtraction
25 - 50

# Multiplication
-10 * 2.5

# Division
25 / 5
25 / 6

# Integer Division
25 // 6

Image Example

![Arithmetic Operations](06_Expressions and Variables_image_02.png)


Variables

You can assign values to variables using the assignment operator =.

my_variable = 1
print(my_variable)

Variable Assignment and Overwriting

A variable's value can be changed by reassigning it.

x = 10
x = 5 + 3
y = x / 3
x = y

Image Example

![Variable Assignment](06_Expressions and Variables_image_03.png)


Variable Types and Naming

Check variable types using type() and use meaningful variable names.

type(x)
total_min = 142
total_hour = total_min / 60
# Update input variable and see final result update
total_min = 200
total_hour = total_min / 60

Image Example

![Variable Naming](06_Expressions and Variables_image_04.png)


Summary

  • Expressions combine values and operators to compute results
  • Variables store values for reuse and manipulation
  • Python follows mathematical precedence in operations
  • Meaningful variable names improve code clarity

Image Summary

![Summary Visual](06_Expressions and Variables_image_05.png)

profile
VFX Cluture Architect

0개의 댓글