Difference between revisions of "Programming Assignments - Beginning 1"

From Computer Science
Jump to: navigation, search
(Problems)
(Solutions)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 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, ...).
+
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, ...)
 +
 
 +
Note that you cannot start working on these problems until you have something you are reading through to learn a language (a book, tutorial, getting started, something).  For suggestions, see [[Programming and CS - Getting Started]].
 +
 
 +
Also, when you are done with most of the programs on this page you might check out [[Programming Assignments - Beginning 2]] for more to work on.
  
 
=Problems=
 
=Problems=
Line 22: Line 26:
 
# ''Factors'' - ask for integer, loop through possible factors, print all its factors
 
# ''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)
 
# ''Is prime'' - ask for integer, check if prime (if only factors are 1 and itself)
 
=Solutions=
 
Solutions in Python - [https://repl.it/@kinnejeff/Programming-Assignment-1]
 

Latest revision as of 03:16, 6 November 2020

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, ...).

Note that you cannot start working on these problems until you have something you are reading through to learn a language (a book, tutorial, getting started, something). For suggestions, see Programming and CS - Getting Started.

Also, when you are done with most of the programs on this page you might check out Programming Assignments - Beginning 2 for more to work on.

Problems

  1. Hello world - make the program print "Hello World!"
  2. Say hello to me - make the program ask for the user’s name, then say “Hello NAME”
  3. Loop through text - print each letter from a string (aka text) on its own line
  4. Count letter - loop through a string, count how many times ‘a’ occurs
  5. Remove spaces - create a new string that has letters of old string but no spaces
  6. ASCII code - print letters from a to z along with their ASCII code values
  7. Count up - print numbers from 1 to 10, one per line
  8. Count down - print numbers from 10 down to 1, then blastoff
  9. Add up - add numbers from 1 to 10
  10. String explosion - start with a string, inside a loop make it double itself, make loop go 5 times
  11. Password check - ask user for password, if they don’t type “please” ask again, keep asking until right
  12. Addition facts - print addition facts and answers (0 + 0 = 0, 1 + 1 = 2, etc.), one per line
  13. Math facts - same but with multiplication, division, subtraction
  14. Random number - choose a random number and print it
  15. Random coins - choose 'heads' or 'tails' at random, print it, repeat 10 times, count how many heads
  16. Math quiz - pick two random numbers, print addition question, ask for answer, check if correct
  17. Powers of two - print the powers of two from 0 up to 10
  18. Factorials - print 1!, 2!, 3!, 4!, 5!, up to 10!
  19. Factors - ask for integer, loop through possible factors, print all its factors
  20. Is prime - ask for integer, check if prime (if only factors are 1 and itself)