π 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
πTrending Topics
π Connect With Us:
“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
Post a Comment