Editor

Type Conversion Chain

Beginner · Write the code · from Python Variables and Data Types: A Practical Introduction

From the lesson: Python Variables and Data Types: A Practical Introduction

Imagine you're shipping a package. You fill out a label that asks for the weight. You write "heavy" instead of a number. The shipping system crashes - it can't calculate a price from the word "heavy."

Read the lesson

You're given a string price_text containing "49" and an integer quantity of 3.

1. Convert price_text to an integer

2. Calculate the total (price times quantity)

3. Print the result in this exact format:

3 items at $49 each = $147 total

You must use the original variables - don't hardcode the numbers in your print statement.

price_text = "49"
quantity = 3
# Step 1: Convert price_text to an integer
# Step 2: Calculate the total
# Step 3: Print the formatted result

More Variables and Data Types exercises

All Python exercises · 50 practice problems · Python Fundamentals quiz