не могу понять строку 42, продолжаю получать ошибку TypeError: неподдерживаемые типы операндов для ** или pow(): 'str' и 'int' может кто-нибудь посоветовать мне, как это исправить, поскольку я застрял на нем в течение нескольких часов как работает код, вы запускаете его, а затем выбираете, какой тип расчета вы хотите сделать, в этом случае область круга сломана, и по какой-то причине он не будет работать, как он должен работать, так это то, что проверка проверки проверяет, является ли строка цифры или буквы, и если это цифры, он продолжится, а если это буквы, он перезапустится и скажет, что вам нужно выбирать цифры, а не буквы
import time
import math
def check(num1, num2):
number1 = str(num1).isnumeric()
if number1 == False:
print('Bruh math not l\'anglais')
time.sleep(0.5)
restart()
number2 = str(num2).isnumeric()
if number2 == False:
print('Bruh math not l\'anglais')
time.sleep(2.5)
while True:
restart()
def percentage_decrease():
original_amount = str(input("Please give me the original amount: "))
percentage_decrease = str(input("Give me percentage to decrease: "))
check(original_amount, percentage_decrease)
multiplier = 1 - int(percentage_decrease) / 100
answer = int(original_amount) * multiplier
print("The answer is",answer)
def percentage_increase():
original_amount = str(input("Please give me the original amount: "))
percentage_increase = str(input("Give me percentage to increase: "))
check(original_amount, percentage_increase)
multiplier = 1 + int(percentage_increase) / 100
answer = int(original_amount) * multiplier
print("The an is",answer)
def power_of_x():
num = str(input("What number would you like to find out the power off: "))
power = str(input("what power do you to do: "))
check(num, power)
answer = int(num**power)
print("The answer is",answer)
def area_circle():
user_choice = input("Would you like to use diameter or radius?")
if user_choice.lower() == "radius" or user_choice.lower() == "r":
num_area_circle_radius = str(input("Please give me the radius: "))
check(num_area_circle_radius, '0')
anwser_area_circle = math.pi * int(num_area_circle_radius**2)
rounded_anwser_area_circle = round(anwser_area_circle, 2)
print("The anwser is",rounded_anwser_area_circle,"rounded 2d.p")
elif user_choice.lower() == "diameter" or user_choice.lower() == "d":
num_area_circle_diameter = str(input("Please give me the diameter: "))
check(num_area_circle_diameter, '0')
convert_diameter_radius = num_area_circle_diameter / 2
anwser_area_circle = math.pi * int(convert_diameter_radius**2)
rounded_anwser_area_circle = round(anwser_area_circle, 2)
print("The anwser is",rounded_anwser_area_circle,"rounded 2d.p")
def addition():
num1_addition = input("First Number pls: ")
num2_addition = input("Second Number pls: ")
check(num1_addition, num2_addition)
answer_addition = int(num1_addition) + int(num2_addition)
print("The answer is",answer_addition)
def multiply():
num1_multiply = str(input("First Number pls: "))
num2_multiply = str(input("Second Number pls: "))
check(num1_multiply, num2_multiply)
answer_multiply = int(num1_multiply) * int(num2_multiply)
print("The answer is",answer_multiply)
def subtraction():
num1_subtraction = str(input("First Number pls: "))
num2_subtraction = str(input("Second Number pls: "))
check(num1_subtraction, num2_subtraction)
answer_subtraction = int(num1_subtraction) - int(num2_subtraction)
print("The answer is",answer_subtraction)
def division():
num1_division = str(input("First Number pls: "))
num2_division = str(input("Second Number pls: "))
check(num1_division, num2_division)
answer_division = int(num1_division) / int(num2_division)
print("The answer is",answer_division)
def start():
print("These are multiple things you can do \n1)Addition \n2)Subtraction \n3)Multiplication \n4)Division \n5)Area Of Circle \n6)Power Off x \n7)Percentage Increase \n8)Percentage Decrease")
time.sleep(0.5)
user_operator = input("What calculation would you like to: ")
if user_operator.lower() == "Addition" or user_operator == "1":
addition()
elif user_operator.lower() == "Subtraction" or user_operator == "2":
subtraction()
elif user_operator.lower() == "Division" or user_operator == "4":
division()
elif user_operator.lower() == "Multiplication" or user_operator == "3":
multiply()
elif user_operator.lower() == "Area of a circle" or user_operator == "5":
area_circle()
elif user_operator.lower() == "power of x" or user_operator == "6":
power_of_x()
elif user_operator.lower() == "percentage increase" or user_operator == "7":
percentage_increase()
elif user_operator.lower() == "percentage decrease" or user_operator == "8":
percentage_decrease()
else:
start()
start()
def restart():
user_restart = input("Do you want to do another calculation(y or n): ")
if user_restart == "Y".lower():
start()
elif user_restart == "N".lower():
print("Thank you for using my calculator.")
else:
start()
while user_restart == "Yes".lower():
restart()
if user_restart == "No".lower():
user_restart = "No"
while True:
restart()
num = str(input("What number would you like to find out the power off: "))
power = str(input("what power do you to do: "))
check(num, power)
answer = int(num**power)
Вы хотели преобразовать «число» в целое, а затем взять власть, вы сместили скобки.
Вы должны преобразовать
num
иpower
в числа до, которые вы выполняете с ними, а не после.