📘 Python Crash Course – Chapter 2: Variables and Simple Data Types – Exercise 2-3 Solution
📝 Exercise 2-3
Task: Store a person’s name in a variable, and print a message to that person . Your message should be simple, such as, “Hello Eric, would you like to learn some Python today?
✅ Solution Code:
name = "Jarvis"
msg="how are you"
print(msg , name)
🧠 Code Explanation:
This Python code performs the following actions:
-
Store a person's name in a variable:
The variable
name
is assigned the string"Jarvis"
, representing the person's name. -
Store a message in another variable:
The variable
msg
is assigned the string"how are you"
, which is the message to be displayed. -
Print the message and name:
The
print()
function is used to display the message and the name together. The output will be:how are you Jarvis
This code demonstrates how to use variables to store data and combine them in a print statement.
🔍 Output:
how are you Jarvis
📚 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