The MC Byte

← Return to all blogs

May 6, 2021

5 Coding Challenges Every Beginner Should Try

The more you use the logic and tools you’ve learned, the better a coder you’ll become.

Studying can only get you so far. The best way to become a better programmer is to practice, practice, practice.

Once you have the basics down, and a decent grasp on the main tools you can use in a language, challenge yourself! The more you use the logic and tools you’ve learned, the better a programmer you’ll become.

Here are five mini-projects to get you started:

Note: These projects are language agnostic, meaning you can complete them in any language that can print to a console!

Fizz Buzz

Prompt: Write a program that outputs numbers 1-100, replacing numbers with Fizz and Buzz according to the rules.

The Rules:

  • If a number is divisible by three, replace it with “Fizz”
  • If a number is divisible by five, replace it with “Buzz”
  • If a number is divisible by both three and five, replace it with “Fizz Buzz”

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
Fizz Buzz

Bonus: Add another word to replace numbers that are divisible by two. Every time an even number pops up, replace it with “Squizz”.

1
Squizz
Fizz
Squizz
Buzz
Fizz Squizz
7
Squizz
Fizz
Squizz Buzz

Even or Odd?

Prompt: Write a program that receives a whole number from a user. Return whether that number is even or odd.

“Enter a whole number”
> 17

“Your number is odd!”

Bonus: Return a prompt if a user enters something other than a whole number. Only run the rest of the code if a proper number is entered

“Enter a whole number”
> 17.83

“Error. Please enter a whole number.”

Print a Pyramid

Prompt: Write a program that outputs a pyramid that’s five rows tall. Each row should have one more star displayed than the last, and should be centered so that the output is shaped like a classic pyramid.

     *

    * *

   * * *

  * * * *

 * * * * *

Bonus: Make your pyramid modifiable by user input. Prompt the user to enter a number, and have your pyramid output that many rows!

Call & Response

Prompt: Write a program that asks users a set of questions. Use their answers to create a paragraph.

You find yourself on a bridge. You must answer three questions to safely pass across.

“What is your name?”
> Sir Lancelot of Camelot

“What is your Quest?”
> seek the Holy Grail

“What is your favorite color?”
> blue

“Your name is Sir Lancelot of Camelot. You wish to seek the Holy Grail.
Your favorite color is blue. Right. Off you go.”

Bonus: Ask a question that has a single correct answer. Prompt the user to answer it! Return one response if they answer correctly, and another if they answer wrong.

“What is the air-speed velocity of an unladen swallow?”
> An African or European swallow?

“What? I don’t know that! Auuuuuuugh!”
The questioner falls. You may pass.

Sort Bot 1.0

Prompt: Write a program that organizes an array of unsorted numbers by increasing value.

Before: [15, 2, 47, 3, 12]

After: [2, 3, 12, 15, 47]

Bonus: Have a user input a list of numbers, separated by spaces. Output those numbers in numerical order

"Enter five numbers, separated by spaces"
> 64 28 2 37 50

"I sorted them for you!"
2 28 37 50 64

Where’s the Solutions?

Before you look up the answers, search that brain of yours. The output examples above are written in Markdown, meaning you won’t be able to find the solutions by inspecting this page.

Try it out! If you get any of these programs to work, in any language of your choice, you’ve succeeded.

Good luck, coders!

Authors

Olivia is a technical writer and content marketing director based in sunny California.