Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- print("Lab_5 / 15var")
- print("Task 1")
- def Calc_1(x):
- a = math.pow(x, 2) / x
- b = (2 - x) / 6
- c = math.pow(math.cos(x), 3) - 2 * x
- h = 5 * c + 2 * math.pow(a, 4)
- return a,b,c,h
- while True:
- try:
- x = float(input("Enter x: "))
- break
- except ValueError:
- print("Please enter a value with a floating point")
- result = Calc_1(x)
- print("x:", x)
- print("a:", result[0])
- print("b:", result[1])
- print("c:", result[2])
- print("h:", result[3])
- print("Task 2")
- def Calc_2(c):
- z = math.cos(c)
- if (z < 0):
- print("z < 0")
- f1 = math.pow(z, 5) / math.sin(2 * z)
- y = f1
- elif (0 <= z <= 8):
- print("0 <= z <= 8")
- f2 = math.exp(-2 * z) + math.tan(z)
- y = f2
- elif (z > 8):
- print("z > 8")
- f3 = math.pow(math.cos(z), 4) + math.pow(z, 1 / 3)
- y = f3
- return z,y
- while True:
- try:
- c = float(input("Enter c: "))
- break
- except ValueError:
- print("Please enter a value with a floating point")
- print("c:", c)
- result = Calc_2(c)
- print("z:", result[0])
- print("y:", result[1])
- print("Task 3")
- def Calc_3(a, b, c):
- count = 0
- summ = 0
- print(" x | F1(x) | F2(x) | y |")
- while a <= b:
- x = a
- count += 1
- f1 = math.pow(x, 3 * x + 1) + 8 * x
- f2 = math.fabs(x - 8) + math.sin(x)
- summ += f1 / f2
- print('%4s | %22s | %22s | %22s |' % (x, f1, f2, summ))
- a = round(a + c, 1)
- return count, summ
- a = 4
- b = 7.5
- c = 0.3
- result = Calc_3(a, b, c)
- print("The sum of the series after", result[0], "operations is:", result[1])
Advertisement
Add Comment
Please, Sign In to add comment