2nd Semester Intro to Computer Science

Lab 2.05 - Tic-Tac-Toe

In your Notebook

1. Predict what will be printed. Then run the program and confirm

Example 1

a = ['a', 'b', 'c', 'd', 'e']
print(a[0:3])
print(a[1:4])

Example 2

a = ['a', 'b', 'c', 'd', 'e']
print(a[1:len(a) - 3])

Example 3

a = ['a', 'b', 'c', 'd', 'e']
b = a.remove('b')
print(a)
print(b)

Example 4

a = ['a', 'b', 'c', 'd', 'e']
a[0] = 'haha'
b = a.pop()
print(a)
print(b)

Example 5

a = ['a', 'b', 'c', 'd', 'e']
b = a + ['abc']
print(a)
print(b)

Example 6

a = ['a', 'b', 'c', 'd', 'e']
b = a.append('f')
print(a)
print(b)

2. In your Console

We are going to start implementing Tic-Tac-Toe using a single list.

  1. The user picks a location on the board according to the number:

    tic-tac-toe

  2. Depending on the position that the user inputs, update the position of the board to an “X” to reflect that.
  3. Print the updated board out, but don’t worry about making it look pretty.
  4. Only need to implement one turn of the game

Edit this page Report an issue