CMPT 120 LECTURE MIDTERM 2 SOLUTIONS

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

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

View Full Document Right Arrow Icon
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?
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern