i got some homework for a program in python

``````'''
Function that haven't been achieved.
============================================

Maxium Number. No number bigger than 2147483648 or less than -2147483648;

Proper 'd' function
- Accept the result or only input.
- Proper 'd' substitution calculate.

.Gets the function of '='
.Has it's own list,
.Do not take part in calculation.
.Show the list

Unchanged 'r' Random function.

============================================
'''

# Filename = srpn.py;
# Generate the same functionality as srpn.sparc;

# =========================
# The general overall stack.
List = [];

# The 'd' function list;
D_list = [];
# The general overall stack.
# =========================
import random;
import string;

def command_rec(com):
temp_code = None;
try :
temp_code = com[0];
except :
pass;

if com == 'r':
return random.randint(1,10000000);
elif com == 'd':
print_List();
'''N = (len(List)-1);
while N > 0:
if type(List[N]) == type(1):
return List[N];
break;
else :
N = N-1;'''
return command_scan();
elif com == '+' or com == '-' or com == '*' or com == '/' or com == '%' or com == '^':
return com;
elif com == '=':
return command_scan();
elif com == '#' or temp_code == '#':
return '#';
else:
try :
print com;
return int(com);
except:
print com,'is not a valid number or command. '

def command_scan():
n = (len(List)-1);
#print 'n',n;
#print List[n];
if type(List[n]) == type(1):
pass;
else :
result = unit_check(n);
print result;
operand_Del();
return result;

def unit_check(num):
if num >= 0:

Warp = 2;
n = 0;
while ((type (List[num-n]) != (type (1)) and type (List[num-n-1]) != (type (1))) and (num-n-1>= 0)) :
n = n+1;
Warp = 2*(n+1);
if List[num] == '+':
return (unit_check(num-Warp) + unit_check(num-1));
elif List[num] == '-':
return (unit_check(num-Warp) - unit_check(num-1));
elif List[num] == '*':
if num-Warp < 0 :
return unit_check(num-1);
return (unit_check(num-Warp) * unit_check(num-1));
elif List[num] == '^':
if num-Warp < 0 :
return unit_check(num-1);
return (unit_check(num-Warp)) ** (unit_check(num-1));
elif List[num] == '/':
if num-Warp < 0 :
return unit_check(num-1);
try:
return (unit_check(num-Warp) / unit_check(num-1));
except:
print 'Divided by 0.'
elif List[num] == '%':
if num-Warp < 0 :
return unit_check(num-1);
try:
return (unit_check(num-Warp) % unit_check(num-1));
except :
print 'Divided by 0.'
else :
Temp_store = List[num];
del List[num];
List.insert(num,'NULL')
return Temp_store;
else:
print 'Stack under flow.'
return 0;

def operand_Del():
n = 0;
while n < len(List):
if type(List[n]) == type(1):
pass;
else :
del List[n];
n = n-1;
n = n+1;

def input_guide(ip):

temp_list = string.split(ip,' ',);
n = 0;
while n <= (len(temp_list)-1):
temp_store = command_rec(temp_list[n]);
if temp_store == '#':
break;
elif temp_store != None:
List.append(temp_store);

n = n+1;

def print_List():
n = 0;
while n < (len(List)):
try:
print int(List[n]);
except:
pass;
n = n+1;

def main():
ip = raw_input();
if ip == 'end':
break;
elif ip == 'Show':
print List;
else :
input_guide(ip);

main();``````

this is my code
Program must be able to input at least two numbers and perform one operation correctly and output:
Input:
10
2
+
=
Input:
11
3
-
=
Program must be able to handle multiple numbers and multiple operations
Input:
3
3
*4
4
*+
=
Input:
1234
2345
3456
d
+
d
+
d
=
Program must be able to correctly handle saturation
Input:
2147483647
1
+
=
Input:
-2147483647
1
-
=
20
-
=
Input:
100000
0
100000
-
d
*
=
Program includes the less obvious features of srpn. These include but are not limited to:
Input:
1
+
Input:
10
5
-5
+
/
Input:
1 1 + 1 + 1 + d
Input:
# This is a comment
1 2 + # And so is this
d
Input:
3 3 ˆ 3 ˆ 3 ˆ =
Input:
r r r r r r r r r r r r r r r r r r r r r r d r r r d
something wrong with my code but i cant find it
plz someone help me...
tx.

Not likely
3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Ene Uran

I think there are a number of so called Reverse Polish Notation calculator examples on this forum.