Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSCI 203 Introduction to CS I; Practice Problems 1. What does the following code print? a [1, 2, 3, 41 bI21 6 print { 'a-,

image text in transcribed

CSCI 203 Introduction to CS I; Practice Problems 1. What does the following code print? a [1, 2, 3, 41 bI21 6 print { 'a-, a, 'b-, b) explain the answer printed in 2 problem number 1 3. What is printed when you invoke prob3()? def eat(x): x[119 x131-11 def prob3 0 Eoodt, 5, 6,7 eat (food) print('food, food) problem number 3. 5. Write a function create2DArray with two inputs height and width that creates and returns a 2D array (ie., a list of lists) with values that are the row number multiplied by the column number. For example >>>create2DArray (3, 5) Lt0, 0, 0, 0, 0, [0, 1, 2, 3, 41, 0, 2, 4, 6, 8]1 6. Write a function addOne with one input anArray which is a 2D array (a list of lists). Your function will add 1 to each element of anarray. For example >>> myArray create2 DArray (3,5) >>> addone (myArray) >>>myArray 7. Create a Python class named Phonebook. Add an inst method that creates an attribute called phonebook. Initialize phonebook to be a dictionary with the following names and phone numbers: Bob 72345, Sally 71000, John 79999. Make the name the key and the phone number the value. Make the phone number an int. 8. Add a method ?sName Present to your Phonebook class. It will have a name as a parameter. It will return True if the name is present in the phonebook, False otherwise. Here is an example that demonstrates how to use this method, >>> book -Phonebook () >>> book.isName Present ('Foo) False >>> book,?sName present ("Bob,) True

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

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions