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 06

For Loops

Overview

Topic: For Loops
Related Reading: Chapter 7
Due: 10:00am, Friday 21 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 allows the user to enter a nonnegative integer $k$ and returns the sum of the first $k$ perfect squares, $$\sum_1^k{k^2}.$$ For example, if $k=4$ the sum should be $1^2 + 2^2 + 3^2 + 4^2 = 1 + 4 + 9 + 16 = 30$. A sample execution might appear as

    Enter k: 4
    30

  2. (10 points)

    Ask the user for a word and then output the following pattern.

    Enter word: example
    e
    ex
    exa
    exam
    examp
    exampl
    example
    

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