Exercise 2-1 Solution – Python Crash Course Chapter 2: Variables and Simple Data Types

 

📘 Python Crash Course – Chapter 2: Variables and Simple Data Types – Exercise 2-1 Solution


📝 Exercise 2-1

Task: Store a message in a variable, and then print that message.

✅ Solution Code:


message = "this is a message"
print(message)

🧠 Code Explanation:

This Python code performs the following actions:

  1. Store a message in a variable:

    The variable message is assigned the string "this is a message". This means the variable now holds this text value.

  2. Print the message:

    The print() function is used to display the value of the message variable on the console. When the code is executed, it will output:

    this is a message

This is a simple example of defining a variable and using it in Python.

🔍 Output:


this is a message

📚 Related Exercises from Chapter 2:


Previous Post Next Post

Contact Form