Activities for CS1 in Python - Calvin University

GANDY INK

5 0

Gold

4 2

IntroCS POGIL

Royal

2 45 47

Activities for CS1 in Python

Student Workbook

Navy Tricia Shepherd, Chris Mayfield, Helen Hu

With contributions from Michael Stewart, Theresa Wilson, and Barbara Wahl

BROKEN ARROW WEAR

Fall 2019

Copyright ? 2019. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Contents

Introduction to Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Model 1 Getting Started with Thonny Model 2 Python Built-In Functions Model 3 Variables and Assignment

Arithmetic Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Model 1 Python Calculator Model 2 Dividing Numbers Model 3 Integers and Floats

Basic Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Model 1 Lists Model 2 Sequences Model 3 Dictionaries

Conditions and Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Model 1 Comparison Operators Model 2 if/else Statements Model 3 Boolean Operations

Loops and Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Model 1 for Statements Model 2 The range Function Model 3 while Statements

Defining Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Model 1 Flow of Execution Model 2 Passing Arguments Model 3 Returning Values

Lists and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Model 1 Working with Lists Model 2 Indexing and Slicing Model 3 Common String Methods

Importing Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Model 1 Random Numbers Model 2 Multiple Modules Model 3 Turtle Graphics

Nested Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Model 1 Lists of Lists Model 2 Nested for Loops Model 3 Nested Dictionaries

File Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Model 1 Writing to a File Model 2 Appending to a File Model 3 Reading from a File

Visualizing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Model 1 Simple Plot Model 2 Histograms Model 3 CSV Data

Defining Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Model 1 Attributes and Methods Model 2 Constructors Model 3 Object-Oriented

Extending Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Model 1 UML Class Diagrams Model 2 Single-Class Approach Model 3 Derived Classes

Recursive Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Model 1 Factorial Function Model 2 Fibonacci Numbers Model 3 Summation

Role Cards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Meta Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Team Roles, Team Disruptions, What Employers Want, Group vs Team, POGIL Research Honor Code Case Studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

Panic Attack, A Friend Indeed, Oops!, Too Close for Comfort, Let's Make a Deal, A Friendly Assist, A Team Effort

Introduction to Python

In this course, you will work in teams of 3?4 students to learn new concepts. This activity will introduce you to the process. We'll take a first look at variables, assignment, and input/output.

Content Learning Objectives

After completing this activity, students should be able to: ? Describe differences between program and output text. ? Identify and execute Python functions for input/output. ? Write assignment statements and use assigned variables.

Process Skill Goals

During the activity, students should make progress toward: ? Leveraging prior knowledge and experience of other students. (Teamwork)

Copyright ? 2019 T. Shepherd, C. Mayfield, and H. Hu. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

1

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download