Variable Naming
Variables in Python are typically named using snake case, which means that every word is lowercase and separated by underscores. For example, if you wanted a variable to store whether it was raining, you would call it:
is_raining
There’s also special variables called constants, which means that the variable should not be changed and only has 1 value throughout the entire program runtime. Constants are usually in all caps. For example:
IS_RAINING
When naming variables, make sure you are descriptive but concise, and that you follow all of the other Python syntax-related rules. For a complete guide, see https://www.w3resource.com/python/python-variable.php.
Practice
Favorite
Practice: Write a program that asks the user for their favorite food, favorite drink, and the name of their favorite person. Output a statement that uses all of this information. (Be creative!)
Previous Section
2.4 CastingNew Section
Chapter 2 QuizCopyright © 2021 Code 4 Tomorrow. All rights reserved.
The code in this course is licensed under the MIT License.
If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.