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

 

📘 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:

  1. Store a person's name in a variable:

    The variable name is assigned the string "Jarvis", representing the person's name.

  2. Store a message in another variable:

    The variable msg is assigned the string "how are you", which is the message to be displayed.

  3. 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:


“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