teachComputing
  • Home
  • AI
    • AI Literacy >
      • AI Alliteration
      • Describing Monsters
      • Dystopian writing
      • Bringing literacy to life with AI
      • AI Literacy Prompts
    • AI Computing >
      • AI Computing Lessons >
        • Make me happy
        • Chatting Robot
        • Supervised Learning
        • Fooled
        • Socratic Debate
        • Moral Machine
      • AI Coding Strategies
      • AI Computing Prompts
    • AI Prompts
  • Teaching & Learning
    • Wellbeing
    • Blog
    • Humour >
      • Teacher Humour
      • Teacher Humor
    • PLN Challenge >
      • Covering your backside
      • Online Privacy
      • Twitter Challenge >
        • Twitter All Star
        • Challenge 1
        • Challenge 2
        • Challenge 3
        • Tips for staying safe on Twitter
        • Tips for hosting Edu Twitter Chats
        • Tips for taking part in Twitter chats
        • It's all about the hashtag! Essential chats for educators
        • How to storify a chat
        • How to schedule Tweets
        • Twitter Lists
        • NT2tEU
      • Facebook Challenge >
        • Challenge 4
        • Challenge 5
        • Challenge 6
        • Tips for staying safe on Facebook
      • Google Challenge >
        • Challenge 7
        • Challenge 8
        • Challenge 9
      • Pinterest Challenge >
        • Challenge 10
        • Challenge 11
        • Challenge 12
        • Tips for using Pinterest
      • Blog Challenge >
        • Challenge 13
        • Challenge 14
        • Challenge 15
        • How to create a classroom blog
      • Staffrm Challenge >
        • Challenge 16
        • Challenge 17
        • Challenge 18
      • Skype Challenge >
        • Challenge 19
        • Challenge 20
        • Challenge 21
      • Edmodo Challenge >
        • Challenge 22
        • Challenge 23
        • Challenge 24
      • TeachMeet Challenge >
        • Challenge 25
        • Challenge 26
        • Challenge 27
      • In-school challenge >
        • Challenge 28
        • Challenge 29
        • Challenge 30
      • 30 ways to grow your PLN
    • Tools for Teachers >
      • Web 2.0 >
        • Top 10 Web 2.0 Tools
        • Classroom Response Tools
      • Quiz Tools
      • Classroom Management Tools
      • Software >
        • Media Conversion Tools
        • Application Software
      • Multimedia >
        • Free Music
    • BYOD
    • Digital Leaders >
      • Digital Leaders Blog >
        • DL Archive
      • DL Tips
      • Quotes
      • Links
    • Flipped Learning >
      • Flipped Classroom vs. Blended Classroom
    • Gamification >
      • Gamification vs. Game Based Learning vs. Game Design
    • School Closures
    • Game Based Learning >
      • Minecraft >
        • Minecraft in Education
        • Minecraft Lesson Ideas
        • Minecraft Literacy
        • Real Life Minecraft
        • Minecraft Top Tips
        • Minecraft Coding Tutorials >
          • Minecraft Code Builder Setup
          • Minecraft Code: Walking on Air
          • Minecraft Code: Hello World
          • Minecraft Code: Functions
          • Minecraft Code: Rainbow
          • Minecraft Code: Skyscraper
          • Minecraft Pixel Art
    • The magic of >
      • The magic of Computing
      • The magic of Maths
      • The magic of Science
      • The magic of Literacy
    • Road2e2
    • T&L Blog
  • Computing
    • Computing Blog >
      • GCSE Computer Science
      • General
    • Teaching Computer Science >
      • CPD >
        • Blocks to Code
        • Tutorials >
          • How to embed Flash into PowerPoint
          • How to embed YouTube videos in to PowerPoint
          • How to create a wiki
          • How to create a classroom blog
      • Schemes of Work
      • Programming Resources
      • Theory
      • Posters
      • Festive Computing Activities
      • FLOPPYS 2020
      • FLOPPYS 2021
      • FLOPPYS 2022
      • Game Design
      • App Creation
    • Theory Lessons >
      • Theory Tests
      • Computer Hardware >
        • Input / Output
        • CPU
        • LMC
        • Storage Devices
        • Memory (RAM / ROM)
        • Hardware
      • Binary Lessons >
        • Units of Data
        • Binary Representation
        • Binary Representation of Images
        • Binary Representation of Images (Festive)
        • Binary Representation of Characters
        • Binary Representation of Sound
        • Binary Representation of Instructions
        • Binary Addition
        • Hexadecimal
      • Software >
        • Operating System
        • Types of Software
        • Utility Software
      • Programming >
        • Flowcharts
      • Computational Thinking >
        • Data Science
    • Digital Literacy >
      • Social Media (Good or Bad thing?)
      • Cyberbullying
      • Staying Safe Online
    • ICT Strand >
      • Fake News Project >
        • Fake News 1
        • Fake News 2
        • Fake News 3
        • Fake News 4
        • Fake News 5
      • Spreadsheet Modelling
      • Superhero Movie Trailer
      • PowerPoint Task
      • Digital Imaging
      • Paint 3D Tutorial
    • Programming Lessons >
      • Scratch >
        • Festive Scratch >
          • Music Festive with Scratch
          • Turtle Snowflakes
          • What's your elf name
          • Secret Santa
        • Making music with Scratch
        • Sorting Hat Lesson
        • Turtle Time
        • Superhero name generator
        • Compliment Generator
        • Magic 8 ball
      • Python >
        • Chatbot
        • Coding Golf
        • Turtle Time >
          • Turtle Instructions
        • Magic 8 ball
        • Python Mad Libs
        • Rock Paper Scissors
        • Shakespearean Insult Generator >
          • Shakespearean Insult Generator Part 2
        • Compliment generator
        • Sorting Hat
        • Superhero name generator
        • Cards Against
        • Guess the word
        • Guess the number
        • Festive Python >
          • What's your elf name
          • Secret Santa
          • Turtle Snowflakes
      • Little Man Computer
      • Hour of Code >
        • Hour of Code Music
        • Python Tutorials
        • HoC 8-Bit Challenge
        • Music MicroPython (Festive)
      • Raspberry Pi >
        • Networking the Pi
        • Minecraft Pi
        • Harry Potter Sorting Hat >
          • Harry Potter Sorting Hat (GPIO)
        • Raspberry Pi LTSP (Networked Classroom)
        • Astro Pi
    • Homeschooling
    • Remote Learning >
      • Fun Python Tutorials
      • Python Tutorials >
        • Chatbot Tutorial
        • Dice Roll
        • Turtle Tutorial
        • Magic 8 ball
        • Sorting Hat
        • Rock Paper Scissors Tutorial
        • Cards Against
        • Python Mad Libs
        • Shakespearean Insult Generator >
          • Shakespearean Insult Generator Part 2
        • Guess the word
        • Guess the number
        • Superhero name generator
        • Compliment generator
        • Festive Python Tutorials >
          • What's your elf name
          • Secret Santa
          • Turtle Snowflakes
      • Scratch Tutorials >
        • Sorting Hat
        • What's your superhero name
        • Turtle Time Tutorial
        • Compliment Generator
        • Magic 8 Ball
        • Festive Scratch Tutorials >
          • Festive Music with Scratch
          • Secret Santa Scratch Tutorial
          • Turtle Snowflakes Tutorial
          • What's your elf name
    • Revision >
      • Data Representation >
        • Binary Representation of Images
        • Binary Representation of Sound
  • 21 Things
    • 21 Things To Try >
      • ConnectEd
      • Social Media >
        • Twitter
        • Pinterest
        • Facebook Groups
        • Facebook Pages
        • Google+ Communities
        • Staffrm
        • Edmodo
        • Mystery Skype
        • Blogging
        • Classroom Blogging
      • Gamification
      • Flipped Classroom
      • Breakout Edu
      • Edu Podcasts
      • Jar of Awesome
      • TeachMeet
      • Team Teaching
      • Mixed Reality
      • Digital Leaders
      • Genius Hour
      • Sketchnoting
    • Computing >
      • CS 20
      • Code Golf
      • PRIMM
      • Under The Hood
      • Unplugged
      • Podcasts
      • Facebook Groups CS
      • Flipped Classroom CS
      • Teach with Magic
      • Socratic Debate
      • Coding Music
    • 21 Things Keep Fit >
      • 20 Health Hacks
      • Home Health Hacks
    • 21 Things PLN >
      • Edmodo
      • Twitter
      • Reply to a blog
      • Skype
      • Cofee Edu
      • Pinterest
      • Reach out
      • Conferences
      • Instagram
      • Ning
      • MEC
      • Voxer
      • LinkedIn
  • Microbit
    • Physical Computing >
      • micro:bit LEDs
      • micro:bit PIR
      • micro:bit Servo
      • micro:bit Temp
      • micro:bit LDR
      • micro:bit Moisture
      • micro:bit RGB LEDs
      • micro:bit HC-SR04 3v3
      • micro:bit HC-SR04 5v
      • micro:bit Push button
      • micro:bit Potentiometer
      • micro:bit Piezo
    • Music >
      • Music Festive
    • Festive Projects
    • Projects >
      • Music
      • Music MicroPython
      • Servo Animals
    • Lessons >
      • Magic 8 Ball
      • Harry Potter Sorting Hat
    • Quick Start Guide
    • Microbit Simulator
  • #100 Ideas
    • Testimonials
    • Competition >
      • Competition 2
    • Worksheets
    • Bonus Ideas >
      • What's your elf name
      • Make me happy
      • Guess the word
      • Cards Against Humanities
      • Compliment generator
      • Data Science
    • Curriculum
    • ISTE
    • CSTA
  • About
    • Privacy
  • Home
  • AI
    • AI Literacy >
      • AI Alliteration
      • Describing Monsters
      • Dystopian writing
      • Bringing literacy to life with AI
      • AI Literacy Prompts
    • AI Computing >
      • AI Computing Lessons >
        • Make me happy
        • Chatting Robot
        • Supervised Learning
        • Fooled
        • Socratic Debate
        • Moral Machine
      • AI Coding Strategies
      • AI Computing Prompts
    • AI Prompts
  • Teaching & Learning
    • Wellbeing
    • Blog
    • Humour >
      • Teacher Humour
      • Teacher Humor
    • PLN Challenge >
      • Covering your backside
      • Online Privacy
      • Twitter Challenge >
        • Twitter All Star
        • Challenge 1
        • Challenge 2
        • Challenge 3
        • Tips for staying safe on Twitter
        • Tips for hosting Edu Twitter Chats
        • Tips for taking part in Twitter chats
        • It's all about the hashtag! Essential chats for educators
        • How to storify a chat
        • How to schedule Tweets
        • Twitter Lists
        • NT2tEU
      • Facebook Challenge >
        • Challenge 4
        • Challenge 5
        • Challenge 6
        • Tips for staying safe on Facebook
      • Google Challenge >
        • Challenge 7
        • Challenge 8
        • Challenge 9
      • Pinterest Challenge >
        • Challenge 10
        • Challenge 11
        • Challenge 12
        • Tips for using Pinterest
      • Blog Challenge >
        • Challenge 13
        • Challenge 14
        • Challenge 15
        • How to create a classroom blog
      • Staffrm Challenge >
        • Challenge 16
        • Challenge 17
        • Challenge 18
      • Skype Challenge >
        • Challenge 19
        • Challenge 20
        • Challenge 21
      • Edmodo Challenge >
        • Challenge 22
        • Challenge 23
        • Challenge 24
      • TeachMeet Challenge >
        • Challenge 25
        • Challenge 26
        • Challenge 27
      • In-school challenge >
        • Challenge 28
        • Challenge 29
        • Challenge 30
      • 30 ways to grow your PLN
    • Tools for Teachers >
      • Web 2.0 >
        • Top 10 Web 2.0 Tools
        • Classroom Response Tools
      • Quiz Tools
      • Classroom Management Tools
      • Software >
        • Media Conversion Tools
        • Application Software
      • Multimedia >
        • Free Music
    • BYOD
    • Digital Leaders >
      • Digital Leaders Blog >
        • DL Archive
      • DL Tips
      • Quotes
      • Links
    • Flipped Learning >
      • Flipped Classroom vs. Blended Classroom
    • Gamification >
      • Gamification vs. Game Based Learning vs. Game Design
    • School Closures
    • Game Based Learning >
      • Minecraft >
        • Minecraft in Education
        • Minecraft Lesson Ideas
        • Minecraft Literacy
        • Real Life Minecraft
        • Minecraft Top Tips
        • Minecraft Coding Tutorials >
          • Minecraft Code Builder Setup
          • Minecraft Code: Walking on Air
          • Minecraft Code: Hello World
          • Minecraft Code: Functions
          • Minecraft Code: Rainbow
          • Minecraft Code: Skyscraper
          • Minecraft Pixel Art
    • The magic of >
      • The magic of Computing
      • The magic of Maths
      • The magic of Science
      • The magic of Literacy
    • Road2e2
    • T&L Blog
  • Computing
    • Computing Blog >
      • GCSE Computer Science
      • General
    • Teaching Computer Science >
      • CPD >
        • Blocks to Code
        • Tutorials >
          • How to embed Flash into PowerPoint
          • How to embed YouTube videos in to PowerPoint
          • How to create a wiki
          • How to create a classroom blog
      • Schemes of Work
      • Programming Resources
      • Theory
      • Posters
      • Festive Computing Activities
      • FLOPPYS 2020
      • FLOPPYS 2021
      • FLOPPYS 2022
      • Game Design
      • App Creation
    • Theory Lessons >
      • Theory Tests
      • Computer Hardware >
        • Input / Output
        • CPU
        • LMC
        • Storage Devices
        • Memory (RAM / ROM)
        • Hardware
      • Binary Lessons >
        • Units of Data
        • Binary Representation
        • Binary Representation of Images
        • Binary Representation of Images (Festive)
        • Binary Representation of Characters
        • Binary Representation of Sound
        • Binary Representation of Instructions
        • Binary Addition
        • Hexadecimal
      • Software >
        • Operating System
        • Types of Software
        • Utility Software
      • Programming >
        • Flowcharts
      • Computational Thinking >
        • Data Science
    • Digital Literacy >
      • Social Media (Good or Bad thing?)
      • Cyberbullying
      • Staying Safe Online
    • ICT Strand >
      • Fake News Project >
        • Fake News 1
        • Fake News 2
        • Fake News 3
        • Fake News 4
        • Fake News 5
      • Spreadsheet Modelling
      • Superhero Movie Trailer
      • PowerPoint Task
      • Digital Imaging
      • Paint 3D Tutorial
    • Programming Lessons >
      • Scratch >
        • Festive Scratch >
          • Music Festive with Scratch
          • Turtle Snowflakes
          • What's your elf name
          • Secret Santa
        • Making music with Scratch
        • Sorting Hat Lesson
        • Turtle Time
        • Superhero name generator
        • Compliment Generator
        • Magic 8 ball
      • Python >
        • Chatbot
        • Coding Golf
        • Turtle Time >
          • Turtle Instructions
        • Magic 8 ball
        • Python Mad Libs
        • Rock Paper Scissors
        • Shakespearean Insult Generator >
          • Shakespearean Insult Generator Part 2
        • Compliment generator
        • Sorting Hat
        • Superhero name generator
        • Cards Against
        • Guess the word
        • Guess the number
        • Festive Python >
          • What's your elf name
          • Secret Santa
          • Turtle Snowflakes
      • Little Man Computer
      • Hour of Code >
        • Hour of Code Music
        • Python Tutorials
        • HoC 8-Bit Challenge
        • Music MicroPython (Festive)
      • Raspberry Pi >
        • Networking the Pi
        • Minecraft Pi
        • Harry Potter Sorting Hat >
          • Harry Potter Sorting Hat (GPIO)
        • Raspberry Pi LTSP (Networked Classroom)
        • Astro Pi
    • Homeschooling
    • Remote Learning >
      • Fun Python Tutorials
      • Python Tutorials >
        • Chatbot Tutorial
        • Dice Roll
        • Turtle Tutorial
        • Magic 8 ball
        • Sorting Hat
        • Rock Paper Scissors Tutorial
        • Cards Against
        • Python Mad Libs
        • Shakespearean Insult Generator >
          • Shakespearean Insult Generator Part 2
        • Guess the word
        • Guess the number
        • Superhero name generator
        • Compliment generator
        • Festive Python Tutorials >
          • What's your elf name
          • Secret Santa
          • Turtle Snowflakes
      • Scratch Tutorials >
        • Sorting Hat
        • What's your superhero name
        • Turtle Time Tutorial
        • Compliment Generator
        • Magic 8 Ball
        • Festive Scratch Tutorials >
          • Festive Music with Scratch
          • Secret Santa Scratch Tutorial
          • Turtle Snowflakes Tutorial
          • What's your elf name
    • Revision >
      • Data Representation >
        • Binary Representation of Images
        • Binary Representation of Sound
  • 21 Things
    • 21 Things To Try >
      • ConnectEd
      • Social Media >
        • Twitter
        • Pinterest
        • Facebook Groups
        • Facebook Pages
        • Google+ Communities
        • Staffrm
        • Edmodo
        • Mystery Skype
        • Blogging
        • Classroom Blogging
      • Gamification
      • Flipped Classroom
      • Breakout Edu
      • Edu Podcasts
      • Jar of Awesome
      • TeachMeet
      • Team Teaching
      • Mixed Reality
      • Digital Leaders
      • Genius Hour
      • Sketchnoting
    • Computing >
      • CS 20
      • Code Golf
      • PRIMM
      • Under The Hood
      • Unplugged
      • Podcasts
      • Facebook Groups CS
      • Flipped Classroom CS
      • Teach with Magic
      • Socratic Debate
      • Coding Music
    • 21 Things Keep Fit >
      • 20 Health Hacks
      • Home Health Hacks
    • 21 Things PLN >
      • Edmodo
      • Twitter
      • Reply to a blog
      • Skype
      • Cofee Edu
      • Pinterest
      • Reach out
      • Conferences
      • Instagram
      • Ning
      • MEC
      • Voxer
      • LinkedIn
  • Microbit
    • Physical Computing >
      • micro:bit LEDs
      • micro:bit PIR
      • micro:bit Servo
      • micro:bit Temp
      • micro:bit LDR
      • micro:bit Moisture
      • micro:bit RGB LEDs
      • micro:bit HC-SR04 3v3
      • micro:bit HC-SR04 5v
      • micro:bit Push button
      • micro:bit Potentiometer
      • micro:bit Piezo
    • Music >
      • Music Festive
    • Festive Projects
    • Projects >
      • Music
      • Music MicroPython
      • Servo Animals
    • Lessons >
      • Magic 8 Ball
      • Harry Potter Sorting Hat
    • Quick Start Guide
    • Microbit Simulator
  • #100 Ideas
    • Testimonials
    • Competition >
      • Competition 2
    • Worksheets
    • Bonus Ideas >
      • What's your elf name
      • Make me happy
      • Guess the word
      • Cards Against Humanities
      • Compliment generator
      • Data Science
    • Curriculum
    • ISTE
    • CSTA
  • About
    • Privacy
Search by typing & pressing enter

YOUR CART

Guess the word (Python)

A self-directed (browser enabled) tutorial of this lesson (suitable for remote learning) can be found:
Guess the word tutorial
​How to create a 'guess the word' game in Python (Free python web tutorial).
Like this tutorial? Share it with your followers by clicking on the image below.
Picture

​Suggested time: 60 mins

Learning Objectives:
  • Understand and use sequence in an algorithm
  • Understand and use iteration in an algorithm (FOR and WHILE loops)
  • Understand and use selection in an algorithm (IF, Else and Else if)
  • Understand why it is so difficult to create a computer that can seemingly think for itself
  • Understand and use data structures in an algorithm (for example, Lists, Tables or Arrays)

Curriculum Mapping:

KS2:

  • Design, write and debug programs that accomplish specific goals; solve problems by breaking them into smaller parts. Select, use and combine a variety of software on a range of digital devices to design and create a range of programs.
  • Use sequence, selection and repetition in programs; work with variables and various forms of input and output
  • Use logical reasoning to explain how some simple algorithms work; detect and correct errors in algorithms and programs


KS3:

  • Use two or more programming languages, at least one of which is textual, to solve a variety of computational problems.

STUDENT: COMPUTATIONAL THINKER:

  • 5a: Students break problems into component parts, extract key information, and develop descriptive models to understand complex systems or facilitate problem-solving.
  • 5c: Students break problems into component parts, extract key information, and develop descriptive models to understand complex systems or facilitate problem-solving.
  • 5d: Students understand how automation works and use algorithmic thinking to develop a sequence of steps to create and test automated solutions.

 

 

EDUCATOR: COMPUTATIONAL THINKING COMPETENCIES:

  • 4b: Design authentic learning activities that ask students to leverage a design process to solve problems with awareness of technical and human constraints and defend their design choices.

 

COMPUTER SCIENCE EDUCATORS:

  • 2a: Plan and teach computer science lessons/units using effective and engaging practices and methodologies:

i. Select a variety of real-world computing problems and project-based methodologies that support active and authentic learning and provide opportunities for creative and innovative thinking and problem solving

ii. Demonstrate the use of a variety of collaborative groupings in lesson plans/units and assessments

iii. Design activities that require students to effectively describe computing artifacts and communicate results using multiple forms of media

iv. Develop lessons and methods that engage and empower learners from diverse cultural and linguistic backgrounds

v. Identify problematic concepts and constructs in computer science and appropriate strategies to address them

vi. Design and implement developmentally appropriate learning opportunities supporting the diverse needs of all learners

vii. Create and implement multiple forms of assessment and use resulting data to capture student learning, provide remediation and shape classroom instruction

 

CSTA K–12 CS Standards:

  • 1B-AP-08: Compare and refine multiple algorithms for the same task and determine which is the most appropriate.
  • 1B-AP-09: Create programs that use variables to store and modify data.
  • 1B-AP-10: Create programs that include sequences, events, loops, and conditionals.
  • 1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.
  • 1B-AP-13: Use an iterative process to plan the development of a program by including others' perspectives and considering user preferences.
  • 1B-AP-15: Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended.
  • 1B-AP-17: Describe choices made during program development using code comments, presentations, and demonstrations.
  • 2-AP-11: Create clearly named variables that represent different data types and perform operations on their values
  • 2-AP-12: Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.
  • 2-AP-15: Seek and incorporate feedback from team members and users to refine a solution that meets user needs.
  • 2-AP-16: Incorporate existing code, media, and libraries into original programs, and give attribution.
  • 2-AP-17: Systematically test and refine programs using a range of test cases.
  • 3A-AP-14: Use lists to simplify solutions, generalizing computational problems instead of repeatedly using simple variables.
  • 3A-AP-15: Justify the selection of specific control structures when tradeoffs involve implementation, readability, and program performance, and explain the benefits and drawbacks of choices made.

AREA OF LEARNING AND EXPERIENCE: Science and Technology:

Computation is the foundation for our digital world.

Progression step 3        

  • I can use conditional statements to add control and decision-making to algorithms.
  • I can identify repeating patterns and use loops to make my algorithms more concise.
  • I can explain and debug algorithms.

 

Progression step 4

  • I can decompose given problems and select appropriate constructs to express solutions in a variety of environments.
  • I can select and use data structures that efficiently manage data in algorithms.
  • I can plan and implement test strategies to identify errors in programs.

 

Progression step 5

  • I can identify, define and decompose problems, choose appropriate constructs and express solutions in a variety of environments.
  • I can use file-handling techniques to manipulate data in algorithms.
  • I can test, evaluate and improve a solution in software.

 


Introduction:

How the game works

1. The game will start by picking a random word or phrase from a list.
2. Next, each letter in the word or phrase is replaced by a dash '-' or 'underscore '_'.
e.g.
DONALD TRUMPS
becomes
_ _ _ _ _ _ / _ _ _ _ _ _
3. Finally, the player must guess the word by suggesting different letters.

Rules:
  • If the player guesses a correct letter, the letter is revealed in the phrase. 
  • For each letter the player guesses wrong, the player will lose a life.
Picture

In this lesson, students will learn how to create their very own 'guess the word' game using Python. 
Part 1: Introducing the String Slicing

Before creating their 'guess the word game', start by having the students explore some of the functions they will be using. 

STEP 1
Start by s
haring the following line of code to replace a character at specific index in a string.

Explain to the students that to replace a character with a given character at a specified index, you can use python string slicing as shown below:
Picture
Share the following code for students to copy. Ask the students to predict what the program does before running the code.
string = "pythonhxamples"
position = 6
character = "e"

string = string[:position] + character + string[position+1:]
print(string)
Try it yourself:
After running the program, ask the students to comment their code, using the hashtag (#), to explain what each line of the the code is doing.

​Explain that, in our game, we need to replace each letter in our word or phrase with a dash '-' or 'underscore '_'.


Challenge 1
  • Challenge the students to modify their code (above) so that it changes the 3rd letter to an underscore '_'.

STEP 2
Explain to the students that in order to change all the letters in our word or phrase, they are going to need a loop.

Ask the students copy and run the following code (You can try the code yourself using the code window above):
string = "TRUMP"
character = "_"
for i in range (len(string)):
  string = string[:i] + character + string[i+1:]
print(string)
Problem! Ask the students if they can see the problem with their code?

Explain to the students that because there are no spaces in between each of the hidden letters, we can't tell how many letters there are in our word!

Ask the students to replace the last line in their code with the following.
Important! (Inform students that they must ensure that they put a space between the two speech marks " "): 
​print(" ".join(string))
Ask the students to run their code again and ​to comment their code, using the hashtag (#), to explain what the new code is doing.

Part 2: Creating a random name picker

Explain to the students that in order to make our game more challenging, each time the player plays the game it will pick a new word at random from a list.

Start by having the students practice this by creating a random name picker. 

STEP 1
Tell the students that they are now going to create a random name picker and that this will form the basis of their 'guess the word' game.

Share the following code for students to copy (You can test this for yourself using the code window below):
import random

names = ["Bob", "Dave", "Stuart"]

print(names[random.randint(0,2)])


Challenge:

Ask the students to comment their code, using the hashtag (
#), to explain what each line of the code is doing and why the random generator is returning a value between 0 and 2 rather than 1 and 3.

Explain to the students that lists start at 0 NOT 1.

e.g. if we were to run the following code:

print(names[0])

The computer would return the name “Bob”


STEP 2
  • Ask the students to replace the last line with the following new code:

print(random.choice(names))

Have the students run their new script and explain what the new code does.

 
STEP 3 

Finally, explain to the students that, in order for our program to work, we need to add (concatenate) the word “Minion” at the beginning of our randomly selected name.
​

  • Ask the students to replace the last line with the following:
print(“Minion” + “ “ + random.choice(names))

Have the students run their new script and explain what the new code does.


Challenge:
  • Ask the students to add some more names to their list.

Part 3: Creating the 'guess the word' game.

Explain to the students that they now have all the components they need to create their very own guess the word game.

Share the following code for students to copy (You can try the code yourself using the code window below):
​import random

#create a list of hangman words
wordList = ["cat","dog","mouse"]

#choose a word from the list at random
wordChosen = random.choice(wordList)

#create an empty list to store the used letters
used = []

#create a variable to store and display the player's guesses  
display = wordChosen
for i in range (len(display)):
  #replace each letter with a '_'
  display = display[0:i] + "_" + display[i+1:]
  
#put a space between each dash
print (" ".join(display))

#counter stops the game once all letters have been guessed correctly
attempts = 0

#keep asking the player untill all letters are guessed
while display != wordChosen:
  guess = input("Please enter a letter: ")
  guess = guess.lower()
  #Add the players guess to the list of used letters
  used.extend(guess)
  print ("Attempts: ")
  print (attempts)
  
  #Search through the letters in answer
  for i in range(len(wordChosen)):
    if wordChosen[i] == guess:
      display = display[0:i] + guess + display[i+1:]

  print("Used letters: ")
  print(used)
      
  #Print the string with guessed letters (with spaces in between))
  print(" ".join(display))
  attempts = attempts + 1
  
print("Well done, you guessed right!)
Example Solutions

guess_the_word_solution.zip
File Size: 1 kb
File Type: zip
Download File

Challenge:
Challenge the students to...
  1. Modify their code so that it tells the player how many guesses they made.
  2. Add some more words or phrases to their list.
  3. Modify their code so that it replaces spaces (" ") in a phrase with a slash "/".
  4. Add a 'life counter' and remove a life every time a player guesses an incorrect letter. The game ends if the player guesses correctly or they run out of lives (which ever comes first). 

You may also be interested in:
  • Python Mad Libs
  • Python Chat Bot
  • Code Golf
  • Python Sorting Hat
  • Python Magic 8-Ball ​
  • Cards Against Humanities
  • Guess the number

Licence:

Unless otherwise specified, everything in this repository is covered by the following licence:
Picture
Guess the word is licenced under a Creative Commons Attribution 4.0 International License.

Tags: programming language python, python programming language, python coding language, programming languages python, python code language, python programming language example, what is the python programming language, python scripting, python language tutorial, what type of programming language is Python, python class, python how to learn, learn python, learn python from scratch, where to learn Python, coding on computer, computer coding,  best place to learn coding online, online coding, online code, computer programming and Coding, hour of code program, computer science degree programs, programs for computer science, what does coding mean in computers, how does computer code work, what is computer programmer.
Powered by Create your own unique website with customizable templates.