question archive File: lists_warmup

File: lists_warmup

Subject:Computer SciencePrice: Bought3

File: lists_warmup.py

 a new directory for this prac, then a new Python file called lists_warmup.py and enter the following line:

numbers = [3, 1, 4, 1, 5, 9, 2]

What values do the following expressions have? Without running the code, record your answers to these questions in your Python file as a comment.
Then use the Python console to see if you were correct.

numbers[0]
numbers[-1]
numbers[3]
numbers[:-1]
numbers[3:4]
5 in numbers
7 in numbers
"3" in numbers
numbers + [6, 5, 3]

In the same Python file, write statements to achieve the following:

  1. Change the first element of numbers to "ten" (the string, not the number 10)
  2. Change the last element of numbers to 1
  3. Print all the elements from numbers except the first two (slice)
  4. Print whether 9 is an element of numbers

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions