{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


hw3_orig - used for the slice operator 3 If we write this...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS8, F09, UCSB H03: (Based on Miller/Ranum, Chapter 2) Total Points: 50 Accepted: on paper, at the *beginning* of lecture (11am-12:15pm, TD-W 1701) on Thursday, October 8. Place on the front desk as you walk in, before getting seated. Print out this assignment and write the answers on it. No email submission allowed. Name: (3 pts)______________________________ UCSBNetID (3 pts) _____________________ To answer the questions on this homework, it will be very helpful to have a computer system running Python 3.0 or Python 3.1 available to you. To find such as system, you can either: * log on to one of the computers in the CSIL computer lab, and access Python 3.0 there * download Python 3.0 to your PC or Mac, and access Python 3.0 there Review Chapters 2 and 3 in your textbook, then answer these questions: 1. (5 pts) Section 3.2.3 talks about the index operator. What symbol is used for the index operator? 2. (5 pts) Section 3.2.4 talks about the slice operator. What symbol is
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: used for the slice operator? 3. If we write this at the Python shell prompt: >>> team = "Gauchos" then type each of the following at the shell prompt, what will the result be? a. (3 pts) >>> team[0] b. (3 pts) >>> team[0:2] c. (3 pts) >>> team[-1] d. (3 pts) >>> team[1:3] 4. (10 pts) Read Section 3.2.5. Then answer: There is a "string method "that will convert the variable team to all capital letters, i.e. return GAUCHOS instead of gauchos? What do we write if we want to assign the varible teamUC to be team, converted to upper case? Hint: The correct answer is NOT teamUC = "GAUCHOS" Please turn over for more problems Continued from other side 5. (10 pts) (problem 2.3 from page 81 in the textbook.) Write a function to compute the area of a circle with a radius of r. Use n as the parameter to the function. Use the value of pi from the math module....
View Full Document

{[ snackBarMessage ]}

Page1 / 2

hw3_orig - used for the slice operator 3 If we write this...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online