This exercise is meant to help you practice basic programming skills:
- Creating variables.
- Manipulating simple data.
- Printing results to the console.
- Executing code in the terminal.
You will be writing a short a python script to explore some of the most fundamental aspects of programming. As you are writing the code, periodically execute the code in your terminal and print your variables to check your work and see their values.
Specifically, write a script that does the following:
- Create four variables.
- Assign numeric values to two of them.
- Assign string data to one of them.
- Assign a boolean value to one of them.
- Add the two numbers together and store the result in a new variable.
- Use string concatenation to add some text to the string variable and store the result back into the original variable.
- Hint
+=
works for strings too!
- Hint
- Use the "not" operator
not
on your boolean variable and see what it does.- Hint: If your variable is named
the_truth
then tryprint(not the_truth)
- Hint: If your variable is named
- Try to use the
+
operator with variables that don't have the same type. Specifically try all of these combinations:- Combine the boolean and a number.
- Combine a string and a number.
- Combine a string and a boolean.
- What happens when you run the code?
- Is it the same for each combination?
- Can you explain the behavior you're witnessing?
- Hone your research skills: search the internet for more information...