Created
October 14, 2021 07:46
-
-
Save raghavmri/0d26212e4a704d7e82119d48580d769a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # program 29 Python program to import math module and ask the user to choose the function and to go again or not. | |
| import math | |
| def main(): | |
| print("1.ceil - returns the smallest integer greater than or equal to x.\n") | |
| print("2.sqrt - returns the square root of the number\n") | |
| print("3.exp - returns the logarithm, e raised to the entered number\n") | |
| print("4.fabs - returns the absolute number of the number\n") | |
| print("5.floor - returns the largest integer less than or equal to x\n") | |
| print("6.log - returns the logarithm of x to the base a(defaults to e)\n") | |
| print("7.log10 - returns the base-10 logarithm of x\n") | |
| print("8.pow - returns x raised to the power y\n") | |
| print("9.sin - returns the sine of x\n") | |
| print("10.cos - returns the cosine of x\n") | |
| print("11.tan - returns the tangent of x\n") | |
| print("12.degrees - converts angle x from radians to degrees\n") | |
| print("13.radians - Converts angle x from degrees to radians\n") | |
| num = int(input( | |
| "Choose the function from the above you want the number to be converted: ")) | |
| ent = float(input("Enter the value")) | |
| if num == 1: | |
| print("The value of the number is", math.ceil(ent)) | |
| elif num == 2: | |
| print("The value of the number is", math.sqrt(ent)) | |
| elif num == 3: | |
| print("The value of the number is", math.exp(ent)) | |
| elif num == 4: | |
| print("The value of the number is", math.fabs(ent)) | |
| elif num == 5: | |
| print("The value of the number is", math.floor(ent)) | |
| elif num == 6: | |
| print("The value of the number is", math.log(ent)) | |
| elif num == 7: | |
| print("The value of the number is", math.log10(ent)) | |
| elif num == 8: | |
| print("The value of the number is", math.pow(ent)) | |
| elif num == 9: | |
| print("The value of the number is", math.sin(ent)) | |
| elif num == 10: | |
| print("The value of the number is", math.cos(ent)) | |
| elif num == 11: | |
| print("The value of the number is", math.tan(ent)) | |
| elif num == 12: | |
| print("The value of the number is", math.degrees(ent)) | |
| elif num == 13: | |
| print("The value of the number is", math.radians(ent)) | |
| else: | |
| print("Enter a valid choice: ") | |
| choice = input("Do you like to go again [yes/no]: ") | |
| if choice == "yes": | |
| main() | |
| if choice == "no": | |
| print("thanks!") | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment