Code Circle
  • Home
  • Team
    • Admin Team
    • Board of Directors
  • Join Us
    • Teach A Course
    • Become A Partner
  • Partners
  • Programs
    • App Design & Development
    • Python Course >
      • Python Course Week 1: Introduction >
        • Gmail Account Setup
        • Repl.it Setup
      • Python Course Week 2: Numbers (Ints and Doubles) >
        • Variables
        • Integers
        • Integer Operations
        • Doubles
        • Summary
        • Python Ints Quiz
      • Python Course Week 3: Strings >
        • Printing, Assigning, and Concatentating
        • Converting With Strings
        • Indexing
        • Summary
        • Strings Cheat Sheet
        • Strings Error Log
        • Python Strings Quiz
      • Python Course Week 4: Booleans >
        • Practicality
        • Comparisons
        • Logical Statements
        • Summary
        • Error Log
        • Boolean Quiz
        • Mid-Course Survey
      • Python Course Week 5: Conditional Statements >
        • If Statements
        • Else/Else If Statements
        • While Loops
        • If Statement Logic
        • Summary
        • Cheat Sheet: Conditions
        • Conditionals Error Log
        • Quiz: Conditional Statements
      • Python Course Week 6: For Loops >
        • For Loops
        • For Loops Syntax
        • Loop Errors
        • Summary
        • Using Loops in Problems
        • Quiz: For Loops
      • Python Course Week 7: Lists >
        • Functions
        • Iterating Through A Loop
        • Summary
        • Error Log
        • Quiz: Lists
      • Python Course Week 8: Functions and Programs >
        • All About Functions
        • All About Programs
        • Post-Course Quiz
        • Python Course Final Project
    • Global Ambassadors

If Statements

If Statements in Everyday Life

This week you’ll be learning about conditional statements. While you may not be familiar with this term, you probably have used them in your everyday life. Conditional statements are phrases that say what would happen if certain conditions are met. Here are a few everyday examples
  • If your room is messy, then you have to clean it.
  • If you are hungry, then go find something to eat.
  • If it is late, then go to bed.
  • If it is cold, then put on a jacket.​
As you can see, the magic word in these statements is if. This is why conditional statements are also known as if statements. These statements are actions that occur depending on conditions like time, weather, and feelings. They’re also related to booleans (true, false) as conditional statements follow a certain boolean-like format.
  • If this condition is true then these actions will occur.

If Statements in Python

Now, lets bring these statements to life in Python, 
Here is an example of an If statement in Python:
Picture

​

Remember: A huge part of coding is having the proper syntax. If you look at the example above, the print statement is aligned under the num variable. This is known as indentation, where the code is in a specific place to complete the statement. Make sure that the code is properly indented or it could result in a compiling error. If you are having trouble with this, refer to the code above for the proper indentation for conditional statements. In addition, make sure you add a colon after your conditional statement. Don’t forget the “:” after num>0 or you will have an error!

Now you are ready to start creating your own conditional statements, based on your work with booleans and variables!
previous
continue with week 5
Powered by Create your own unique website with customizable templates.
  • Home
  • Team
    • Admin Team
    • Board of Directors
  • Join Us
    • Teach A Course
    • Become A Partner
  • Partners
  • Programs
    • App Design & Development
    • Python Course >
      • Python Course Week 1: Introduction >
        • Gmail Account Setup
        • Repl.it Setup
      • Python Course Week 2: Numbers (Ints and Doubles) >
        • Variables
        • Integers
        • Integer Operations
        • Doubles
        • Summary
        • Python Ints Quiz
      • Python Course Week 3: Strings >
        • Printing, Assigning, and Concatentating
        • Converting With Strings
        • Indexing
        • Summary
        • Strings Cheat Sheet
        • Strings Error Log
        • Python Strings Quiz
      • Python Course Week 4: Booleans >
        • Practicality
        • Comparisons
        • Logical Statements
        • Summary
        • Error Log
        • Boolean Quiz
        • Mid-Course Survey
      • Python Course Week 5: Conditional Statements >
        • If Statements
        • Else/Else If Statements
        • While Loops
        • If Statement Logic
        • Summary
        • Cheat Sheet: Conditions
        • Conditionals Error Log
        • Quiz: Conditional Statements
      • Python Course Week 6: For Loops >
        • For Loops
        • For Loops Syntax
        • Loop Errors
        • Summary
        • Using Loops in Problems
        • Quiz: For Loops
      • Python Course Week 7: Lists >
        • Functions
        • Iterating Through A Loop
        • Summary
        • Error Log
        • Quiz: Lists
      • Python Course Week 8: Functions and Programs >
        • All About Functions
        • All About Programs
        • Post-Course Quiz
        • Python Course Final Project
    • Global Ambassadors