1. LIST (the values are represented in [ ]). Step 1.  Predict the output of this code. Write down what each line does. Make sure you number each line with your answer. Don’t worry about making mistakes, it is part of the learning process. Don’t run the code yet.    Step 2.  Type the code into a file named task01.py. Run the code. Attach a screenshot of your code and answer.    Step 3.  Explain any discrepancies between your predictions and the actual output. Write down where you made the mistakes and what you understood after obtaining the answer. Number the lines where the mistakes are made with your reasoning.  Study this code:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

1. LIST (the values are represented in [ ]).

Step 1

Predict the output of this code. Write down what each line does. Make sure you number each line with your answer. Don’t worry about making mistakes, it is part of the learning process. Don’t run the code yet. 
 

Step 2

Type the code into a file named task01.py. Run the code. Attach a screenshot of your code and answer. 
 

Step 3

Explain any discrepancies between your predictions and the actual output. Write down where you made the mistakes and what you understood after obtaining the answer. Number the lines where the mistakes are made with your reasoning. 

Study this code:

def list_demo () :
my_list = [64, 'hello', 105.7, '', [0,1,2], False]
print('la. ', my_list[2:4])
print('lb. ', my_list[4] [2])
my_list[3] = True
print('lc. ', my_list)
print('1d. ', my_list[-1])
my_list.append (True)
print('le. ', len(my_list))
print('lf. ', my_list[4:6] + ['2014/11/06', 5])
my_list.extend (' 2014/11/06'.split('/'))
print('1g. ',
my_list = my_list + [105.7, False, list('abc'), '"]
my_list.remove(105.7)
print('lh. ', my_list)
print('li. ', len(my_list))
print('lj. ', my_list.index(True))
%3D
len (my_list))
Transcribed Image Text:def list_demo () : my_list = [64, 'hello', 105.7, '', [0,1,2], False] print('la. ', my_list[2:4]) print('lb. ', my_list[4] [2]) my_list[3] = True print('lc. ', my_list) print('1d. ', my_list[-1]) my_list.append (True) print('le. ', len(my_list)) print('lf. ', my_list[4:6] + ['2014/11/06', 5]) my_list.extend (' 2014/11/06'.split('/')) print('1g. ', my_list = my_list + [105.7, False, list('abc'), '"] my_list.remove(105.7) print('lh. ', my_list) print('li. ', len(my_list)) print('lj. ', my_list.index(True)) %3D len (my_list))
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY