Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 1 Accessing values of a list and slicing strings. Given the list named pizzas : In [ ] : pizzas = ['cheese', 'pepperoni', 'margherita',
Exercise 1 Accessing values of a list and slicing strings. Given the list named pizzas : In [ ] : pizzas = ['cheese', 'pepperoni', 'margherita', 'hawailan', 'italian sausage', 'green pe a) Grab the first flavor, assign the value to a variable named first_f lavor, and print it. In [ ] : In [ ] b) Grab the last flavor, assign the value to a variable named last_flavor, and print it. In [ ] In []: c) Access the element of the pizza lis that corresponds to 'pepperoni', replace it for 'mushroom', and print the pizzas list. In [ ]: In [ ]: 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 varlable name less_pizzas, and print it. In [ ] : In []: Exercise 2 Lists inside lists: accessing and appending values. Given the list named pizzas_prices . In [ ] : pizzas_prices =[[ 'cheese ' ,9],[ 'mushroom' ,10.5],[ 'margherita', 8], ['hawaiian', 13] a) Grab the first element, assign the value to a variable named option_1, and print it. In [ ] In [ ] b) Grab the last element, assign the value to a variable named option_2, and print it. In []: In [ ]: c) From option_1 and option_2 that you created in the previous exercise, grab the price value of each of them, assign the values to cheese_price and hawaiian_price respectively, and print them. In [ In [ ]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started