Question

In: Computer Science

Use Python to solve each problem. Answers should be written in full sentences. Define a code...

Use Python to solve each problem. Answers should be written in full sentences.

  1. Define a code that will give users the option to do one of the following.

    • Convert an angle from radians to degrees,

    • Convert an angle from degrees to radians,

    • Return the sine, cosine, or tangent of a given angle (need to know if angle is given in degrees or radians).

Solutions

Expert Solution

PYTHON PROGRAM:

import math 

#options to choose operation from...
print("\nchoose any one of the following operations:")
print("1 convert an angle from degree to radian\n2 convert an angle from radian to degree")
print("3 find sine of angle\n4find cosine of angle\n5 find tangent of angle")
#input option 
n=int(input())

print()
#taking input of angle
x=float(input("Enter angle: "))
print()

#conditions and calculations for corresponding options

if n==1:
    print("In radian: ",round(x*math.pi/180,6))  #degree to radian upto 6 decimal place
    
elif n==2:
    print("In degree: ",round(x*180/math.pi,6))  #radian to degree upto 6 decimal place

#options to find sine, cosine or tangent
elif n==3 or n==4 or n==5:
    #input for type of angle i.e. degree or radian
    t=int(input("Choose type of input:\n1 degree\n2radian\n"))
    print()
    #if degree type
    if t==1:
        if n==3:
            print("sine of angle: ",round(math.sin(x*math.pi/180),6))  #sine of degree upto 6 decimal places
        elif n==4:
            print("cosine of angle: ",round(math.cos(x*math.pi/180),6))  #cosine of degree upto 6 decimal places
        elif n==5:
            print("tangent of angle: ",round(math.tan(x*math.pi/180),6))  #tangent of degree upto 6 decimal places
            
    #if radian type
    if t==2:
        
        if n==3:
            print("sine of angle: ",round(math.sin(x),6))  #sine of radian upto 6 decimal places
            
        elif n==4:
            print("cosine of angle: ",round(math.cos(x),6))   #cosine of radian upto 6 decimal places
            
        elif n==5:
            print("tangent of angle: ",round(math.tan(x),6))   #tangent of radian upto 6 decimal places

SAMPLE OUTPUT:

a.)

b.)


Related Solutions

Write a python script to solve the 4-queens problem using. The code should allow for random...
Write a python script to solve the 4-queens problem using. The code should allow for random starting, and for placed starting. "The 4-Queens Problem[1] consists in placing four queens on a 4 x 4 chessboard so that no two queens can capture each other. That is, no two queens are allowed to be placed on the same row, the same column or the same diagonal." Display the iterations until the final solution Hill Climbing (your choice of variant)
1) Code in python for solving the MNIST classification problem (for full size of the training...
1) Code in python for solving the MNIST classification problem (for full size of the training set Classify two digits from MNIST dataset 2) Logistic regression (LR) with L1 regularization where LR is differentiable, But L1 norm is not • Use proximal gradient descent • For L1 norm, that’s soft-thresholding • Use tensorflow library
I just wrote Python code to solve this problem: Write a generator that will return a...
I just wrote Python code to solve this problem: Write a generator that will return a sequence of month names. Thus gen = next_month('October') creates a generator that generates the strings 'November', 'December', 'January' and so on. If the caller supplies an illegal month name, your function should raise a ValueError exception with text explaining the problem. Here is my code: month_names = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] def next_month(name: str) -> str:...
construct A*star algorithm for solving the 8-puzzle problem . Use MATLAB or Python .Your code should...
construct A*star algorithm for solving the 8-puzzle problem . Use MATLAB or Python .Your code should include two heuristic functions -misplaced tiles and calculation of manhattan distance. The code should work for all cases of puzzle.
*MUST SHOW ALL WORK AND STEPS TO SOLVE PROBLEM TYPED ANSWERS IN FULL DETAIL Problem 1...
*MUST SHOW ALL WORK AND STEPS TO SOLVE PROBLEM TYPED ANSWERS IN FULL DETAIL Problem 1 : Lucky Star Inc. just issued a bond with the following characteristics: Maturity = 3 years Coupon rate = 8% Face value = $1,000 YTM = 10% Interest is paid annually and the bond is noncallable. Calculate the bond’s Macaulay duration (Round "Present value" to 2 decimal places and "Duration" to 4 decimal place.) Calculate the bond’s modified duration Assuming the bond’s YTM goes...
Use stars and bars to solve each counting problem. You may leave your answers as binomial...
Use stars and bars to solve each counting problem. You may leave your answers as binomial coefficients. (a) How many collections of 6 (not necessarily distinct) coins can be made from an infinite supply of pennies, nickels, dimes, and quarters? (b) A social security number is a sequence of 9 digits. How many social security numbers are there n1n2n3 . . . n9 such that ni ≤ ni+1 for i = 1 to 8? For example, 024455888 would count but...
Use stars and bars to solve each counting problem. You may leave your answers as binomial...
Use stars and bars to solve each counting problem. You may leave your answers as binomial coefficients. (a) How many collections of 6 (not necessarily distinct) coins can be made from an infinite supply of pennies, nickels, dimes, and quarters? (b) A social security number is a sequence of 9 digits. How many social security numbers are there n1n2n3 . . . n9 such that ni ≤ ni+1 for i = 1 to 8? For example, 024455888 would count but...
For this problem, you should: describe the algorithm using aflowchart and thenwrite Python code...
For this problem, you should: describe the algorithm using a flowchart and thenwrite Python code to implement the algorithm.You must include:a.) a picture of the flowchart you are asked to create,b.) a shot of the Python screen of your code, andc.) a shot of the Python screen of your output.Program Requirements: Your application will implement a stopwatch to beused during a 1500-meter race in a swimming match. The input to theapplication will be the number of seconds for two different...
The code should be written in c++. It should be in only OpenGL // ***** ONLY...
The code should be written in c++. It should be in only OpenGL // ***** ONLY OpenGL PLEASE ******// write a program snippet that accepts the coordinates of the vertices of a rectangle centered around the origin, with edges that are parallel to the X and Y axes, and with aspect ratio W and converts it into a rectangle centered around the origin with aspect ratio of 1/W. The program has to figure W from the given points. You MUST...
Solve with Python: The following is the color code of the jackets of employees for a...
Solve with Python: The following is the color code of the jackets of employees for a companies annual conference. The Color is determined by the Employee category and the state in which they work. Employee Category Executive (1) Director(2) Manager(3) Worker(4) State Jacket Color State Jacket Color State Jacket Color State Jacket Color NY, NJ, PA Blue NY, NJ, PA Purple NY, NJ, PA Red NY, NJ, PA Black TX, LA, FL White TX, LA, FL Green TX, LA, FL...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT