Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 4 : Suppose we have the following list: list _ a = [ 1 , 2 , 3 , 4 list _ b =

Exercise 4: Suppose we have the following list:
list_a =[1,2,3,4
list_b = l'a','b', c','d'1
Create a third list, namely, list_c, with elements being 'al','bl','cl'. Then print elements of zip(list_a, list_b, list_c). Guess what would be the general rule when the iterables have different length?
Exercise 5: Suppose we have a list of students' phone numbers and a tuple of students'
names.
phone =[979921,989043,933043,932902]
student =('jane', 'nika', 'kian', 'mira')
In a single line of code, create a dictionary with phones as keys and names as values (hint: use zip()). Explain how the code works.
Exercise 6: Use the listcomp to create a list with three-tuple elements where each tuple contains a number between 1 and 10, its square and cubic; that is,
[O,0,0),
(1,1,1),
(2,4,8),
(3,9,27).
(4,16,64),
(5,25,125);
(6,36,216),
(7,49,343),
(8,64,512),
(9,81,729)]
Exercise 7: We have the following dictionary:
dict1={'Al': 100,'B1':20,'A2':30,'B2' :405,'A3':23}
Create a list of its values in one line code by:
* listcomp without using values) method
* iterator unpacking using values ( method
* list constructor using values method

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

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions

Question

25. Establish Equation (6.2) by differentiating Equation (6.4).

Answered: 1 week ago