image

Welcome to Computing Corner (renamed in light of new English National Curriculum) this is a regular column about computing and coding in the classroom. Written by Dan Aldred (@Dan_Aldred) who is well worth a follow on Twitter. Dan’s article is about his students use of programming to work with triangular numbers.

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 10thtriangular 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,

deftriangle_value(n):

"Print the Triangular numbers for a given list"

tn1 = (n-1)*0.5

tnf = tn1*n

printtnf

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

deftriangle_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)

I hope this has inspired you to try some of this programming at home.

Dan’s new website has some brilliant ‘How to’ programming guides http://itecdigital.weebly.com/

clip_image004

Dan Aldred is a teacher of Computing and Head of IT. He is also a member of the school extended leadership team and teacher learning group.  He’s interested in how technology and software move learning forward.

Written by Julian S Wood - www.ideasfactory.me/about/"rel="author"
About me
UK Primary School Future Learning Technologist.I am into Experience and Fun Based Learning.I use web tools to stimulate writing. I've been Playing and Learning since 1970. Have some fabulous ideas now & again.. Check out my about.me profile!
Click Here to View All Nominated Educators
My LinkedIn Profile

To see my LinkedIn profile, click here:

Julian S Wood
edublogs-nominated-bestindivtweeter-150x150
Subscribe
Email subscription to blog
Map
Privacy Policy
Privacy Policy - www.ideasfactory.me

Privacy Policy for www.ideasfactory.me

If you require any more information or have any questions about our privacy policy, please feel free to contact us by email at skyblue_jules@talk21.com.

At www.ideasfactory.me, the privacy of our visitors is of extreme importance to us. This privacy policy document outlines the types of personal information is received and collected by www.ideasfactory.me and how it is used.

Log Files
Like many other Web sites, www.ideasfactory.me makes use of log files. The information inside the log files includes internet protocol ( IP ) addresses, type of browser, Internet Service Provider ( ISP ), date/time stamp, referring/exit pages, and number of clicks to analyze trends, administer the site, track users movement around the site, and gather demographic information. IP addresses, and other such information are not linked to any information that is personally identifiable.

Cookies and Web Beacons
www.ideasfactory.me does not use cookies.

DoubleClick DART Cookie

.:: Google, as a third party vendor, uses cookies to serve ads on www.ideasfactory.me.
.:: Google's use of the DART cookie enables it to serve ads to your users based on their visit to www.ideasfactory.me and other sites on the Internet.
.:: Users may opt out of the use of the DART cookie by visiting the Google ad and content network privacy policy at the following URL - http://www.google.com/privacy_ads.html

Some of our advertising partners may use cookies and web beacons on our site. Our advertising partners include
Google Adsense

These third-party ad servers or ad networks use technology to the advertisements and links that appear on www.ideasfactory.me send directly to your browsers. They automatically receive your IP address when this occurs. Other technologies ( such as cookies, JavaScript, or Web Beacons ) may also be used by the third-party ad networks to measure the effectiveness of their advertisements and / or to personalize the advertising content that you see.

www.ideasfactory.me has no access to or control over these cookies that are used by third-party advertisers.

You should consult the respective privacy policies of these third-party ad servers for more detailed information on their practices as well as for instructions about how to opt-out of certain practices. www.ideasfactory.me's privacy policy does not apply to, and we cannot control the activities of, such other advertisers or web sites.

If you wish to disable cookies, you may do so through your individual browser options. More detailed information about cookie management with specific web browsers can be found at the browsers' respective websites.