In: Computer Science
Write a function fun(x) that takes as input a positive number x and solves the following equation for y and returns y. The equation is 10^4y=x+3.
Could you help me with this by using python? I can use loop or if statement for this question.
I have written the program using PYTHON PROGRAMMING LANGUAGE.
OUTPUT :
CODE :
#imported the math module
import math
#function definition for fun
def fun(x):
# 10^4y=x+3
#to calculate the y value as per the formula given in the question
y = (math.log(x+3,10))/4.0
return y#returned y value
if(__name__ == "__main__"):
#taking the user input
number = int(input("Please Enter the positive integer : \t"))
#condition to check whether input value is a positive number or not
if(number>0):
#calling the fun to get the y value
print("y value is %.2f"%fun(number))
else:
print("Invalid Input!!! Please Enter the positive number!!!")
Thanks..