수학 기호를 함수 매개 변수에 추가하는 방법이 있는지 알고 싶습니다.Python 함수 매개 변수의 수학 기호는 무엇입니까?
def math(x, y, symbol):
answer = x 'symbol' y
return answer
이 내 말은 얼마나 작은 예입니다. 편집
: 여기 내가 횟수하지만 함수를 호출 할 필요가 전체 문제
def code_message(str_val, str_val2, symbol1, symbol2):
for char in str_val:
while char.isalpha() == True:
code = int(ord(char))
if code < ord('Z'):
code symbol1= key
str_val2 += str(chr(code))
elif code > ord('z'):
code symbol1= key
str_val2 += str(chr(code))
elif code > ord('A'):
code symbol2= key
str_val2 += str(chr(code))
elif code < ord('a'):
code symbol2= key
str_val2 += str(chr(code))
break
if char.isalpha() == False:
str_val2 += char
return str_val2
입니다 때로는 때로는 첫 번째 심볼에 대한 +/- 및 두 번째 심볼에 대한 +/-와
ORIGINAL CODE :
def code_message(str_val, str_val2):
for char in str_val:
while char.isalpha() == True:
code = int(ord(char))
if code < ord('Z'):
code -= key
str_val2 += str(chr(code))
elif code > ord('z'):
code -= key
str_val2 += str(chr(code))
elif code > ord('A'):
code += key
str_val2 += str(chr(code))
elif code < ord('a'):
code += key
str_val2 += str(chr(code))
break
if char.isalpha() == False:
str_val2 += char
return str_val2
죄송합니다, 당신은 정교한 수있는 좀 더 –
하셨습니까'답 = X "기호"y' : 아래의 예 봐? –