High School course

Python 101 (Old)

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

Answer Key

Module 4: Asteroid

Module 6: Quiz

1. What is the keyword used to start a function definition?

  • function
  • def
  • create
  • abracadabra

2. What is outputted by the following code?

i = 0
def inc() :
    i = i + 1
    print(i)
inc()

  • 1
  • 0
  • Nothing, it will produce an error.
  • Undefined

3. Why does the following code not print anything?

i = "hello world"
def print_hello_world() :
    print(i)

  • The variable i does not contain the string "hello world."
  • The function has not been called.
  • You can not access a global variable inside a function.
  • It will print "hello world."

4. What goes into the first parameter of the onkey function?

  • a function's name
  • a string of the key
  • onkey does not take any parameters
  • a number

5. Why does the following code not print "Hello" when the space bar is pressed?

def say() :
    print("Hello")

screen.onkey(say(), "Space")
screen.listen()

  • screen.listen is not a function
  • The first parameter of onkey shouldn't include parentheses
  • The second parameter does not take a string
  • "say" is a keyword

6. Why does the following code not print "Hello" when the space bar is pressed?

def say() :
    print("Hello")

screen.onkey(say, "Space")

  • The first parameter of onkey is incorrect
  • The second parameter of onkey does not take a string
  • The screen.listen() function was not called
  • screen.onkey is not a function

7. What is an advantage of using a function?

  • It makes the code more modular and more readable.
  • It makes you have less bugs.
  • It makes code run faster.
  • It has no advantages.

8. True or False : All user defined functions can't have parameters.

  • True
  • False

9. True or False : Function names must follow the same naming rules as variables.

  • True
  • False

10. What is wrong with the following code?

def set_i() :
    i = 10
set_i()
print(i)

  • The code is correct.
  • "set_i" is not a valid function name.
  • "i" must be a string to use print.
  • "i" is not defined in global scope.

11. How many seconds does it take for the screen to print out "Hello" after the following code is executed?

def print_hello_world() :
    print("Hello")
screen.ontimer(print_hello_world, 500)
screen.listen()

  • 50 seconds
  • 500 seconds
  • 5 seconds
  • .5 seconds

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, HSA.CED.A.1, HSA.CED.A.3, MP.1, MP.2, MP.3
  • CSTA: 2-AP-11, 2-AP-13, 2-AP-16, 2-AP-17, 3A-AP-17, 3B-AP-11, 3B-AP-12, 3B-AP-22
  • CS CA: 6-8.AP.11, 6-8.AP.12, 6-8.AP.13, 6-8.AP.16, 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, 6.b

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
All pupils must have the opportunity to study aspects of information technology and computer science at sufficient depth to allow them to progress to higher levels of study or to a professional career. 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 8: User Interaction

Course: | Web

  • User Defined Functions
  • Key Detection
  • Timers
  • Asteroid
  • Review
  • Quiz

Description

An introduction to Python for intermediate or advanced coders in upper middle or high school. In this advanced lesson plan, students will be introduced to Python as they complete 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 transition to 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 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.