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:
- The computer secretly picks a number between 1 and 20.
- The user keeps guessing until they get it right.
- The computer tells the user whether their guess is too low or too high.
An example session running the program is shown below:
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
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
