Question: In Python Problem 2 A) Using a combination of list subsetting and variable assignment, create a new variable named sum_cases that contains the sum of

In Python

Problem 2

A) Using a combination of list subsetting and variable assignment, create a new variable named sum_cases that contains the sum of Prince William's cases and Loudoun's cases. Refer to the cases list below. Print the new variable sum_cases.

In [ ]:

 
cases = ['Fairfax', 66703, 
 'Prince William', 39398, 
 'Virginia Beach', 30652, 
 'Loudoun', 23126, 
 'Arlington', 13182]
# Enter your code below this line:
 

B) Use slicing to create a list, top_3, that contains the first 4 elements of cases. Do a similar thing to create a new variable, last_2, that contains the last 4 elements of cases. Print both top_3 and last_2 using print().

In [ ]:

 
cases = ['Fairfax', 66703, 
 'Prince William', 39398, 
 'Virginia Beach', 30652, 
 'Loudoun', 23126, 
 'Arlington', 13182]
# Enter your code below this line:
 

C) Update cases for Virginia Beach and add an additional 348 cases. Print cases

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!