Last active
January 31, 2023 19:18
-
-
Save peteristhegreat/8ae6b84b7de073d54e14b7fd307cd0e8 to your computer and use it in GitHub Desktop.
1000 words in english language quiz, python
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
be | |
and | |
of | |
a | |
in | |
to | |
have | |
too | |
it | |
I | |
that | |
for | |
you | |
he | |
with | |
on | |
do | |
say | |
this | |
they | |
at | |
but | |
we | |
his | |
from | |
that | |
not | |
can’t | |
won’t | |
by | |
she | |
or | |
as | |
what | |
go | |
their | |
can | |
who | |
get | |
if | |
would | |
her | |
all | |
my | |
make | |
about | |
know | |
will | |
as | |
up | |
one | |
time | |
there | |
year | |
so | |
think | |
when | |
which | |
them | |
some | |
me | |
people | |
take | |
out | |
into | |
just | |
see | |
him | |
your | |
come | |
could | |
now | |
than | |
like | |
other | |
how | |
then | |
its | |
our | |
two | |
more | |
these | |
want | |
way | |
look | |
first | |
also | |
new | |
because | |
day | |
more | |
use | |
no | |
man | |
find | |
here | |
thing | |
give | |
many | |
well | |
only | |
those | |
tell | |
one | |
very | |
her | |
even | |
back | |
any | |
good | |
woman | |
through | |
us | |
life | |
child | |
there | |
work | |
down | |
may | |
after | |
should | |
call | |
world | |
over | |
school | |
still | |
try | |
in | |
as | |
last | |
ask | |
need | |
too | |
feel | |
three | |
when | |
state | |
never | |
become | |
between | |
high | |
really | |
something | |
most | |
another | |
much | |
family | |
own | |
out | |
leave | |
put | |
old | |
while | |
mean | |
on | |
keep | |
student | |
why | |
let | |
great | |
same | |
big | |
group | |
begin | |
seem | |
country | |
help | |
talk | |
where | |
turn | |
problem | |
every | |
start | |
hand | |
might | |
American | |
show | |
part | |
about | |
against | |
place | |
over | |
such | |
again | |
few | |
case | |
most | |
week | |
company | |
where | |
system | |
each | |
right | |
program | |
hear | |
so | |
question | |
during | |
work | |
play | |
government | |
run | |
small | |
number | |
off | |
always | |
move | |
like | |
night | |
live | |
Mr. | |
point | |
believe | |
hold | |
today | |
bring | |
happen | |
next | |
without | |
before | |
large | |
all | |
million | |
must | |
home | |
under | |
water | |
room | |
write | |
mother | |
area | |
national | |
money | |
story | |
young | |
fact | |
month | |
different | |
lot | |
right | |
study | |
book | |
eye | |
job | |
word | |
though | |
business | |
issue | |
side | |
kind | |
four | |
head | |
far | |
black | |
long | |
both | |
little | |
house | |
yes | |
after | |
since | |
long | |
provide | |
service | |
around | |
friend | |
important | |
father | |
sit | |
away | |
until | |
power | |
hour | |
game | |
often | |
yet | |
line | |
political | |
end | |
among | |
ever | |
stand | |
bad | |
lose | |
however | |
member | |
pay | |
law | |
meet | |
car | |
city | |
almost | |
include | |
continue | |
set | |
later | |
community | |
much | |
name | |
five | |
once | |
white | |
least | |
president | |
learn | |
real | |
change | |
team | |
minute | |
best | |
several | |
idea | |
kid | |
body | |
information | |
nothing | |
ago | |
right | |
lead | |
social | |
understand | |
whether | |
back | |
watch | |
together | |
follow | |
around | |
parent | |
only | |
stop | |
face | |
anything | |
create | |
public | |
already | |
speak | |
others | |
read | |
level | |
allow | |
add | |
office | |
spend | |
door | |
health | |
person | |
art | |
sure | |
such | |
war | |
history | |
party | |
within | |
grow | |
result | |
open | |
change | |
morning | |
walk | |
reason | |
low | |
win | |
research | |
girl | |
guy | |
early | |
food | |
before | |
moment | |
himself | |
air | |
teacher | |
force | |
offer | |
enough | |
both | |
education | |
across | |
although | |
remember | |
foot | |
second | |
boy | |
maybe | |
toward | |
able | |
age | |
off | |
policy | |
everything | |
love | |
process | |
music | |
including | |
consider | |
appear | |
actually | |
buy | |
probably | |
human | |
wait | |
serve | |
market | |
die | |
send | |
expect | |
home | |
sense | |
build | |
stay | |
fall | |
oh | |
nation | |
plan | |
cut | |
college | |
interest | |
death | |
course | |
someone | |
experience | |
behind | |
reach | |
local | |
kill | |
six | |
remain | |
effect | |
use | |
yeah | |
suggest | |
class | |
control | |
raise | |
care | |
perhaps | |
little | |
late | |
hard | |
field | |
else | |
pass | |
former | |
sell | |
major | |
sometimes | |
require | |
along | |
development | |
themselves | |
report | |
role | |
better | |
economic | |
effort | |
up | |
decide | |
rate | |
strong | |
possible | |
heart | |
drug | |
show | |
leader | |
light | |
voice | |
wife | |
whole | |
police | |
mind | |
finally | |
pull | |
return | |
free | |
military | |
price | |
report | |
less | |
according | |
decision | |
explain | |
son | |
hope | |
even | |
develop | |
view | |
relationship | |
carry | |
town | |
road | |
drive | |
arm | |
true | |
federal | |
break | |
better | |
difference | |
thank | |
receive | |
value | |
international | |
building | |
action | |
full | |
model | |
join | |
season | |
society | |
because | |
tax | |
director | |
early | |
position | |
player | |
agree | |
especially | |
record | |
pick | |
wear | |
paper | |
special | |
space | |
ground | |
form | |
support | |
event | |
official | |
whose | |
matter | |
everyone | |
center | |
couple | |
site | |
end | |
project | |
hit | |
base | |
activity | |
star | |
table | |
need | |
court | |
produce | |
eat | |
American | |
teach | |
oil | |
half | |
situation | |
easy | |
cost | |
industry | |
figure | |
face | |
street | |
image | |
itself | |
phone | |
either | |
data | |
cover | |
quite | |
picture | |
clear | |
practice | |
piece | |
land | |
recent | |
describe | |
product | |
doctor | |
wall | |
patient | |
worker | |
news | |
test | |
movie | |
certain | |
north | |
love | |
personal | |
open | |
support | |
simply | |
third | |
technology | |
catch | |
step | |
baby | |
computer | |
type | |
attention | |
draw | |
film | |
Republican | |
tree | |
source | |
red | |
nearly | |
organization | |
choose | |
cause | |
hair | |
look | |
point | |
century | |
evidence | |
window | |
difficult | |
listen | |
soon | |
culture | |
billion | |
chance | |
brother | |
energy | |
period | |
course | |
summer | |
less | |
realize | |
hundred | |
available | |
plant | |
likely | |
opportunity | |
term | |
short | |
letter | |
condition | |
choice | |
place | |
single | |
rule | |
daughter | |
administration | |
south | |
husband | |
Congress | |
floor | |
campaign | |
material | |
population | |
well | |
call | |
economy | |
medical | |
hospital | |
church | |
close | |
thousand | |
risk | |
current | |
fire | |
future | |
wrong | |
involve | |
defense | |
anyone | |
increase | |
security | |
bank | |
myself | |
certainly | |
west | |
sport | |
board | |
seek | |
per | |
subject | |
officer | |
private | |
rest | |
behavior | |
deal | |
performance | |
fight | |
throw | |
top | |
quickly | |
past | |
goal | |
second | |
bed | |
order | |
author | |
fill | |
represent | |
focus | |
foreign | |
drop | |
plan | |
blood | |
upon | |
agency | |
push | |
nature | |
color | |
no | |
recently | |
store | |
reduce | |
sound | |
note | |
fine | |
before | |
near | |
movement | |
page | |
enter | |
share | |
than | |
common | |
poor | |
other | |
natural | |
race | |
concern | |
series | |
significant | |
similar | |
hot | |
language | |
each | |
usually | |
response | |
dead | |
rise | |
animal | |
factor | |
decade | |
article | |
shoot | |
east | |
save | |
seven | |
artist | |
away | |
scene | |
stock | |
career | |
despite | |
central | |
eight | |
thus | |
treatment | |
beyond | |
happy | |
exactly | |
protect | |
approach | |
lie | |
size | |
dog | |
fund | |
serious | |
occur | |
media | |
ready | |
sign | |
thought | |
list | |
individual | |
simple | |
quality | |
pressure | |
accept | |
answer | |
hard | |
resource | |
identify | |
left | |
meeting | |
determine | |
prepare | |
disease | |
whatever | |
success | |
argue | |
cup | |
particularly | |
amount | |
ability | |
staff | |
recognize | |
indicate | |
character | |
growth | |
loss | |
degree | |
wonder | |
attack | |
herself | |
region | |
television | |
box | |
TV | |
training | |
pretty | |
trade | |
deal | |
election | |
everybody | |
physical | |
lay | |
general | |
feeling | |
standard | |
bill | |
message | |
fail | |
outside | |
arrive | |
analysis | |
benefit | |
name | |
sex | |
forward | |
lawyer | |
present | |
section | |
environmental | |
glass | |
answer | |
skill | |
sister | |
PM | |
professor | |
operation | |
financial | |
crime | |
stage | |
ok | |
compare | |
authority | |
miss | |
design | |
sort | |
one | |
act | |
ten | |
knowledge | |
gun | |
station | |
blue | |
state | |
strategy | |
little | |
clearly | |
discuss | |
indeed | |
force | |
truth | |
song | |
example | |
democratic | |
check | |
environment | |
leg | |
dark | |
public | |
various | |
rather | |
laugh | |
guess | |
executive | |
set | |
study | |
prove | |
hang | |
entire | |
rock | |
design | |
enough | |
forget | |
since | |
claim | |
note | |
remove | |
manager | |
help | |
close | |
sound | |
enjoy | |
network | |
legal | |
religious | |
cold | |
form | |
final | |
main | |
science | |
green | |
memory | |
card | |
above | |
seat | |
cell | |
establish | |
nice | |
trial | |
expert | |
that | |
spring | |
firm | |
Democrat | |
radio | |
visit | |
management | |
care | |
avoid | |
imagine | |
tonight | |
huge | |
ball | |
no | |
close | |
finish | |
yourself | |
talk | |
theory | |
impact | |
respond | |
statement | |
maintain | |
charge | |
popular | |
traditional | |
onto | |
reveal | |
direction | |
weapon | |
employee | |
cultural | |
contain | |
peace | |
head | |
control | |
base | |
pain | |
apply | |
play | |
measure | |
wide | |
shake | |
fly | |
interview | |
manage | |
chair | |
fish | |
particular | |
camera | |
structure | |
politics | |
perform | |
bit | |
weight | |
suddenly | |
discover | |
candidate | |
top | |
production | |
treat | |
trip | |
evening | |
affect | |
inside | |
conference | |
unit | |
best | |
style | |
adult | |
worry | |
range | |
mention | |
rather | |
far | |
deep | |
front | |
edge | |
individual | |
specific | |
writer | |
trouble | |
necessary | |
throughout | |
challenge | |
fear | |
shoulder | |
institution | |
middle | |
sea | |
dream | |
bar | |
beautiful | |
property | |
instead | |
improve | |
stuff | |
claim |
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
#!/usr/bin/env python3 | |
import os | |
import sys | |
import random | |
def make_quiz(count): | |
# change the path to where the script is located | |
abspath = os.path.abspath(__file__) | |
dname = os.path.dirname(abspath) | |
os.chdir(dname) | |
word_list_file = "1000.txt" | |
if not os.path.isfile(word_list_file): | |
print("Error: File not found", word_list_file) | |
print(" Looking in folder", os.getcwd()) | |
exit(1) | |
# read in the 1000 most common English words file | |
with open(word_list_file, "r") as f: | |
words_orig = f.readlines() | |
# remove whitespace before and after each word | |
words = [w.strip() for w in words_orig] | |
# make sure count isn't too big or too small | |
if count > len(words): | |
print("Reduced count to", len(words)) | |
count = len(words) | |
elif count < 1: | |
print("Increased count to 1") | |
count = 1 | |
# Did we read in a valid file? | |
# print(words[0], words[99], words[999]) | |
random.shuffle(words) | |
# slice the array to use the first "count" number of words | |
words_subset = words[0:count] | |
print("== Quiz ==") | |
for i, word in enumerate(words_subset): | |
# for word in words_subset: | |
print(i+1, word) if i >= 9 else print(i+1, " " + word) | |
print("---") | |
random.shuffle(words_subset) | |
for i, word in enumerate(words_subset): | |
# print the index at the start of the line | |
print(i+1, "", end="") if i >= 9 else print(i+1, " ", end="") | |
for j, letter in enumerate(word): | |
# default to printing an underscore | |
out = "_" | |
if j == 0 or j == len(word) -1: | |
# first letter last letter, use letter instead | |
out = letter | |
# print the letter or underscore with a space | |
print(out, " ", end='', sep='') | |
# print a new line after each word | |
print() | |
def usage(): | |
print("Please pass the count of words to use in the quiz") | |
print(" e.g. {} {}".format(sys.argv[0], 10)) | |
if __name__ == "__main__": | |
count = 10 | |
if len(sys.argv) > 2: | |
print("Error: Too many arguments") | |
usage() | |
exit(1) | |
elif len(sys.argv) == 2: | |
try: | |
# convert the first argument into an integer | |
count = int(sys.argv[1]) | |
except Exception as e: | |
print("Error: '{}' isn't a valid number".format(sys.argv[1])) | |
usage() | |
exit(1) | |
else: | |
try: | |
# read in text from the user | |
count = int(input("Enter count (default=10):")) | |
except Exception as e: | |
print("Defaulting to 10") | |
count = 10 | |
# run the main program with the input received | |
make_quiz(count) |
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
#!/usr/bin/env bash | |
count=10 | |
file=1000.txt | |
for i in $(seq $count); do | |
printf "$i " | |
sed $((RANDOM % 1000))'q;d' $file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment