Created
July 3, 2014 15:35
-
-
Save simonbrowndotje/989240fbc115e231297b to your computer and use it in GitHub Desktop.
A short Python 3 program that I used with year 6 at St Martin's School in Jersey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def removeRandomLetterFrom(word): | |
lengthOfWord = len(word) | |
randomNumber = random.randint(0, lengthOfWord-1) | |
letterToRemove = word[randomNumber] | |
newWord = "" | |
for letter in word: | |
if letter == letterToRemove: | |
newWord += "_" | |
else: | |
newWord += letter | |
return newWord | |
words = [ | |
"second", | |
"following", | |
"together", | |
"without", | |
"outside", | |
"suddenly", | |
"different", | |
"coming", | |
"between", | |
"across" | |
] | |
correctSpellings = 0 | |
for word in words: | |
print("How do you spell", removeRandomLetterFrom(word), "?") | |
spellingTry = input() | |
if spellingTry == word: | |
print(" - Well done, that's correct!") | |
correctSpellings += 1 | |
else: | |
print(" - Sorry, that's not correct.") | |
print("You got", correctSpellings, "out of", len(words), "correct") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment