No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
I have written a working calculator program but it will not work out negative inputs. For example, 3+2 = 5.0, but, -2+5 = Wrong type of expression (error message). The user inputs the calculation which is called "expression". I have two stacks, one for operators and one for operands and … |
|
I have managed to change an input String expression with parentheses to a postfix expression. I want to print to print the values in the stack but can't work it out. Can anyone tell me how I do this? [code] class Converter{ private Stack converterStack; private String input; private String … |
|
My connect4 game works fine, but after a user wins the program exits and prints a few tracebacks. Is it possible to not print any tracebacks and just exit a program smoothly? |
|
I am trying to create a RPN calculator, the addition and subtraction functions work but it only accepts numbers under 10. How can I fix this so any integers are allowed? Thanks. [code] import sys accepted = '0123456789dr+-*/%^=' numbers = '0123456789' stack = [] while len(stack) <= 20: while True: … |
|
I have managed to create a custom sized grid which prints correctly but when I try and print X or 0 a new line is started. Please see the "test" result below. [code] def createBoard(): global rows,columns,board rows = input("How many rows (more than 4)? ") columns = input("How many … |
|
I need to only allow integers and the letters "d" and "r" from raw input otherwise I need to run an exception. For example: [I]You entered 's' this is invalid[/I] I have tried to use try/except statements but can't work it out. Is this the best way? Can someone help? … |