Search Header Logo
Python Conditionals

Python Conditionals

Assessment

Presentation

Computers

7th - 12th Grade

Practice Problem

Medium

Created by

Jason Davis

Used 64+ times

FREE Resource

8 Slides • 8 Questions

1

Python Conditionals

by Jason Davis

2

​What's Up?

Essential Question​

How can a program make decisions about whether or not to run code?

​Objective

I can write code that decides whether or not to perform an action

media

3

Define: conditional

  • Code structure

  • Lets us make decisions

  • Do a section of code or skip it

  • "If yes, then do something"

  • Example: "If it is raining, then I'll bring an umbrella."

media

4

Multiple Choice

What best describes a conditional?

1

I will do what I want

2

If the answer is no, then I'll do something

3

If it doesn't snow I'll wear my snow boots to school

4

If the answer is yes, then I'll do something

5

Define: if-clause/then-block

  • if-clause in code is the condition:

  • if-clause decides whether or not to proceed with the then-block

  • then-block has at least one line of code

    then-block can either be executed or skipped depending on the if-clause

media

6

Multiple Choice

Which part of a conditional decides whether or not to skip the then-block?

1

if-clause

2

then-block

3

input statement

4

print statement

7

Structure of a Conditional

  • Two parts: if-clause and then-block

  • then-block is indented under if-clause

  • ​Words go in quote marks, numbers don't

  • ​Don't forget the colon!

media

8

Multiple Choice

What happens to the then-block if the condition in the if statement isn't true?

1

It runs either way

2

It gets skipped

3

You will receive an error message

4

The program asks the user the input a new answer

9

Multiple Choice

What happens to the then-block you forget the colon after the if-clause

1

It runs either way

2

It gets skipped

3

You will receive an error message

4

The program asks the user the input a new answer

10

  • Define: comparison operators

  • ​Comparison Operators are the symbols that help determine if a conditional is true or false. You might recognize them from your math class - but with a twist!

    1. < less than

    2. <= less than or equal to

    3. > greater than

    4. >= greater than or equal to

    5. == equal to

    6. != not equal to

11

Fill in the Blank

Type answer...

12

Fill in the Blank

Type answer...

13

What is a valid condition?

  • Part of the if-clause

  • Asks a yes or no question

  • Usually contains an expression (a comparison of value)

  • Often uses comparison operators

14

Multiple Choice

True or false: The if-clause HAS to use numbers for comparison.

1

True

2

False

15

I'm just using this slide so there aren't two questions in a row. It's good, right?​

16

Poll

On a scale of 1-5, where are you on conditionals?

1

Conditionals? Never heard of them.

2

I am strugling to understand the vocabulary and the coding.

3

I understand the vocabulary, but I'm struggling with the coding.

4

I am good with the coding, but still fuzzy on the vocab

5

I understand everything and I can code programs with conditionals by myself.

Python Conditionals

by Jason Davis

Show answer

Auto Play

Slide 1 / 16

SLIDE