Welcome to Coding Corner-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 write thank-you letters.
Christmas is a time that you may, if are lucky enough receive some gifts. Then comes that time when you should politely write and thank the givers of the gifts. How about if you could write a program to create these letters?
This will be the basis of my first lesson back with the students.
First I created some variables,
yn = this is your name
r = this is the person that you are writing to
p = this is the name of the person that gave you the present
t = [a random list of various nice comments for the recipient]
Next create the letter using the print function.
I have also used the new line feature \n to place the sentences on new lines.
Extensions activities would be for students to code the letter to print out or write to another file, maybe allow the user to create all the letters at once.
#Christmas thank you letters
yn = raw_input("Please enter your name ")
r = raw_input("please enter the name of the person you are writing to " )
p = raw_input("please enter the present that you were given ")
t =[‘It really was a lovely present’,
‘I am so touched that you purchased the present’,
‘How very lucky I am I feel warm inside’,
‘It was such an amazing present’]
print ‘\nDear’, r
print ‘\nI am writing to say thank you for my Christmas present, I have always wanted a’, p
print "\nIt was very kind of you"
print "\nMany thanks again"
print "\nFrom", yn
Why not try some of this programming at home?
Dan’s new website has some brilliant ‘How to’ programming guides http://itecdigital.weebly.com/
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"