Python: Buy Low, Sell High (Gr. 9-10)

Description

In this lesson, students are introduced to the if…else and if…elif…else statements in Python for multi-way decision making. Both statements can execute the code inside the body of the if/elif when certain conditions are met. Code inside the body of else will be executed if neither of the condition is met. To explore conditional constructs, students will develop a computational model to simulate the commodity trading and practice the ‘buy low, sell high’ strategy.

Objectives

  • Further exploration of Python conditional statements (elif and else)
  • How to import modules (random)
  • Using the Random() function to get a random number from a range

Curriculum Connections Summary

  • Ontario - Mathematics & Computer Science
  • Quebec - Coming Soon!
  • New Brunswick - Coming Soon!
  • Nova Scotia - Coming Soon!
  • Alberta - Coming Soon!
  • British Columbia - Coming Soon!
  • Manitoba - Coming Soon!
  • Prince Edward Island - Coming Soon!
  • Saskatchewan - Coming Soon!
  • Newfoundland & Labrador - Coming Soon!
  • Yukon Territories - Follow's B.C.'s Curriculum
  • Northwest Territories - Follows Alberta's Curriculum
  • Nunavut - Follows Alberta's Curriculum


Find Out More


mBlock (Python Coding)
mBlock (Python Coding)

mBlock and Python Coding - The Programming Language of the Future

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. With mBlock, Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form.