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 was the basis of my first lesson back with the students. First create 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.
Example code
#Christmas thank you letters
import random
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(random.choice(t))
print "\nMany thanks again"
print "\nFrom", yn
This was the basis of my first lesson back with the students. First create 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.
Example code
#Christmas thank you letters
import random
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(random.choice(t))
print "\nMany thanks again"
print "\nFrom", yn