Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is my assignment Accessing values of a list and sicing strings, Given the list ramed pizzas : In [ 1: pizzas = ['cheese', 'popperoni',

image text in transcribed
image text in transcribed
image text in transcribed
This is my assignment
Accessing values of a list and sicing strings, Given the list ramed pizzas : In [ 1: pizzas = ['cheese', 'popperoni', 'margherita', 'hawaitan', 'italitan sausage', 'greon peppers and onions'] a) Grab the first fiavor, assign the value to a variable named firat,flavor, and print it. In [2]; firnt_flavor = "cheese" print(first flavor) cheese In I 1n 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 "pepperond', replace it for and print the pizias list. In I 1: P YOUR CODE ZERE raise NotimplementedFrror() In I ]: d) By using slicing, grab the sub-list that contains 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 If / YOUR CODE HRRE Faiso Notrmplenentedzrrof() Lists inside lists: accossing and appending values. Given the list named pizzan pricen. InIIfpizzasprices-[fcheese,9].[mushroom,10.5],Imargherite,B],[hawaitan,13)] a) Grab the first element, assign the value to a variable named option_1, and print it. In(4)=In(1: \[ \text { In }[4]: \begin{array}{l} \text { option_1 }=\text { "cheese" } \\ \text { print(option_1) } \\ \text { cheone } \end{array} \] b) Grab the last element, assign the value to a variable named option_2. and print it. In[inoption2=In(1) c) From option_1 and option_2. that you created in the previous exerciso, grab the price value of each of them, assign the values to cheete price and havaiian price respectively, and print them. In1In1 Given the list named new pizzas In I It new plzzas = ['eheese', 'pepperon'', 'margherita', 'hawalian', 'italian sausage', 'qreen peppers and onions'] a) Use a list method that lots you add a new flavour to add "spinach and fota" to the end of the list. In 1 it YoUN coDs HERE raise Notimplementederrorf() In in It b) Grab the oloment with value 'itatian nausage' from the list nev pizzab, assign it to a variable named my ptzza. In i 11= your coos HER : raise Notimpleftentedkrror() In 1ln c) From the variable ny piza grab the slce that comesponds to 'italian' and the slice that corresponds to speces), assign them to variablos named word 1 and vord 2 rospoctively, and print them. tbe carntud, don't include In In

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions