Monday, 8 October 2012

Programs to build

Programs to build

Hello World
Write a program which outputs the words "hello world".
You will need: print

Hello name
Write a program which asks a user for their name, then outputs "Hello _____ " (With ____ being whatever they typed in.
Extension: Ask the user for their first name and surname separatley  but print them out on the same line ("Hello _firstname_ _surname_")
You will need: print, input, variables

Mathematical operators
Write a program which asks a user to input their date of birth. The program then adds together what they input and outputs a number. The program should tell the user that this is their lucky number.
Extension: Adapt the program so that it is not obvious what maths has been done to calculate the lucky number (a bit like a secret code)
You will need: print, input, variables, mathematical operators

Writing lists
Write a program which stores 10 of your favourite things in a list. Using code delete out the 6th item in the list, add another favourite thing to the end of the list and print the list out 5 times. It is a good idea to check that your code is working properly - and we do this by printing out the list every time we change it.
You will need: list, print, delete, append

Using tuples
Write a program which stores a list of numbers in a turple, and a list of numbers in a list. The program should output the fourth number in the list, and the third number in the tuple.
Extension: Do some maths combining numbers from the list and tuple and output the answers.
You will need: list, turple, print

No comments:

Post a Comment