Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Assignment

This is the firststep in creating an 8-puzzle ArrangeNumbers game.

Write a script file arrangenumbers_0_1.py where you write a docstring containing:

 one line summary (at least filename and a short description)


 @author: your name

For more on commenting and documenting your code

Write a script where you:

 print the title of the game


 create a list of numbers containing values:  '4', '7', '2', '6', '8', '3', '5', '_', '1'
 create a tuple check containing values: '1', '2', '3', '4', '5', '6', '7', '8', '_' 
 item ‘_’ marks “empty” in the game
 print both
o the numbers to be arranged and
o check to show the correct order
 ask user which number to move, no checking of validity of input is needed, if the
given number is not in numbers list the program is allowed to throw en exception and
close 
 find the index of the number user gave. For more information see  Python - Get Index
or Position of Item in a List - Python Examples
 change the content of the “empty” and the number user provided in numbers list. For
examples on how to swap two elements in a list see Python program to swap two
elements in a list - GeeksForGeeks
 repeat (ask for input and do the swap) 8 times and check if the numbers are in order
i.e.compare the content of numbers and check. Remember you can only compare
elements of a same type e.g.. Convert Python List to Tuple or Tuple ordering and
deep comparisons in Python - Trey Hunner
 print the result (are the numbers in order or not i.e. is the content of numbers the same
as the content of check)

An example of running script is 


Return the script file.

You might also like