📘 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:
-
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. -
Print the message:
The
print()
function is used to display the value of themessage
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:
- ➤ Exercise 2-1 | Simple Message Part 1
- ➤ Exercise 2-2 | Simple Messages Part 2
- ➤ Exercise 2-3 | Personal Message
- ➤ Exercise 2-4 | Name Cases
- ➤ Exercise 2-5 | Famous Quote
- ➤ Exercise 2-6 | Famous Quote 2
- ➤ Exercise 2-7 | Stripping Names
- ➤ Exercise 2-8 | Number Eight
- ➤ Exercise 2-9 | Favorite Number
- ➤ Exercise 2-10 | Adding Comments
- ➤ Exercise 2-11 | Zen of Python