Lesson Python Calculus

Quick Look

Grade Level: 12 (11-12)

Time Required: 30 minutes

Lesson Dependency: None

Subject Areas: Computer Science, Problem Solving

A symbolic equation for the slope of a tangent line, shown in a cartoon fashion.
The slope of a tangent line is an important equation in calculus.
copyright
Copyright © 2013 Scott Burns, University of Nebraska-Omaha

Summary

Students analyze a cartoon of a Rube Goldberg machine and a Python programming language script to practice engineering analysis. In both cases, they study the examples to determine how the different systems operate and the function of each component. This exercise in juxtaposition enables students to see the parallels between a more traditional mechanical engineering design and computer programming. Students also gain practice in analyzing two very different systems to fully understand how they work, similar to how engineers analyze systems and determine how they function and how changes to the system might affect the system.

Engineering Connection

Engineers must be able to analyze systems to determine functionality and potential problems. For instance, mechanical engineers troubleshoot the mechanical systems on automobiles to determine why they do not work. They also analyze the same systems to determine what affect a potential change to those systems can have on the system. Structural engineers test individual components of their designs, such as for bridges, subways or skyscrapers, as well as the design as a whole under potential conditions, such as excessive loading. Engineers of all disciplines apply these types of analysis skills to perform their jobs.

Learning Objectives

After this lesson, students should be able to:

  • Given outputs, analyze computer code to determine aspects of how the code performs.
  • Analyze steps and the final outcome in a situation or process, in order to understand how the process operates.

Educational Standards

Each TeachEngineering lesson or activity is correlated to one or more K-12 science, technology, engineering or math (STEM) educational standards.

All 100,000+ K-12 STEM standards covered in TeachEngineering are collected, maintained and packaged by the Achievement Standards Network (ASN), a project of D2L (www.achievementstandards.org).

In the ASN, standards are hierarchically structured: first by source; e.g., by state; within source by type; e.g., science or mathematics; within type by subtype, then by grade, etc.

  • Determine the best approach by evaluating the purpose of the design. (Grades 9 - 12) More Details

    View aligned curriculum

    Do you agree with this alignment?

  • Understand numbers, ways of representing numbers, relationships among numbers, and number systems (Grades Pre-K - 12) More Details

    View aligned curriculum

    Do you agree with this alignment?

  • Understand meanings of operations and how they relate to one another (Grades Pre-K - 12) More Details

    View aligned curriculum

    Do you agree with this alignment?

  • Communicate the problem, process, and solution. Students should present their results to students, teachers, and others in a variety of ways, such as orally, in writing, and in other forms — including models, diagrams, and demonstrations. (Grades 9 - 12) More Details

    View aligned curriculum

    Do you agree with this alignment?

Suggest an alignment not listed above

Worksheets and Attachments

Visit [www.teachengineering.org/lessons/view/uno_python_lesson01] to print or download.

Pre-Req Knowledge

Teachers should have a working knowledge of the PythonTM computer language and know how to use one of the Python applications: Portable Python or Cloud9 IDE.

It is beneficial for students to have some computer programming knowledge, but it is not entirely necessary. Prior experience with Python is not required.

Introduction/Motivation

As an engineer, you must be able to look at a system and determine how it functions. For example, a bio-systems engineer in an ethanol plant must be able to look at the fermentation chamber and determine the correct functionality as well as any potential problems. Structural engineers must be able to analyze how a structure works together and if a failure occurs, examine the system to determine why, so that it can be prevented in the future. To be successful, all engineers throughout the various fields of engineering must possess these practical analysis skills.

In this lesson, you will analyze computer code to see what it does. You might not be familiar with the particular programming language, but with careful observation and analysis, you should be able to apply your prior knowledge and learn how this system works.

A cartoon drawing shows a Rube Goldberg machine for a self-operating napkin. When the man eats, a series of events happen, eventually causing a napkin to wipe his face.
Figure 1. Self-Operating Napkin—an example Rube Goldberg machine.
copyright
Copyright © 1915 Wikimedia Commons http://commons.wikimedia.org/wiki/File:Professor_Lucifer_Butts.gif

To begin, let's start with a fun activity in which we all analyze the performance of the system depicted in a cartoon of a Rube Goldberg machine. (Hand out the Explain a Rube Goldberg Machine, also Figure 1.)

Look carefully at the cartoon drawing and analyze how the system works. Remember to be specific in your analysis and explanation. Write down an explanation of how you think the machine works based on studying the picture. Try to capture every step! (Give students time to complete their analyses. Refer to the Explain a Rube Goldberg Machine Example Answer for an example analysis/explanation.)

A screen capture image shows a simple Python program that includes the coding for how to define a variable, define a function and use a list and a simple for loop. It results in the output of: Hi everybody! 16; Output 1: 14; Output 2: 2, 4, 6, 8, 10, 12, 14, 16, 18, 20.
Figure 2. Example working Python code that students analyze and compile.
copyright
Copyright © 2013 Scott Burns, University of Nebraska-Omaha

Next, let's take a look at some functional Python code. (Hand out the Explain Some Python Code; also Figure 2.) First retype, compile and execute the code using the Python compiler. As part of your analysis, answer the following questions:

  • What is the purpose of the quotation marks used in print statements? (Answer: They tell the computer to print exactly what is inside the quotation marks.)
  • Is x = 8 the same as 8 = x? (Answer: No, the order matters in variable declaration. The value on the right will be stored in the variable on the left.)
  • Does the indentation matter? (Answer: In the Python language, yes. Indented lines belong to the first non-indented line above.)
  • How does the 'for' loop work? (Answer: The for loop takes every element of list1, calls it 'i' for temporary computation, and performs an operation. In this case, every element is put into the function g(x).)

After answering the questions, do some experimentation. Make some changes to the code based on your analysis, then recompile and execute the code again. For example try 8 = x instead of x = 8 or change the x = 8 to x = 3, etc. Did your changes to the code work the way you expected they would, based on your prior analysis and experience? Refer to the associated activity Python Script Analysis for students to continue their engineering analysis of Python script by completing and running functioning codes.

Lesson Background and Concepts for Teachers

Overview and Preparation

Students each need access to a computer or tablet, and one of the many free and easily useable Python compilers that can be found online, such as Portable Python at http://portablepython.com/, which can be downloaded and run directly from a flash drive, and Cloud9 IDE at https://aws.amazon.com/cloud9/?origin=c9io, which can be run off the web with no install or permissions required.

In advance, make copies of the Explain a Rube Goldberg Machine and Explain Some Python Code, one each per student. Have students work individually or in groups of two or three students each. Refer to answers on the Explain a Rube Goldberg Machine Example Answer and Explain Some Python Code Answer Key.

Various Definitions of Computer Programming

  • In recognizable terms: Programming is defined as designing and creating software that enables a computer or other device accomplish a desired task.
  • In conceptual terms: Programming is how a human user gives commands and tasks to a computing machine. This is done through a wide variety of mediums that are often layered upon each other. The simplest programming involves the use of bits, or electronic signals, that represent symbols such as 0s and 1s. This base can be translated into programming that turns symbols into words, making it easier for humans to write plans or processes for the machine (the plans or processes are often called "algorithms"). Further translations make the simple languages more complex and enable more use of common human language, leading to high-level languages such as Java and C++.
  • In mathematical terms: Mathematically, programming is built on the conditional logic taught in most geometry courses—Boolean logic—which is simply examining on/off or true/false results, finite loops of a process, and recursion methods. Programming is a direct application of a wide variety of mathematical thinking.
  • In process terms: Programming is usually done using a chosen high-level language such as Java, C++, Python, or one of many others, and an integrated development environment (IDE) that provides the programmer with text editing for typing the code of the program. Programming also uses a compiler that translates the written code down through the languages understood by the respective machine, and adebugger, which allows for step-by-step inspection of a program in order to find errors in the code.
  • In applicable terms: Programming describes the variety of tasks done in computer science. Any software that operates on a computer is composed of a program developed by a programmer. Programming is also used to control industrial machinery, encrypt and decrypt messages or data, and solve multi-variable problems such as weather and economic forecasting.

Computer Programming History

The history of electronic computer programming began in the 1940s with the invention of the ENIAC machine. This first modern computer was developed by the military to help with the writing of artillery-firing tables. These tables were used for weapons that were fired under varied conditions for target accuracy. As computers improved through the 1950s to 1970s, languages like COBOL for business and FORTRAN for science and engineering were developed and became the standard. With the invention of the personal computer in the 1980s, computers became household items and the number of languages grew and diversified. Pascal and BASIC were languages that sprung up in the 1980s as a result of the PC (personal computer). As computers continue to get more powerful, the languages continue to adapt. Some of the more prevalent languages today are various iterations of C, Java and PHP.

Basic Functions of Computer Programs (in Almost Any Language)

  • Input: The acquisition of data from a file, keyboard or other input device.
  • Mathematical functions: The performance of mathematical operations ranging from basic arithmetic to advanced functions.
  • Repetition: The performance of an action over and over, sometimes with subtle changes.
  • Conditional algorithms: The checking for certain conditions and the execution of statements in an appropriate sequence.
  • Output: The data resulting from the program operation, presented on a screen, in a file or any other means.

Associated Activities

  • Python Script Analysis - Students continue their engineering analysis of Python script by completing and running functioning codes. For two different sets of script, they analyze the code to determine missing commands and then missing explanatory comments. Then they make modifications to the code in order to find the slopes of tangents to a variety of functions. These activities cultivate their abilities to understand the logic employed in the code.

Vocabulary/Definitions

Python programming language: A general purpose, high-level computer programming language.

Rube Goldberg machine: A device or apparatus that is a deliberately over-engineered to perform a very simple task.

Assessment

Pre-Lesson Assessment

Questions: Ask students the following questions to gauge their prior knowledge about analyzing a system or situation.

  • When have you had to analyze a situation before acting?
  • What skills did that analysis require?
  • What does it mean to analyze a situation?

Post-Introduction Assessment

Observations: As students are engaged in the lesson, consider these or similar questions in order to assess their comprehension:

  • Were students able to analyze the Rube Goldberg machine?
  • Did students see the connection between analyzing the Rube Goldberg machine and the Python code?
  • Were students able to analyze the Python code and figure out how it works?

Lesson Summary Assessment

Writing: Have students respond to the following writing prompt:

  • Explain the skills that you needed to have to analyze the examples in this lesson. (Example answer: To analyze the Rube Goldberg machine and Python code, I had to carefully observe what was happening. I had to see how the different and individual parts of the example worked together as a larger whole. Looking at the final outcome [results] was a great help in analyzing the example to figure out what each part does.)

Subscribe

Get the inside scoop on all things TeachEngineering such as new site features, curriculum updates, video releases, and more by signing up for our newsletter!
PS: We do not share personal information or emails with anyone.

More Curriculum Like This

Middle School Lesson
Rube Goldberg and the Meaning of Machines

Through the cartoons of Rube Goldberg, students are engaged in critical thinking about the way his inventions make simple tasks even harder to complete. As the final lesson in the simple machines unit, the study of Rube Goldberg machines can help students evaluate the importance and usefulness of th...

Middle School Lesson
Program Analysis Using App Inventor

In this lesson, students learn about, design and create flow charts for different scenarios, including a game based on the Battleship® created by Hasbro©. In the associated activity, Flow Charting App Inventor, students apply their knowledge from this lesson and gain experience with a software appli...

Copyright

© 2013 by Regents of the University of Colorado; original © 2013 Board of Regents, University of Nebraska

Contributors

Scott Burns, Brian Sandall

Supporting Program

IMPART RET Program, College of Information Science & Technology, University of Nebraska-Omaha

Acknowledgements

The contents of this digital library curriculum were developed as a part of the RET in Engineering and Computer Science Site on Infusing Mobile Platform Applied Research into Teaching (IMPART) Program at the University of Nebraska-Omaha under National Science Foundation RET grant number CNS 1201136. However, these contents do not necessarily represent the policies of the National Science Foundation, and you should not assume endorsement by the federal government.

Last modified: June 30, 2019

Free K-12 standards-aligned STEM curriculum for educators everywhere.
Find more at TeachEngineering.org