Starting from:

$30

IT210- Fundamentals of Programming Lab 4 Solved

This program requires you to work in a group of two or three write Python code that implements problem P4.22 in your text on page 210. That problem is restated here:

Write a program that reads an integer and displays, using asterisks, a filled diamond of the given side length. For example, if the side length is 4, the program should display



Implementation comments:

            Your program should work correctly for any integer from zero and up.

    The leftmost asterisk of the middle row is at the left margin.

    Hint 1: using two for loops, one for the top half and one for the bottom half is a good approach.

Hint 2: the string repetition operator is useful.

    Discuss with your group how the number or leading spaces and the number of stars change as a function of the entered integer as you go from line to line.

       You don't need to do this, but a solution with fewer than 10 lines of Python code is possible.

Each member of the group must make a submission to D2L with your own name as a comment on line 1 and the name or names of other group members on the following lines. If you do the lab solo, I will deduct 20 points. Submit a copy of the lab to the Lab 4 D2L dropbox not later than 11:59 pm Friday evening. Name your file Lab04.py. You are permitted to work on your program after the lab to make corrections or improvements and it might therefore differ from the programs submitted by others in your group but all names still need to be present.

More products