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:


“In the world of code, Python is the language of simplicity, where logic meets creativity, and every line brings us closer to our goals.”— Only Python

πŸ“Œ Follow Us And Stay Updated For Daily Updates

Comments