1
Home
Tirsvad edited this page 2026-11-15 10:25:17 +01:00

English · Dansk · Bahasa Melayu

Guess The Number

A beginner-friendly Number Guessing Game for the terminal.

What is it?

Day 12 of the Udemy course 100 Days of Code: The Complete Python Pro Bootcamp. The computer picks a number between 1 and 100. The player chooses a difficulty (easy gives 10 attempts, hard gives 5) and is told after each guess whether it was too high or too low.

What the exercise teaches

  • Writing functions with parameters and return values
  • Understanding variable scope and keeping state in arguments instead of global variables
  • Repeating input until it is valid, and ending a loop when the attempts run out
  • Writing small automated tests that replace the input

What it does

  • A random number between 1 and 100
  • Two difficulty levels: easy (10 attempts) and hard (5 attempts)
  • A hint after every guess: too high or too low
  • Input validation: only a whole number in range is accepted, and the difficulty is asked again until it is valid

Next