Programming Assignment 3: Functions
In this assignment you will write functions for two programs (Program 1 and Program 2) that will include your functions. Each program will be well documented (commented) and submitted in a separate document (though both should be submitted within the Programming Assignment 3 link).
Program 1
First write functions for the following:
- A function “circleArea (radius)” that returns the area of a circle having the given radius. (The formula is A =πr^2 .)
- A function “circlePerimeter(radius)” that returns the perimeter of a circle having the given radius. (The formula is P = 2πr .)
Then write a main program that uses these functions to compute the area and perimeter of a circle given the radius.
The program should prompt the user for the radius and then print out the area and perimeter.
A sample run for the program is as follows:
Enter the radius of the circle: 5
Area of the circle is 78.5
Perimeter of the circle is 31.4
Submit your program, which should include the function(s) as well as the main program, named as follows:
ITS-150_assignment3_1.py
Program 2
Write a function to compute the nth number of the following series: Given a valuex, multiply all the non-zero digits ofxtogether and then add that value toxto get the next number in the series. The function should be named: some_series.
1, 2, 4, 8, 16, 22, 26, 38, 62, 74, 102, 104, 108, 116, 122, 126, 138, 162, 174, 202, 206, 218, 234, 258, 338, 410, 414, 430, 442, 474, 586, 826, 922, 958, 1318, 1342, 1366, …
Write a main program that prompts the user to enter “n” and prints out the nth number of the series.
A sample run for the program is as follows.
Enter a positive integer: 6
The 6th number of the series would be 22
Submit your program, which should include the function(s) as well as the main program, named as follows:
ITS-150_assignment3_2.py