Additional Homework problems:

1.) Write the definition of a function absoluteValue that receives a parameter containing an integer value and returns the absolute value of that parameter.

2.) The factorial of a positive integer n (written n!) is the product 1*2*3*....*n. Write a program that asks the user to input a positive integer and then calculates and displays the factorial of the number. The program should call a function named getN that gets input and guarantees that the input is a positive integer. Also, the factorial of the number input should be calculated with a function named fact. (Below shows a possible outcome of this exercise):

(Ask user to enter an integer) Enter a positive integer: 5
(Output) 5! is 120

Problem 2

Write a program to draw this. Assume the innermost square is 20 units per side, and each successive square is 20 units bigger, per side, than the one inside it.

Figure: see image.

Problem 3

Write a non-fruitful function draw_poly(t, n, sz) which makes a turtle draw a regular polygon. When called with draw_poly(tess, 8, 50), it will draw a shape like this: see image.

Problem 7

Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and including n. So sum_to(10) would be 1+2+3...+10 which would return the value 55.

Problem 8

Write a function area_of_circle(r) which returns the area of a circle of radius r.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.