Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is my assignment in Python Accessing values of a list and slicing strings. Given the list ramed pf zeas : In [ 14 pizzas

This is my assignment in Python
image text in transcribed
image text in transcribed
Accessing values of a list and slicing strings. Given the list ramed pf zeas : In [ 14 pizzas = ['cheese', 'popperoni', 'margherita', 'hawaikan', 'italian sausage', 'green peppers and onions'] a) Grab the first flavor, assign the value to a variable named first, flavor, and print it. In {2}= In I1I first_flavor = "cheese" print(first_flavor) cheese. b) Grab the last fiavor, assign the value to a variable named last flavor, and print it. In [3]t last_flavor = "green peppers and onions" print (last flavor) green peppers and onions In I ]: c) Access the element of the pizza lis that corresponds to "pepperoni', replace it for and print the pizzas list. In I ]: P.YOUR CODE ZERE raise NotimplementedFrror() In \& 1: d) By using slicing, grab the sub-list that conttins all the options except the first one and the last one, assign the result to a variable name less pizzas . and print it. In I It I YoUR CODE HRRE raiso Notimplenentedsrrof() Lists inside lists: accossing and appending values. Given the list named pizzan pricen. a) Grab the first element, assign the value to a varlable named option_1, and print it. In{4}=In(11: \[ \text { In }[4]=\begin{aligned} \text { option_1 } & =\text { "cheese" } \\ & \text { print(option_1) } \\ & \text { cheene } \end{aligned} \] b) Grab the last olement, assign the value to a variable named option_2, and print it. InIIfoption2=In(1; c) From option_1 and option_2 that you created in the previous axerciso, grab the price value of each of them, assign the values to cheetbe.price and hovaitan price respectively, and print them. In1 In1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions