Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara How to Store Numbers in Python | Variables and Types in Python
Introduction to Python(ihor)

bookHow to Store Numbers in Python

To create a variable, choose a name and use the equals sign = to assign a value to it. Make sure the variable name is descriptive.

12
# Variable called `expenses` with value `1200` expenses = 1200
copy

Variables can also be used to calculate and store new values based on existing ones. This makes the code more flexible and reduces the need for repetitive calculations. Using variables is really convenient, and you can also display their values using the print() statement.

123456789
# Monthly expenses amount in dollars monthly_expenses = 1200 # Discount rate as a decimal (20%) discount_rate = 0.2 # Calculated total expenses after applying the discount total_expenses = monthly_expenses * (1 - discount_rate) print(total_expenses)
copy
question mark

Which statement correctly explains how variables work?

Select the correct answer

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 1

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

Suggested prompts:

Mi faccia domande su questo argomento

Riassuma questo capitolo

Mostri esempi dal mondo reale

Awesome!

Completion rate improved to 1.67

bookHow to Store Numbers in Python

Scorri per mostrare il menu

To create a variable, choose a name and use the equals sign = to assign a value to it. Make sure the variable name is descriptive.

12
# Variable called `expenses` with value `1200` expenses = 1200
copy

Variables can also be used to calculate and store new values based on existing ones. This makes the code more flexible and reduces the need for repetitive calculations. Using variables is really convenient, and you can also display their values using the print() statement.

123456789
# Monthly expenses amount in dollars monthly_expenses = 1200 # Discount rate as a decimal (20%) discount_rate = 0.2 # Calculated total expenses after applying the discount total_expenses = monthly_expenses * (1 - discount_rate) print(total_expenses)
copy
question mark

Which statement correctly explains how variables work?

Select the correct answer

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 1
some-alt