Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment consists of two scripts. First Script Working with Lists All print output should include descriptions as shown in the example output below. Create

This assignment consists of two scripts.

First Script Working with Lists

All print output should include descriptions as shown in the example output below.

Create an empty list called list1

Populate list1 with the values 1,3,5

Create list2 and populate it with the values 1,2,3,4

Create list3 by using + (a plus sign) to combine list1 and list2. Print list3.

Use sequence operator in to test list3 to see if it contains a 3, print True/False result (do with one line of code).

Count the number of 3s in list3, print the result.

Determine the index of the first 3 in list3, print the result.

Pop this first 3 and assign it to a variable called first3, print first3.

Create list4, populate it with list3's sorted values, using the sorted built-in function.

Print list3 and list4.

Slice list3 to obtain a list of the values 1,2,3 from the middle of list3, print the result.

Determine the length of list3, print the result.

Determine the max value of list3, print the result.

Sort list3 (use the list sort method), print list3.

Create list5, a list of lists, using list1 and list2 as elements of list5, print list5.

Print the value 4 contained within list5.

Example output:

d) list3 is: [1, 3, 5, 1, 2, 3, 4] e) list3 contains a 3: True f) list3 contains 2 3s g) The index of the first 3 contained in list3 is 1 h) first3 = 3 j) list3 is now: [1, 5, 1, 2, 3, 4] j) list4 is: [1, 1, 2, 3, 4, 5] k) Slice of list3 is: [1, 2, 3] l) Length of list3 is 6 m) The max value in list3 is 5 n) Sorted list3 is: [1, 1, 2, 3, 4, 5] o) list5 is: [[1, 3, 5], [1, 2, 3, 4]] p) Value 4 from list5: 4 

Second Script Bit Operators

Assign the values 9 and 14 to variables a and b respectively.

Print the binary values of a and b (use the bin built-in function).

Calculate the value of a and b, print the result in binary.

Calculate the value of a or b, print the result in binary.

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 

Add the following at the end of the script to show your results:

''' Execution results: paste execution results here '''

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions