sample-fi - CMPT 165 Final Sample Questions, 2004-1 1. [10...

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

View Full Document Right Arrow Icon
CMPT 165 Final Sample Questions, 2004-1 1. [10 points] Write a program that asks the user for their name and then says hello. You program should be unfriendly to people named “Monty”. [If your name is Monty, nothing personal.] So, usually the program should look like this: What is your name? Waylon Hello, Waylon. But, if the user is named Monty, What is your name? Monty I don’t really like you, Monty. 2. [10 points] Write a program to determine the number os roots to a quadratic equation of the form ax 2 + bx + c = 0 . The number of roots is determined by evaluating the formula D = b 2 - 4 ac . If D < 0, there are no roots; if D = 0, there is one; if D > 0, there are two. When the program runs, it should look like this: Enter the coefficients: a = 1 b = 4 c = 1 D = 12. There are two roots. 3. [10 points] Write a Python function named rule that uses a for loop to create a text-version of a horizontal rule. The function should take one argument that indicates the number of characters in
Background image of page 1

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

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

This note was uploaded on 02/06/2011 for the course CMPT 165 taught by Professor Ramesh during the Winter '09 term at Simon Fraser.

Page1 / 2

sample-fi - CMPT 165 Final Sample Questions, 2004-1 1. [10...

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

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