Question

You need to write this program providing function definition. You can choose your own function definition....

You need to write this program providing function definition. You can choose your own function definition. Write a program that will ask the user to provide an angle value and the program will calculate the sine, cosine and tangent of that angle. (in python)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the python3 code for mentioned problem statement.

import math

# Method to find the sin(angle)
def findSinTheta(angle):

    return math.sin(math.radians(angle))

# Method to find the cos(angle)
def findCosTheta(angle):

    return math.cos(math.radians(angle))

# Method to find the tan(angle)
def findTanTheta(angle):

    return math.tan(math.radians(angle))

if __name__ == '__main__':
    # Prompt for user input to enter angle
    theta = int(input("Please enter the angle : "))
    print("Angle is : ", theta )

    # calling the respective functions
    sin_theta = findSinTheta(theta)
    cos_theta = findCosTheta(theta)
    tan_theta = findTanTheta(theta)

    # Dsiplaying the results
    print("\nSin of ",theta, " is : ",  sin_theta)
    print("Cos of ",theta, " is : ",  cos_theta)
    print("Tan of ",theta, " is : ",  tan_theta)

Output:

Please enter the angle : 30
Angle is : 30

Sin of 30 is : 0.49999999999999994
Cos of 30 is : 0.8660254037844387
Tan of 30 is : 0.5773502691896257

Please find the screenshot of code and output:

te demo.py import math Run # Method to find the sin(angle) def findSinTheta(angle): Run: demo (1) /home/deepak/anaconda3/envs

te demo.py import math Run # Method to find the sin(angle) def findSinTheta(angle): Run: demo (1) /home/deepak/anaconda3/envs/py3/bin/python /home/deepak/ Please enter the angle : 30 Angle is : 30 A return math.sin(math.radians (angle)) → # Method to find the cos(angle) def findCosTheta(angle): 000NM Sin of 30 is: 0.49999999999999994 Cos of 30 is: 0.8660254037844387 Tan of 30 is : 0.5773502691896257 return math.cos(math.radians (angle)) = HOX Process finished with exit code o # Method to find the tan(angle) def findTanTheta(angle): 15 return math. tan(math.radians (angle)) if _name__ == 'main ': # Prompt for user input to enter angle theta = int(input("Please enter the angle : ")) print("Angle is : ", theta) ON NNNNNNNNNN DOO # calling the respective functions sin_theta = findSinTheta(theta) cos_theta = findCosTheta(theta) tan_theta = findTanTheta(theta) # Dsiplaying the results print("\nSin of ", theta," is : ", sin_theta) print("Cos of ", theta," is : ", cos theta) print("Tan of ", theta," is : ", tan theta)

Add a comment
Know the answer?
Add Answer to:
You need to write this program providing function definition. You can choose your own function definition....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need a simple program in C language that calculates the values of Sine, Cosine, and...

    I need a simple program in C language that calculates the values of Sine, Cosine, and Tangent of values given in degrees. It has to be a range of values between 0 and 360(integer values). The output should be a table of values showing Sin, Cos and Tan values. The complete computation and printing of the table must be done inside a function. The function also returns to the main program with 3 output arguments: It also needs to show...

  • . Use what you learned from our First Python Program to write a Python program that...

    . Use what you learned from our First Python Program to write a Python program that will carry out the following tasks. Ask user provide the following information: unit price (for example: 2.5) quantity (for example: 4) Use the following formula to calculate the revenue: revenue = unit price x quantity Print the result in the following format on the console: The revenue is $___. (for example: The revenue is $10.0.) . . Use the following formula to calculate the...

  • Write in Python 3 Write a program that takes the value of an angle x in...

    Write in Python 3 Write a program that takes the value of an angle x in degrees, such that 0 s x <90, and calculates approximate value of sine of the given angel using the following series sin(x)-x-for all x The series given above has infinite number of terms. However, you can only include a finite number of terms in the series. The absolute value of each subsequent term is smaller than that of the term calculated before it. The...

  • USING PYTHON PLEASE Write a program that calculates the factorial value of a number entered by...

    USING PYTHON PLEASE Write a program that calculates the factorial value of a number entered by the user. Remember that x! =x* (x-1)* (x-2)*... *3+ 2* 1. Your program should check the value input by the user to ensure it is valid (i.e., that it is a number > =1). To do this, consider looking at the is digit() function available in Python. If the user enters an incorrect input, your program should continue to ask them to enter a...

  • Your employer needs a program that analyzes the monthly sales figures for each division. Write a...

    Your employer needs a program that analyzes the monthly sales figures for each division. Write a Python program that allows the user to enter a series of numbers and places the numbers (not string values) in a list. Each number entered by the user is the monthly sales amount for one division. Use a sentinel-controlled loop to get input from the user and place each value entered into the list as long as the value is not negative. As soon...

  • Write a program that inputs from the user an angle (measured in degrees) then computes and...

    Write a program that inputs from the user an angle (measured in degrees) then computes and prints: (the trigonometric sine of the angle in radians) squared + (the trigonometric cosine of the angle in radians) squared. Test your program on different degrees; if your program is working correctly, the result should be 1 each time (pythagorean trigonometric identity). IN JAVA THANK YOU

  • Can you send the code and the screenshot of it running? 1) Create a PYHW2 document...

    Can you send the code and the screenshot of it running? 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both flowchart and pseudocode forms for the following two functions: A. Write a Python function that receives a real number argument representing the sales amount for videos rented so far this month The function asks the user for the number...

  • Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as...

    Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as described below. Calls the function find_item_in_grid and prints the result. The find_item_in_grid function should have one parameter, which it should assume is a list of lists (a 2D list). The function should ask the user for a row number and a column number. It should return (not print) the item in the 2D list at the row and column specified by the user. The...

  • I need help in this, please write your own definition and make your own examples. Please...

    I need help in this, please write your own definition and make your own examples. Please do not copy anything, It should be plagiarism free Topic List (10 points) 1. Microeconomics 2. Intermediate good 3. Disposable personal income (provide a quantitative example!" 4. Inflation rate (provide a quantitative example." Four Topics (20 points each) 1. Microeconomics Definition/discussion: Example (if required): 2. Intermediate good Definition discussion: Example (if required): 3. Disposable personal income (provide a quantitative example) Definition/discussion: Example (if required):...

  • 2) Write a C++ program that uses a class called “Degree” to obtain the trigonometric values...

    2) Write a C++ program that uses a class called “Degree” to obtain the trigonometric values for angles given in degrees. This is because the trigonometric functions defined in the library file <cmath> are applied to radian angles only. Use the constant DEG2RAD = 0.017453 for conversion from degrees to radians. This class must include a constructor, destructor, and the following functions: a. void set_value(double) b. double get_value() c. double get_sine() d. double get_cosine() e. double get_tangent() f. void read_value()...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT