Skip to main contentSkip to main content
Room Banner
Back to all walkthroughs
Room Icon

Python: Simple Demo

Premium room

Explore what a basic Python program looks like.

easy

60 min

28,814

User profile photo.
User profile photo.

To access material, start machines and answer questions login.

In the first two rooms, Data Representation and Data Encoding, we learned how computers understand numbers, characters, colors, and even emojis. In this room, we will explore one of the most popular and friendly programming languages, Python.

You may have heard of the Python programming language numerous times. Python is a high-level general-purpose programming language. By high-level, we mean it hides most implementation details; general-purpose means you can use Python for a wide variety of scenarios, from web applications and automation scripts to data science and machine learning.

In this room, we will create a “Guess the Number” game. Our plan will be as follows:

  1. The computer secretly picks a number between 1 and 20.
  2. The user keeps guessing until they get it right.
  3. The computer tells the user whether their guess is too low or too high.

An example session running the program is shown below:

Terminal
           ubuntu@tryhackme:~$ python guess_the_number.py
I'm thinking of a number between 1 and 20
Take a guess: 10
Too high, try again.
Take a guess: 5
Too low, try again.
Take a guess: 7
Too low, try again.
Take a guess: 8
You got it in 4 tries!
        

Learning Objectives

  • Learn about Python variables
  • Understand how conditional statements are used
  • See iteration (loop) in action

Prerequisites

Answer the questions below

Let’s code our game!

Ready to learn Cyber Security?

The Python: Simple Demo room is only available for premium users. Signup now to access more than 500 free rooms and learn cyber security through a fun, interactive learning environment.

Already have an account? Log in

We use cookies to ensure you get the best user experience. For more information see our cookie policy.