Save this video free

Python (Fall 2026) Module 6-5: Loops in Practice Guessing Game

Bill Moseley, Ph.D. - Computer Science Educator · 17:43 · Watch on YouTube

Part of Bakersfield College COMP B10. See all 36 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

Bill Moseley builds a Python number-guessing game using `random.randint`, a `while` loop, and `if`/`elif`/`else` comparisons, giving the player three guesses to find a number from 1 to 10. He then adds a remaining-guesses display and an outer replay loop, demonstrating how configurable variables and `break` statements control game flow while noting that input validation is omitted for simplicity.

Key takeaways

Chapters

0:00 Build the Guessing Game with a Three-Guess Loop
9:12 Show Remaining Guesses and Adjust Game Difficulty
11:37 Add a Replay Loop with `while True`

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:02 So, let's, let's take our guessing game. Remember  the number guessing game we did a little while back? And I want to take that, and let's rebuild  that. Let's rebuild that really quick. But let's use a loop so that you can give the user multiple  guesses. Okay. So, let's, let's talk about this. I'm gonna do my little welcome here. Okay. So, I'm going to create a few  variables that allow me to adjust the difficulty of this game kind of on  the fly. So, I'm going to say int number guesses.

0:57 That's kind of a long variable name. I'm just  going to call it NG for number of guesses. Why? Because there aren't there very many, there  aren't very many variables in this game, and I'll be able to remember what this is. So,  I'm going to try three guesses. I'm also going to, intMin number is one. intMax is 10. So  basically what I'm setting up here is, I'm going to give the user three guesses  to, to try and figure out a number between 1 and 10. So the first thing I want to do  is I want to create that secret number. intSecret =. Now remember, we have to use random  for this. So, if I want to use random, I'm going

1:52 to come up to the top and I'm going to import  random so that I can have access to that library. So, I put import random up at the top. And now I  can use random.randint, which allows me to pick a random integer. And this is where I'm going to  plug in my variables for min, minimum and maximum. So, it's going to be between one and 10. But now  I can easily adjust the difficulty of my game by changing the value of these variables. I could  say between one and 100 or something like that.

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.