Course Home | Class Schedule | Assignments | Git Submission | Perusall | Python | Tutoring

Saint Louis University

Computer Science 1300/5001
Introduction to Object-Oriented Programming

Michael Goldwasser

Fall 2018

Computer Science Department

Homework Assignment 02

Python Scripts

Overview

Topic: Python Scripts
Related Reading: Chapter 2
Due: 10:00am, Tuesday, 4 September 2018

Please make sure you adhere to the policies on academic integrity.


Problems to be Submitted (20 points)

  1. (10 points)

    Write a program that asks the user to enter their name and subsequently greets them. The precise format should match the following sample session.

        What is your name? Julia
        Hello Julia!
    (To distingush between the program's output and the user's response, we use underlines to typeset the user's response above, even though no such underlines will appear when executing a script.)

  2. (10 points)

    Write a program that prompts the user for the lengths of the two legs of a right triangle, and which reports the length of the hypotenuse. Recall that the hypotenuse length satisfies the formula $c = \sqrt{a^2 + b^2}$.

    Your script should precise adhere to the format demonstrated in the following sample session.

        I will compute the hypotenuse of a right triangle.
        But first, you must tell me the lengths of the legs.
        What is the length of the first leg? 7
        What is the length of the second leg? 4
        The length of the hypotenuse is 8.0622577.
    (To distingush between the program's output and the user's responses, we use underlines to typeset the user's responses above, even though no such underlines will appear when executing a script.)


Michael Goldwasser
CSCI 1300/5001, Fall 2018
Last modified: Sunday, 02 September 2018
Course Home | Class Schedule | Assignments | Git Submission | Perusall | Python | Tutoring