ответ: .
Пошаговое объяснение:
Во-первых, как можно заметить, от C значение функции не зависит.
Особенно это хорошо видно на последних двух строчках. Если убрать переменную C, то получиться таблица из 4 строк:
A B F
0 0 1
0 1 1
1 0 1
1 1 0
Это таблица истинности для отрицания И: - ответ.
На этом можно было бы остановиться (проверить по таблице истинности с учётом бесполезного С), но сделаем ещё кое-что - выведем это шаг за шагом, докажем, что С - бесполезная и никому не нужная переменная.
Запишем то же выражение в совершенной конъюнктивной нормальной форме. Выберем стоки, которые обращают выражение в Ложь.
A B C F
1 1 0 0
1 1 1 0
Две строки - две скобки. Единица в таблице означает отрицание переменной в скобке. Получаем .
Тут уже видно, что переменная С на результат не влияет. Упростим и приведём это к выражению выше.
- ответ.
Объяснение:
Итак, было 2 места с опечатками.
Во-первых, строка 29 - ввод числа - действия. Стоял плюс перед input(). option = +input(...
Во-вторых, строка 34 - вывод результата сложения, результат суммы не присоединялся к строке (забыт оператор +).
Исправил и приложил код ниже.
P.S. Вообще тема калькуляторов - вещь интересная. Она стоит на границе двух областей: компиляторов (парсинг, синтаксический анализ, etc.) и символьных вычислений (Это про то, как по текстовому выражению решить дифференциальное уравнение или построить график функции, или решить квадратное уравнение аналитически).
Если тебя так интересует эта тема, можешь продолжить написанием более функционального калькулятора для обратной польской записи, например.
Успехов в обучении!
Код:
like = "Great, I'm too! So let's enjoy math together)"
hate = "But I do like! So I can help you as well)"
what = "Could you please answer Yes or No)"
anyway = "Although I can't understand you again, let's do this!"
option = "6"
i = "7"
name = input("Hey, what's your name? ")
print("Wow, what a beautiful name ")
math = input(name + ", do you like mathematics? ")
if math.lower() == "yes":
print(like)
elif math.lower() == "no":
print(hate)
else:
print(what)
print(" ")
math = input(name + ", do you like mathematics? ")
if math.lower() == "yes":
print(like)
elif math.lower() == "no":
print(hate)
else:
print(anyway)
print(" ")
while i == "7":
print("I can find the sum(1), difference(2), product(3), fraction(4), of two numbers and raise number to the power(5) or end this game(0)")
option = input("select the needed option by sending corresponding number ") # HERE! You have placed a plus before an input()
if option == "1":
n1 = float(input("So you have chosen the sum. Enter the first number "))
n2 = float(input(f"And what number you wanna add to {n1} ? "))
sum = n1+n2
print(f"The sum of {n1} and {n2} is {sum}") # And THERE! You have written down ... + "is" sum) without a concatination plus
print(" ")
elif option == "2":
n1 = float(input("So you have chosen the difference. Enter the first number "))
n2 = float(input("And the second? "))
dif = n1 - n2
print(f"{n1} - {n2} = {dif}")
print(" ")
elif option == "3":
n1 = float(input("So you have chosen the production. Enter the first number "))
n2 = float(input("And the second one "))
prod = n1 * n2
print(f"The result is {prod}")
print(" ")
elif option == "4":
n1 = float(input("So you have chosen the fraction. Enter the first number "))
n2 = float(input(f"And {n1} is divided by... "))
fr = n1 / n2
print(f"So, the result is {fr}")
print(" ")
elif option == "5":
n1 = float(input("What number should I raise to the poser? "))
n2 = float(input(f"And what is exponent (the little number above {n1}) ? "))
power = n1 ** n2
print(f"{n1}^{n2} is {power}")
print(" ")
elif option == "0":
input("The game is ended!")
break
else:
print("I don't have any options like this. Try again.")