Вы находитесь на странице: 1из 2

GE 120: INTRODUCTION TO OOP FOR GEOSPATIAL APPLICATIONS

MACHINE EXERCISE NO.1


You must put code comments per line so as for me to know that you really know what you
do. Plagiarism or cheating is a serious academic offense. Collaboration with others is
encouraged, but copying is not. You may get ideas from others, but implement your own
solution.

Tech Skills: User Input, Selection Controls, Iterations, Relational/Logical Operators,


Numerical Computing, Print and Modulo Kung Fu, Reusing Built-In Modules.

Life Skills: Bravery, Determination, Hard Work, Attention to Details, Positive Thinking. J

Submission: Submit in a single, zipped file (e.g. ME1_DelaCruz.zip) your 3 machine exercises
solutions (SumOfMultiples.py, StarsOfEmptiness.py, and SineApproximation.py)

I. Sum of Multiples (SumOfMultiples.py)

The list of all whole numbers below 10 that are multiples of 3 or 5 are 3, 5, 6, and 9. The sum of
these multiples is 23. Find the sum of all the multiples of 3 or 5 below 100.

II. Stars of Emptiness (StarsOfEmptiness.py)

Write a program that prints an empty box with stars along its border. For each program run, the user
inputs the height and width of the box. Below is the sample program run for height = 4, width =
7. Assume that the user will not input a height or width values less than 3. Tip: analyze and observe
the patterns first of those in small boxes (e.g. 3x3, 3x4, 4x3, or 4x4 dimensions).

Also, see the related exercise 3.7 on page 117 of our Deitels Python How to Program reference
ebook (Chapter 3: Control Structures). The book is uploaded in UVLe also. Essentially, youll have to
utilize the combination of for loops, printing stars (print *), printing spaces (print ), printing
newlines (print) and suppressing newlines using the comma operator (print *, or print ,)

III. Sine Approximation (SineApproximation.py)

The sin(x) could be expressed as a polynomial function:

In essence, it could be expressed as an alternating sum, with the exponents (N) having the value of 1,
3, 5, 7, etc. You could use the built-in math modules factorial() function for computing the factorial
values in the denominators (see sample usage below).
Sample runs below for sin(x), with polynomial term power (N) equals to 1, 3, and 25. The user
should input the values of x and N.

___ oo0oo ___

Its not the work thats hard, its the discipline.

"Great teachers do not exist, there are only great pupils."


http://www.lifehack.org/articles/productivity/10-reasons-why-people-give-learning-musical-instruments-too-easily.html

Вам также может понравиться