Programming Assignments - Beginning 1
This page contains some classic beginning programming exercises. Everyone starts somewhere, and problems like these have been the starting point for everyone who has done programming (Gates, Zuckerberg, Jobs, Hopper, Lovelace, ...).
Problems
- Hello world - make the program print "Hello World!"
- Say hello to me - make the program ask for the user’s name, then say “Hello NAME”
- Loop through text - print each letter from a string (aka text) on its own line
- Count letter - loop through a string, count how many times ‘a’ occurs
- Remove spaces - create a new string that has letters of old string but no spaces
- ASCII code - print letters from a to z along with their ASCII code values
- Count up - print numbers from 1 to 10, one per line
- Count down - print numbers from 10 down to 1, then blastoff
- Add up - add numbers from 1 to 10
- String explosion - start with a string, inside a loop make it double itself, make loop go 5 times
- Password check - ask user for password, if they don’t type “please” ask again, keep asking until right
- Addition facts - print addition facts and answers (0 + 0 = 0, 1 + 1 = 2, etc.), one per line
- Math facts - same but with multiplication, division, subtraction
- Random number - choose a random number and print it
- Random coins - choose 'heads' or 'tails' at random, print it, repeat 10 times, count how many heads
- Math quiz - pick two random numbers, print addition question, ask for answer, check if correct
- Powers of two - print the powers of two from 0 up to 10
- Factorials - print 1!, 2!, 3!, 4!, 5!, up to 10!
- Factors - ask for integer, loop through possible factors, print all its factors
- Is prime - ask for integer, check if prime (if only factors are 1 and itself)