Course Content
Introduction to Python
Introduction to Python
3. Conditional Statements
Boolean Data TypeChallenge: Comparison OperatorsCombining ConditionsChallenge: Logical OperatorsMembership Operators and Types ComparisonSimple if/else ExpressionsChallenge: Grocery StoreChallenge: Odd and Evenif/elif/else ExpressionsChallenge: Grocery Store ExtendedChallenge: Positive, Negative or Zero
Storing Numbers
Variables in programming act like placeholders for data. In the last section, you crunched some numbers. But what if we want to use those numbers again later? Doing the math all over again doesn't make much sense.
To remember a value for later, we give it a name by using a variable. The equals sign =
lets us set a value for that variable. For instance, you can set the variable year
to the value 2024
, and from there, you can display it or do more math with it.
# Create a variable year = 2024 # Output its value print(year) # Perform an addition print(year + 10)
Task
We're in the seventh chapter of the course. Set up a variable called chapter
and give it the value 7
.
Everything was clear?
Thanks for your feedback!
Section 2. Chapter 1