TeCoEd (Teaching Computing Education)
  • Home
    • Freelance
    • Book
    • Downloading
  • Python
    • Learn Python >
      • Python Modules
    • PyGame Zero
    • Python Programs >
      • Higher or Lower
      • Magic Calculator
      • Password Checker
      • Python Pit
    • What's News App
    • Pixels to Cells
    • Python Mosaics
    • Python OCR
    • L-1-AM
    • Web Scraping >
      • Scraping Trains
    • Weather App
    • Snakes and Windows
    • Python Web Server >
      • Flask
    • Python Picks
  • Raspberry Pi
    • All About the Pi
    • Getting Started
    • Remote Desktop and VNC
    • Static IP Address
    • Sonic Pi >
      • 3.14
    • Twitter Feed >
      • Tweepy
    • Android & Pi >
      • Advanced Apps
      • Odds
    • A.I on the the Pi
    • CRON
    • Pick Your Own
  • Pi Hardware
    • Pi HATS >
      • Sense Hat Hacks
      • AstroPi HAT
      • Unicorn-HAT >
        • Unicorn Alphabet Disco
        • Uni Codes / Programs
      • Skywriter
      • Piano HAT
    • STS Pi
    • Pi Camera >
      • Pi-Cam, Python & Email >
        • Time Lapse
      • Pi Noir
    • Pipsta >
      • Flask, Input & Printers
    • Raspberry Pi Power >
      • Energenie IR power
    • Pibrella
    • Distance Sensor
    • LCD Screen
    • Pi-Tooth
    • Robot Arm
    • PiGlow
    • PiFM
    • Accelerometer
    • PiFace >
      • Installing PiFace >
        • Python Commands
  • Pi-Hacks
    • Drone Hacks
    • Pi Glue Gun Hack
    • Blinkt!
    • Sonic Pixels
    • R2D2
    • Get to the chopper
    • Astro Bird
    • Twitter Translator
    • Hacking a Robot
    • Nature_Box >
      • Best Nature Photos
    • Wearable Tech >
      • Project New York
      • P.N.Y Part 2 Health
      • P.N.Y Part 3 Games
      • P.N.Y Part 4 Translation
    • Dino-Tweet
    • Other Links
  • Pi-Hacks 2
    • The Joker
    • Hologram Machine
    • Google Vision: Camera Tell
    • Yoda Tweets
    • Pi Phone
    • Darth Beats
    • Twitter Keyword Finder
    • Crimbo Lights Hack
    • Xmas Elf
    • Halloween 2016
    • Halloween Hack 2015
    • Socrative Zombie
    • Voice Translation
    • The Blue-Who Finder
    • GPIO, Twitter
    • Pi Chat Bot >
      • Dictionary Definitions
    • PiGlow & Email
    • Pibrella Alarm System
    • SMS with Python >
      • Spooking a Mobile
  • Pi-Hacks 3
    • David Bowie
    • Lamp Prank >
      • TEST
    • Yoda FM
    • Retro Player
    • LED Pixel Art
    • TARDIS
    • Battleships
    • LED Board
    • Night Vision
    • Enviro+ Weather
  • Minecraft
    • Minecraft API
    • Minecraft Sweeper
    • PiGlove: Minecraft Power Up
    • Minecraft Photo-booth
    • Rendering Pixels
    • Speed Cube
    • Lucky Dip
  • Computing
    • Why Computing?
    • Can You Compute
    • micro:bit
    • Coding Resources
    • Learn to Code >
      • Coding with iPads
      • Apps Creation Tools
      • sKratchInn
      • Sound Editing
    • Cheat Sheets
    • Theory
    • HOUR OF CODING
    • BEBRAS Computing Challange
    • Computer Facts
    • Free Software and Links
  • Contact Me

Cabbage...

1/31/2013

0 Comments

 
Charles Babbage or ‘Cabbage’, (as many of my students refer to him), spent a considerable amount of his time calculating all sorts of numerical values.  This included triangular numbers.  He was fascinated with statistics and used information and data to make predictions, calculations and decisions surrounding what might happen.   Babbage was so obsessed with this, that he created an engine that would allow him to input a number; the machine would process it and then produce an output.  He called it the Difference Engine.  This was the beginning of computation even though the machine was only a theoretical model with smaller working example models.  A complete working version was never built, but Babbage’s thinking was way ahead of his time.

Babbage spent numerous pain staking years calculating and recording these numbers in books and selling them to engineers, accountants and scientists.  What is incredible is that 200 years later, in the present day we can code a simple program that will calculate any number of triangular numbers that you so desire.

I asked my students to think about triangular numbers and how they could work them out, we come up various formulas, 
For example to calculate the 10th triangular number, (where zero is the first triangular number)

((The position of the triangular number minus 1) multiplied by 0.5)) multiplied by the position of the triangular number

((n-1)*0.5))*n

Next step was to create a program to test the formulas, using Python, 
This was a great exercise to introduce and use the ‘definition’ feature.  A definition allows you to create a set of steps or procedures that are called by a single name, for example the formula to calculate the triangular number,

def triangle_value(n):
    "Print the Triangular numbers for a given list"
        tn1 = (n-1)*0.5
        tnf = tn1*n
    print tnf
   
Then the user can call the definition by using the name of it, triangle_ value (insert a number of your choice).  It saves time having to type out the formula for every single number that  you enter.

The program can then be adapted to add in a pause and use a while statement to count down the triangular  numbers from say, 10 to 0.

import time
def triangle_value(n):
    "Print the Triangular numbers for a given list"
    while n > 0:
        tn1 = (n-1)*0.5
        tnf = tn1*n
        print "The", n, "Triangular number is", tnf
        n = n - 1
        time.sleep(1)
  
x = input("Enter how many triangular numbers you want to find?")

triangle_value(x)         

Download it here  


0 Comments



Leave a Reply.

    Author

    TeCoEd

    Archives

    August 2020
    July 2020
    October 2014
    April 2014
    February 2014
    January 2014
    November 2013
    September 2013
    August 2013
    July 2013
    June 2013
    March 2013
    January 2013

    Categories

    All
    Binary
    Computing
    Education
    Font
    New
    Nqt
    Pixels
    Primary
    Programming
    Teaching

    RSS Feed

Copyright 2020 TeCoEd @dan_aldred