Loading video player…

Creating a Python Dice Roll Application (Overview)

In this video course, you’ll learn how to create a Python dice roll simulator. The course guides you through building a text-based user interface (TUI) application that simulates rolling dice using Python’s random module. You’ll learn to gather and validate user input, use random.randint() for dice rolling, and display results with ASCII art.

By the end of this video course, you’ll understand that:

  • To simulate dice-rolling events, you can use random.randint() .
  • To get the user’s input, you use the built-in input() function.
  • To display dice in Python, you generate ASCII art representations of dice faces and use print().
  • To manipulate strings, you use methods such as .center() and .join().
Download

Course Slides (.pdf)

4.4 MB
Download

Sample Code (.zip)

6.2 KB

00:00 Hello and welcome to Creating a Python Dice Roll Application. My name is Joseph, and I’ll be your concierge for this video course. In this course, you’ll create a Python dice-rolling simulator.

00:11 Ah yes. Finally, freed from the limitations of physical dice, this incredible app is sure to astonish your friends and family. Alright, maybe astonish isn’t quite the right word, but in your journey as a Python developer, building small projects like this can really help you improve and cement your skills, and that’s pretty cool too.

00:29 This app uses a text-based user interface, also known as a TUI, to simulate rolling dice and randomness is implemented with Python’s built-in random module. You’ll be able to roll up to six dice with each die having six faces.

00:43 After rolling, the application will generate an ASCII diagram of dice representing the results. That will then be displayed on screen to the user. Throughout this course, you’ll learn how to use random, .randint() to simulate dice-rolling events, how to capture and read user inputs using the built-in input() function, how to display ASCII art, representations of dice faces to the user with print(), how to manipulate Python strings using methods like .center() and .join().

01:10 And finally, how to improve the design of a Python program using refactoring.

01:15 Now, before we get rolling, it will help if you’re already familiar with a few core concepts: running Python scripts, variables, and constants in Python, fundamental Python data types like str, int, and list, comparison operators and logical expressions, and control flow techniques like conditionals and for loops.

01:35 If you’re still getting the hang of some of these, don’t let that deter you. Sometimes, the best way to learn is to challenge yourself and try something that may seem like it’s beyond your reach.

01:44 And if things get a little too dicey, you can always take a break and read some articles on realpython.com. Alright, you’re ready to get started, but first, you’ll need to define the project requirements.

01:55 What should the project do and how will it do that? That’s what the next lesson is all about. See you there.

Become a Member to join the conversation.