Store information in a variable
A variable gives a value a useful name. For example, learner_name = "Amina" stores text, while minutes = 15 stores a whole number. Choose names that explain what the value represents.
Work with text and numbers
Text values are strings and use quotation marks. Numbers can be used in calculations. Convert a text entry to a number before calculating with it, and check inputs because a user may provide something unexpected.
Try it
Store the name of a course and the minutes spent studying in separate variables. Print a sentence that includes both values. Change the minutes and confirm the output reflects the change.
Key takeaways
- Variables give values meaningful names.
- Text and numeric values behave differently.
- Check and convert user input before calculating.