Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

here is just one example of the correct outputs. please help. skeleton code is given at bottom Assignment Specifications You will develop a Python program

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedhere is just one example of the correct outputs. please help.

skeleton code is given at bottom Assignment Specifications You will develop a Python program which allows the user to select from a menu of options and which performs the requested calculations. You must use at least the four functions specified below. You are encouraged to use more functions of your own design. Global variables are not allowed. That is, any variable names used within any function must be parameters or be created in the function. You are not allowed to use advanced data structures such as list, dictionaries, classes, etc. However, you are allowed to read ahead and use try-except. sum_natural_squares (N) ---> int: a. This function accepts as the user input (string) as numerical value and returns the sum of the squares of the first N natural numbers. If the user input is not a natural number (an integer > 0), the function should return None. Note the string method .isdigit() is helpful. a. Parameters: N (string) b. Returns : int or None c. The function displays nothing. approximate pi () ---> float: a. This function accepts no input and returns the approximate of Pi (). The number should be rounded to 10 decimal digits after the decimal point. The number is calculated as: (-1)" 7=4* 2n +1 The program will expand the series until the absolute value of the next term in the series is less than 1.0e-7 (the specified epsilon); that term will not be included in the sum. b. Parameters: no parameters c. Returns : float d. The function displays nothing. approximate_sin (x) ---> float: b. This function accepts as input a numeric value X (measured in radians) and returns the approximate value of the sine of X. The number should be rounded to 10 decimal digits after the decimal point. The number is calculated as: sin(x)= (-1)" x 2 + sin(x)=2 (2n+1)! The program will expand the series until the absolute value of the next term in the series is less than 1.0e-7 (the specified epsilon); that term will not be included in the sum. The parameter is a string; if it isn't in the correct format for a float, return None. c. Parameters: x (str) d. Returns : float or None e. The function displays nothing. approximate_cos (x) ---> float: a. This function accepts as input a numeric value X (measured in radians) and returns the approximate value of the cosine of X. The number should be rounded to 10 decimal digits after the decimal point. The number is calculated as: cos(x)= (-1)" 22" (2n)! The program will expand the series until the absolute value of the next term in the series is less than 1.0e-7 (the specified epsilon); that term will not be included in the sum. The parameter is a string; if it isn't in the correct format for a float, return None. b. Parameters: x (str) c. Returns : float or None d. The function displays nothing. main(): a. This function is used to interact with the user. It takes no input and returns nothing. Call the functions from here. The program should prompt the user to choose between 6 options (capitalization does not matter) until the user enters 'X': 'A' - Display the value of the sum of squares of the first N natural numbers. 'B' - Display the approximate value of Pi. 'C' - Display the approximate value of the sine of X. 'D' - Display the approximate value of the cosine of X 'M' - Display the menu of options. X'. Exit from the program. b. The program will repeatedly prompt the user to enter a letter (upper or lower case) which corresponds to one of the supported options. For example, the user will enter the letter A (or the letter a) to select Option A (display the value of the sum of the first N natural numbers). c. The program will display the menu of options once when execution begins, whenever the user selects Option M, and whenever the user selects an invalid menu option. d. If the user enters option A, the program will ask the user to enter a numeric value N. IN is a natural number, the program will calculate and display the value of the sum of squares of the first N natural numbers. Otherwise, the program will display an appropriate message. approximate value. Use the appropriate string formatting. f. If the user enters option C, the program should ask the user to enter a numeric value X (measured in radians). The program will calculate and display the approximate value of the sine of X. It will then display the corresponding value from the Python math module, as well as the absolute value of the difference between the calculated value and the math module value. The program should display 10 decimal digits after the decimal point for the approximate value. Use the appropriate string formatting. g. If the user enters option D, the program will ask the user to enter a numeric value X (measured in radians). The program will calculate and display the approximate value of the cosine of X. It will then display the corresponding value from the Python math module, as well as the absolute value of the difference between the calculated value and the math module value. The program should display 10 decimal digits after the decimal point for the approximate value. Use the appropriate string formatting, h. If the user quits, the program should display a goodbye message. "' Insert heading comments here.'' import math EPSILON = 1.0e-7 def display_options(): This function displays the menu of options!!! MENU = ''' Please choose one of the options below: A. Display the sum of squares of the first N natural numbers. B. Display the approximate value of Pi. c. Display the approximate value of the sine of x. D. Display the approximate value of the cosine of X. M. Display the menu of options. X. Exit from the program.' print (MENU) def sum_natural_squares (N): '''Insert docstring here.'' pass # insert your code here def approximate_pi(): '''Insert docstring here.'' pass # insert your code here def approximate_sin(x): '''Insert docstring here.'' pass # insert your code here def approximate_cos(x): "'Insert docstring here.'' pass # insert your code here A. Dalt IIUM the PEUyl all. print (MENU) def sum natural squares (N): "''Insert docstring here.'' pass # insert your code here def approximate_pi(): ''Insert docstring here.'' pass # insert your code here def approximate_sin(x): '''Insert docstring here.'' pass # insert your code here def approximate_cos(x): "'Insert docstring here.'' pass # insert your code here def main(): pass # insert your code here if _name__ == "__main__": main() Please choose one of the options below: A. Display the sum of squares of the first N natural numbers. B. Display the approximate value of Pi. c. Display the approximate value of the sine of x. D. Display the approximate value of the cosine of x. M. Display the menu of options. X. Exit from the program. Enter option: n Error: unrecognized option [N] Please choose one of the options below: A. Display the sum of squares of the first N natural numbers. B. Display the approximate value of Pi. C. Display the approximate value of the sine of x. - N IN D. Display the approximate value of the cosine of x. M. Display the menu of options. X. Exit from the program. Enter option: m Please choose one of the options below: A. Display the sum of squares of the first N natural numbers. B. Display the approximate value of Pi. c. Display the approximate value of the sine of x. D. Display the approximate value of the cosine of x. M. Display the menu of options. X. Exit from the program. Enter option: x 33 Hope to see you again. 34 skeleton code is given at bottom Assignment Specifications You will develop a Python program which allows the user to select from a menu of options and which performs the requested calculations. You must use at least the four functions specified below. You are encouraged to use more functions of your own design. Global variables are not allowed. That is, any variable names used within any function must be parameters or be created in the function. You are not allowed to use advanced data structures such as list, dictionaries, classes, etc. However, you are allowed to read ahead and use try-except. sum_natural_squares (N) ---> int: a. This function accepts as the user input (string) as numerical value and returns the sum of the squares of the first N natural numbers. If the user input is not a natural number (an integer > 0), the function should return None. Note the string method .isdigit() is helpful. a. Parameters: N (string) b. Returns : int or None c. The function displays nothing. approximate pi () ---> float: a. This function accepts no input and returns the approximate of Pi (). The number should be rounded to 10 decimal digits after the decimal point. The number is calculated as: (-1)" 7=4* 2n +1 The program will expand the series until the absolute value of the next term in the series is less than 1.0e-7 (the specified epsilon); that term will not be included in the sum. b. Parameters: no parameters c. Returns : float d. The function displays nothing. approximate_sin (x) ---> float: b. This function accepts as input a numeric value X (measured in radians) and returns the approximate value of the sine of X. The number should be rounded to 10 decimal digits after the decimal point. The number is calculated as: sin(x)= (-1)" x 2 + sin(x)=2 (2n+1)! The program will expand the series until the absolute value of the next term in the series is less than 1.0e-7 (the specified epsilon); that term will not be included in the sum. The parameter is a string; if it isn't in the correct format for a float, return None. c. Parameters: x (str) d. Returns : float or None e. The function displays nothing. approximate_cos (x) ---> float: a. This function accepts as input a numeric value X (measured in radians) and returns the approximate value of the cosine of X. The number should be rounded to 10 decimal digits after the decimal point. The number is calculated as: cos(x)= (-1)" 22" (2n)! The program will expand the series until the absolute value of the next term in the series is less than 1.0e-7 (the specified epsilon); that term will not be included in the sum. The parameter is a string; if it isn't in the correct format for a float, return None. b. Parameters: x (str) c. Returns : float or None d. The function displays nothing. main(): a. This function is used to interact with the user. It takes no input and returns nothing. Call the functions from here. The program should prompt the user to choose between 6 options (capitalization does not matter) until the user enters 'X': 'A' - Display the value of the sum of squares of the first N natural numbers. 'B' - Display the approximate value of Pi. 'C' - Display the approximate value of the sine of X. 'D' - Display the approximate value of the cosine of X 'M' - Display the menu of options. X'. Exit from the program. b. The program will repeatedly prompt the user to enter a letter (upper or lower case) which corresponds to one of the supported options. For example, the user will enter the letter A (or the letter a) to select Option A (display the value of the sum of the first N natural numbers). c. The program will display the menu of options once when execution begins, whenever the user selects Option M, and whenever the user selects an invalid menu option. d. If the user enters option A, the program will ask the user to enter a numeric value N. IN is a natural number, the program will calculate and display the value of the sum of squares of the first N natural numbers. Otherwise, the program will display an appropriate message. approximate value. Use the appropriate string formatting. f. If the user enters option C, the program should ask the user to enter a numeric value X (measured in radians). The program will calculate and display the approximate value of the sine of X. It will then display the corresponding value from the Python math module, as well as the absolute value of the difference between the calculated value and the math module value. The program should display 10 decimal digits after the decimal point for the approximate value. Use the appropriate string formatting. g. If the user enters option D, the program will ask the user to enter a numeric value X (measured in radians). The program will calculate and display the approximate value of the cosine of X. It will then display the corresponding value from the Python math module, as well as the absolute value of the difference between the calculated value and the math module value. The program should display 10 decimal digits after the decimal point for the approximate value. Use the appropriate string formatting, h. If the user quits, the program should display a goodbye message. "' Insert heading comments here.'' import math EPSILON = 1.0e-7 def display_options(): This function displays the menu of options!!! MENU = ''' Please choose one of the options below: A. Display the sum of squares of the first N natural numbers. B. Display the approximate value of Pi. c. Display the approximate value of the sine of x. D. Display the approximate value of the cosine of X. M. Display the menu of options. X. Exit from the program.' print (MENU) def sum_natural_squares (N): '''Insert docstring here.'' pass # insert your code here def approximate_pi(): '''Insert docstring here.'' pass # insert your code here def approximate_sin(x): '''Insert docstring here.'' pass # insert your code here def approximate_cos(x): "'Insert docstring here.'' pass # insert your code here A. Dalt IIUM the PEUyl all. print (MENU) def sum natural squares (N): "''Insert docstring here.'' pass # insert your code here def approximate_pi(): ''Insert docstring here.'' pass # insert your code here def approximate_sin(x): '''Insert docstring here.'' pass # insert your code here def approximate_cos(x): "'Insert docstring here.'' pass # insert your code here def main(): pass # insert your code here if _name__ == "__main__": main() Please choose one of the options below: A. Display the sum of squares of the first N natural numbers. B. Display the approximate value of Pi. c. Display the approximate value of the sine of x. D. Display the approximate value of the cosine of x. M. Display the menu of options. X. Exit from the program. Enter option: n Error: unrecognized option [N] Please choose one of the options below: A. Display the sum of squares of the first N natural numbers. B. Display the approximate value of Pi. C. Display the approximate value of the sine of x. - N IN D. Display the approximate value of the cosine of x. M. Display the menu of options. X. Exit from the program. Enter option: m Please choose one of the options below: A. Display the sum of squares of the first N natural numbers. B. Display the approximate value of Pi. c. Display the approximate value of the sine of x. D. Display the approximate value of the cosine of x. M. Display the menu of options. X. Exit from the program. Enter option: x 33 Hope to see you again. 34

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions