# Creating two variables
num1 = 10
num2 = 20
# Adding the variables together
result = num1 + num2
# Outputting the result
print(result)
30
num1
and num2
and assign them the values 10
and 20
, respectively. We then use the +
operator to add the values of the two variables together and assign the result to a new variable named result
.print
function to output the value of result
to the console. When we run the program, it will output the value 30
, which is the result of adding num1
and num2
together.+
operator behaves differently depending on the types of the variables being added. +
operator will concatenate them, while adding two lists together will combine them into a new list.