CMPT 120 LECTURE MIDTERM 2 SOLUTIONS

# CMPT 120 LECTURE MIDTERM 2 SOLUTIONS - page 1 School of...

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

School of Computing Science Simon Fraser University CMPT 120 - Introduction to Computing Science and Programming Term: Fall 2011-3 Instructor: Bill Havens Second Midterm Examination INSTRUCTIONS : Provide answers to these questions on these pages only. NAME: ________KEY______________ STUDENT#: _________________________ 1. Short Answer (20-points) 1. Give the BNF syntax for the Python "try-except" statement: ___try : <block> except : <block>____ 2. Give the class name of a Python error that you have encountered: ___any runtime error eg- DivideByZero _ 3. Make a Python list of 3 elements that contains your height as a floating value, your age as an integer value and your name as a string: ___[ 60.0, 49, "Harold Hophozophen"]_ 4. What is the result of the following expression: range(14, 20)= _[14, 15, 16, 17, 18, 19] _ 5. Suppose you had a list of your favourite colours called colours represented as strings. Then what is the value of the following expression? ( 2 in colours) ___ False ___ 6. What is the value of this expression? (["red", "blue"]+["orange"])[1] _ "blue" _ 7. Suppose that lst = ["a", "b", "c", "d", "e", "f"] then what is the value of the expression?

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern