Welcome to Lesson 2 of the Python Learning Lounge! In this lesson, we will cover the basics of writing and reading variables in Python.
By the end of this lesson, you will be able to:
- Understand what a variable is in Python.
- Assign values to variables.
- Print variables to the console.
Variables are fundamental elements in programming that allow you to store and manipulate data. In Python, you can create a variable by assigning a value to a name using the =
operator.
Here's a simple example to illustrate how to create and use variables in Python:
# To start we will need to do is this
name = "John Doe"
# A variable in Python is when you put a wordkey before a = and putting the message after the =
# Now let's print this with what we learned in Lesson 101
print("Hello, " + name)
-
Creating a Variable:
name = "John Doe"
: This line creates a variable namedname
and assigns it the value"John Doe"
.
-
Printing a Variable:
print("Hello, " + name)
: This line prints the message"Hello, John Doe"
to the console by concatenating the string"Hello, "
with the value of thename
variable.
In this lesson, we've learned how to create variables in Python and how to print them to the console. Variables are essential for storing and manipulating data, and they form the foundation for more complex programming concepts.
Feel free to experiment with different variable names and values to get more comfortable with the concept!
Feel free to modify this README as needed.