{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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 ]}

### Page1 / 3

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

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

View Full Document
Ask a homework question - tutors are online