انا غيرتها فعلا
تمام بس منصف مش بيدخل عايزين نعمل حذف المسافات حد يساعدنى هو مش بيخش من 3 ايام

def calc(nums, ops): while(ops != []): opn = -1 n = 0 while (n < len(ops)): if (opn == -1): opn = n else: if (ops[opn] == '+' or ops[opn] == '-'): if (ops[n] == '*' or ops[n] == '/'): opn = n if (ops[opn] == '*' or ops[opn] == '/' or ops[opn] == '+' or ops[opn] == '-'): if (ops[n] == '^'): opn = n n+=1 if (ops[opn] == '+'): nums.insert(opn, nums.pop(opn) + nums.pop(opn)) elif (ops[opn] == '-'): nums.insert(opn, nums.pop(opn) - nums.pop(opn)) elif (ops[opn] == '*'): nums.insert(opn, nums.pop(opn) * nums.pop(opn)) elif (ops[opn] == '/'): nums.insert(opn, nums.pop(opn) / nums.pop(opn)) elif (ops[opn] == '^'): nums.insert(opn, nums.pop(opn) ** nums.pop(opn)) ops.pop(opn) return nums[0]
def calc(nums, ops): while(ops != []): opn = -1 n = 0 while (n < len(ops)): if (opn == -1): opn = n else: if (ops[opn] == '+' or ops[opn] == '-'): if (ops[n] == '*' or ops[n] == '/'): opn = n if (ops[opn] == '*' or ops[opn] == '/' or ops[opn] == '+' or ops[opn] == '-'): if (ops[n] == '^'): opn = n n+=1 if (ops[opn] == '+'): nums.insert(opn, nums.pop(opn) + nums.pop(opn)) elif (ops[opn] == '-'): nums.insert(opn, nums.pop(opn) - nums.pop(opn)) elif (ops[opn] == '*'): nums.insert(opn, nums.pop(opn) * nums.pop(opn)) elif (ops[opn] == '/'): nums.insert(opn, nums.pop(opn) / nums.pop(opn)) elif (ops[opn] == '^'): nums.insert(opn, nums.pop(opn) ** nums.pop(opn)) ops.pop(opn) return nums[0] print(calc([1, 2, 3, 4], ['+', '^', '+']))
10 + 2 * 3
nums = [10, 2, 3]
operators = ['+', '*']
operators[0]
nums[0] + nums[1]
operators[n] nums[n] nums[n+1]
f = nums.pop(opn)s = nums.pop(opn) nums.insert(opn, f + s)
1 + 2 ^ 3 + 4
string = raw_input()
string = string.strip(' \t\n\r')
if string == " " :
del " "
d = ""
n = ""
nums = []
operators = []
for c in string:
if (c >= '0' and c <= '9'):
n += c
else: nums.append(int(n))
n = nums.append(int(n))
for b in string :
if (b == "+" or b == "*" or b =="/" or b == "-" or b == "=" ) :
operators.append(d)
if "=" in operators:
print "start here equals "
else :
print string
calc(nums, operators)
string = raw_input()
string = string.strip(' \t\n\r')
d = ""
n = ""
nums = []
operators = []
for c in string:
if (c >= '0' and c <= '9'):
n += c
else: nums.append(int(n))
n = nums.append(int(n))
for b in string :
if (b == "+" or b == "*" or b =="/" or b == "-" or b == "=" ) :
operators.append(d)
if "=" in operators:
print "start here equals "
else :
print string
calc(nums, operators)
string = raw_input()
string.replace(" ","")
d = ""
n = ""
nums = []
operators = []
for c in string:
if (c >= '0' and c <= '9'):
n += c
else:
nums.append((n))
n =""
nums.append((n))
print nums
for b in string :
if (b == "+" or b == "*" or b =="/" or b == "-" or b == "=" ) :
operators.append(d)
if "=" in operators:
print "start here equals "
else :
print string
s = input() string = "" for c in s: if (c != ' ' and c != '\n' and c != '\t' and c != '\r'): string += c n = "" nums = [] operators = [] for c in string: if (c >= '0' and c <= '9'): n += c else: nums.append(float(n)) n = "" nums.append(float(n)) for b in string : if (b == "+" or b == "*" or b =="/" or b == "-" or b == "=" ) : operators.append(b) if "=" in operators: print (" ") else : print (string, '=', calc(nums, operators))
string = raw_input()
string.replace(" ","")
d = ""
n = ""
nums = []
operators = []
for c in string:
if (c >= '0' and c <= '9'):
n += c
else:
nums.append((n))
n =""
nums.append((n))
print nums
for b in string :
if (b == "+" or b == "*" or b =="/" or b == "-" or b == "=" ) :
operators.append(d)
if "=" in operators:
print "start here equals "
else :
print string
تعليق