High School course

Python 101

  • GRADES 7+
  • ADVANCED
  • WEB
  • 13 LESSONS
Slide: 1 of

Answer Key

Module 2: Path Right

Module 3: Path Left

Module 4: More Turns!

Module 8: Hazardous Path

Module 10: Death Valley

Module 11: Traps

Module 13: G for Grandeur

Module 14: Silly Path

Module 16: Quiz

1. Which of the following makes the character shoot if there is an enemy ahead? Mark all that apply.

  • if enemy_in_sight() :
        long_jump()
    
  • if not enemy_in_sight() :
        fire()
    
  • if enemy_in_sight() :
        fire()
    
  • if enemy_in_sight() :
        forward()
    

2. The following two pieces of code do the same thing:

        if condition :
            forward()
        
                # next code

        if condition :
            forward()
         else :
            fire()
        

  • True
  • False

3. You are given three variables, A=True, B=False and C=False. What is the value of the expression A and ( B or C )?

  • True
  • False
  • None
  • I don't know

4. Which part of a conditional goes after the if keyword and before the colon?

  • The word “if”
  • The word “else”
  • The code to run
  • The condition

5. When would you use an "if-else" statement over an "if" statement?

  • When you want to stop running code once the condition is false
  • When you want to run different code if a condition is false
  • When you want to run code and then check if the condition is true after
  • They have the exact same function

6. There is no difference between an "if" statement and an "if-else" statement.

  • True
  • False

7. A conditional, "if" or "if-else" statement, checks the condition and executes the code in the if-statement if the condition evaluates to true.

    if condition :
        # execute code here
    

  • True
  • False

8. The following pieces of code are the exact same in functionality.

    if condition1 :
        function1()    
    if condition2 :
        function2()
    
        # next code

    if condition1 :
        function1()
    elif condition2 :
        function2()
    

  • True
  • False

9. If you wanted to run different code given different conditions, how would you do that?

  • Combine all the conditions in one condition using “or”
  • Use “elif” statements
  • Put everything in the “else” statement
  • Create two functions

10. When running this code, what will the character do if there is an enemy?

    if not enemy_in_sight() :
        fire()
    

  • fire
  • nothing
  • walk forward
  • jump

11. What is the output of this code?

    x = 2
    if (x > 0) :
        print(“hello”)
    else
        print(“goodbye”)
    
    print(“world”)

  • hello
    
  • world
    
  • hello
    world
    
  • goodbye
    

  • 3.1 - If Statements in Action

    Sample answer:

    if (1 < 3):
    print("Hello")
  • 3.5 - Do It Yourself

    Sample answer:

    x = 5
    x += 3
    print(x)
    
    i = 11
    i += 2
    print(i)
    
    j = 22
    j -= 3
    print(j)
  • 3.6 - Do It Yourself

    Sample answer:

    x = 12
    y = x - 20
    
    print(y < x)
    print(y > x)
    print(y == x)
    print(y != x)
    print(y <= x)
    print(x >= x)
  • 3.7 - Do It Yourself

    def true_func():
        print("Running true_func")
        return True
    
    def false_func():
        print("Running false_func")
        return False
    
    x = false_func() and true_func()
    y = true_func() or false_func()
    
    print(x)
    print(y)
  • 3.12 - Nesting Grade Checker

    grade = 74
    (rest unmodified)

U.S. Standards

  • CCSS-ELA: SL.7.1, SL.8.1, RI.9-10.3, RI.9-10.6, L.9-10.3, L.9-10.6
  • CCSS-Math: HSN.Q.A.1, HSN.Q.A.2, HSN.Q.A.3, MP.1, MP.2
  • CSTA: 2-AP-11, 2-AP-12, 2-AP-13, 2-AP-15, 2-AP-17, 3A-AP-17, 3A-AP-19, 3B-AP-11, 3B-AP-12
  • CS CA: 6-8.AP.11, 6-8.AP.12, 6-8.AP.13, 6-8.AP.15, 6-8.AP.17, 9-12.AP.12, 9-12.AP.14, 9-12.AP.16
  • ISTE: 1.c, 1.d, 4.d, 5.c, 5.d

U.K. Standards

Key stage 3
Pupils should be taught to:
  • design, use and evaluate computational abstractions that model the state and behaviour of real-world problems and physical systems
  • understand several key algorithms that reflect computational thinking [for example, ones for sorting and searching]; use logical reasoning to compare the utility of alternative algorithms for the same problem
  • undertake creative projects that involve selecting, using, and combining multiple applications, preferably across a range of devices, to achieve challenging goals, including collecting and analysing data and meeting the needs of known users
  • create, reuse, revise and repurpose digital artefacts for a given audience, with attention to trustworthiness, design and usability
  • understand a range of ways to use technology safely, respectfully, responsibly and securely, including protecting their online identity and privacy; recognise inappropriate content, contact and conduct, and know how to report concerns
Key stage 4
Pupils should be taught to:
  • develop their capability, creativity and knowledge in computer science, digital media and information technology
  • develop and apply their analytic, problem-solving, design, and computational thinking skills
  • understand how changes in technology affect safety, including new ways to protect their online privacy and identity, and how to report a range of concerns

Lesson 3: Conditional Logic

Course: | Web

  • What Are Conditionals?
  • Path Right
  • Path Left
  • More Turns!
  • What Are Assignment Operators?
  • What Are Comparison Operators?
  • What Are Logical Operators?
  • Hazardous Path
  • What Is an Else?
  • Death Valley
  • Traps
  • What Are Nested Ifs?
  • G for Grandeur
  • Silly Path
  • Review
  • Quiz

Description

In this introduction to Python for intermediate or advanced coders in upper middle or high school, students will be learn to code in Python. As they complete this advanced lesson plan, they will enjoy engaging lessons, solve challenging puzzles, and build their own games in Python. This course is ideal for students who have already completed at least one Tynker course and are comfortable with the basics of programming logic and computational thinking. This course will help them learn how to code Python and adapt to the additional challenges of text-based syntax.

Students who successfully complete this lesson plan will demonstrate a strong mastery of Python syntax, as well as the ability to creatively program games and other projects and debug their own code. Students will also be able to come up with an idea for a Python game and take it through the entire design and implementation process, creating custom versions of many of their favorite games in Python.

Topics

  • Python syntax
  • Sequencing
  • Repetition
  • Conditional logic
  • Nested loops
  • Automation
  • Pattern recognition
  • Simple motion
  • Keyboard and mouse events
  • Pen drawing
  • Operators
  • Expressions
  • Variables
  • Turtle graphics
  • Using arrays and objects to store structured data

What Students Learn

  • Learn Python syntax
  • Use conditional logic, loops, and conditional loops to solve problems
  • Create and use variables
  • Detect and handle keyboard and mouse events
  • Write and interpret Python expressions
  • Use pen drawing and Turtle graphics to draw shapes and display images
  • Detect win/loss conditions in a game
  • Implement collision detection between images
  • Use arrays, dictionaries, and objects to store structured data

Technical Requirements

* Online courses require a modern desktop computer, laptop computer, Chromebook, or Netbook with Internet access and a Chrome (29+), Firefox (30+), Safari (7+), or Edge (20+) browser. No downloads required.