Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can I write this in python? First Seript - Working with Lists All print output should include descriptions as shown in the example output

How can I write this in python?

image text in transcribed

image text in transcribed

First Seript - Working with Lists All print output should include descriptions as shown in the example output helow. a. Create an empty list called list 1 b. Populate listl with the values 1,3,5 c. Swap the second and third elements of listl. d. Iterate over list1 and print its items. c. Create list2, initialized with the values 1,2,3,4 f. Create list3 by combining list 1 and list2 (use the + operator). g. Print list3. h. Use sequence operator in to test list3 to see if it contains a 3, print True/False result (do with one line of code). i. Count the number of 3s in list 3 , print the result. j. Determine the index of the first 3 in list 3 , print the result. k. Pop this first 3 and assign it to a variable called first3, print first3. 1. Create list4, populatc it with list.3's sorted values, using the sorted built-in function. m. Print list3. n. Print list4. o. Slice list3 to obtain a list of the values 1,2,3 from the middle of list3, print the result. p. Determine the length of list 3 , print the result. q. Determine the max value of list 3 , print the result. r. Sort list3 (use the list sort method), print list3. s. Create list5, a list of lists, using list1 and list2 as elements of list5. t. Print list5. u. Print the value 4 contained within list5. Example output: d) Items in list1: 51 ) list3 is: [1,5,3,1,2,3,4] h) list3 contains a 3: True i) 7 ist 3 contains 235 j) The index of the first 3 contained in list3 is 2 k) first3 =3 m) list3 is now: [1,5,1,2,3,4] n) list4 is: [1,1,2,3,4,5] o) Slice of list3 is: [1,2,3] p) Length of list3 is 6 a) The max value in 1ist3 is 5 r) Sorted list3 is: [1,1,2,3,4,5] t) list5 is: [[1,5,3],[1,2,3,4]] u) Value 4 from list5: 4 Second Script - Bit Operators a. Assign the values 9 and 14 to variables a and b respectively. b. Print the binary values of a and b (use the bin built-in function). c. Calculate the value of a and b, print the result in binary. d. Calculate the value of a or b, print the result in binary. e. Examine the results. Can you see how they were arrived at? Example output: b) binary of a=0b1001 b) binary of b=0b1110 c) binary of a \& b =0b1000 d) binary of a b=0b1111

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions