Question: Given this list: list1= [5, 1, 2, 9] 1. What is the python statement used to access the first element of the list (L.e.,

Given this list: list1= [5, 1, 2, 9] 1. What is the

 python statement used to access the first element of the list (L.e., the value 5))? 2. What is the python statement used to access

Given this list: list1= [5, 1, 2, 9] 1. What is the python statement used to access the first element of the list (L.e., the value 5))? 2. What is the python statement used to access the last element of the list (i.e., the value 9))? 3. Answer question 2 above but use len [...] to access the last element of the list. Type your answers into python to check if you are right. 1-2: Suppose we have a string initialized as follows: stri = "5129" 1. What is the python statement used to access the first element of the string (i.e., the value 5))? 2. What is the python statement used to access the last element of the string (i.e. the value 9))? 3. Answer question 2 above but use len (...) to access the last element of the string. Reflection: The syntax for 1-1 and 1-2 is the same. Part 2: Creating and modifying lists Consider the following code (it may be on the next page depending on how long your answers are above): res1 - [] for i in range(5): 2 res1.append( i ) (a) print(res1) res2 - resi res2[0] - 99 print( res1) print( res2) DU res2 - [3,4] print(res1) (e) print( res2) (1) What is the code in the first for loop doing (see arrow #1)? Use plain English (not Python syntax) Sample answer: It adds numbers from 0 up to 4 to a list; afterward, the list is printed (2) What is the code in the first for loop doing (see arrow #2)? Use plain English (not Python syntax)

Step by Step Solution

3.45 Rating (165 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Solution Lets address your questions step by step For List 1 list1 To access the first element of th... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!