ECT Pencil Code Program: Interactive Mad Libs


 At a glance…

Core subject(s)

English-Language Arts; Computer Science

Subject area(s)

Language; Programming Fundamentals

Suggested age

8 to 18 years old

Overview

Use this program to create an interactive Mad Libs, prompting the user to enter several words matching requested parts of speech and then stitching them together in a couple humorous sentences. Have students analyze or fill in or change parts of the program. This program could be used to further your understanding of how you could use Pencil Code in the classroom, as a demonstration or discussion with your students, or as a way to introduce various CT concepts, such as pattern recognition or abstraction, to your students by inviting them to extend the existing functionality of the program.

Pencil Code Program

Copy/Paste the following program into a ‘Blank Editor’ on the Pencil Code website (new.pencilcode.net)

# Copyright 2015 Google Inc. All Rights Reserved.

 

# Licensed under the Apache License, Version 2.0 (the "License");

# you may not use this file except in compliance with the License.

# You may obtain a copy of the License at

 

# http://www.apache.org/licenses/LICENSE-2.0

 

# Unless required by applicable law or agreed to in writing, software

# distributed under the License is distributed on an "AS IS" BASIS,

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

# See the License for the specific language governing permissions and

# limitations under the License.

write 'Give me some words for a story.'

madlib = [

  'A Healthy Living Tip by '

  'Your Name'

  ': if you are feeling '

  'adjective'

  ', you should eat plenty of '

  'plural noun'

  ' and make sure you ',

  'verb',

  ' vigorously every day!'

  ]

 

for i in [1...madlib.length] by 2

  await read madlib[i], defer answer

  madlib[i] = answer

 

write madlib.join ''

Sample Output


Screen Shot 2015-06-09 at 12.29.17 PM.png

Additional Information and Resources

Computational Thinking Concepts*

Concept

Definition

Abstraction

Identifying and extracting relevant information to define main idea(s)

Pattern Recognition

Observing patterns, trends, and regularities in data

* Explore the Computational Thinking Concepts Guide for a list of the CT concepts noted on ECT, including tips for implementing each concept in your classroom

Additional Resource Links

Administrative Details

Contact info

For more info about Exploring Computational Thinking (ECT), visit the ECT website (g.co/exploringCT)

Credits

Developed by the Exploring Computational Thinking team at Google and reviewed by K-12 educators from around the world.

Last updated on

06/09/2015

Copyright info

Except as otherwise noted, the content of this document is licensed under the Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache 2.0 License.


 ECT Pencil Code Program: Interactive Mad Libs                                                                    of