#🔒 help review first project pls
35 messages · Page 1 of 1 (latest)
@wispy spindle
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
can you show me the usage?
Enter the problem to solve: ab!c!d!e + !c!d!e!a!b
Simplify with single variable theorems
ab!c!d!e + !c!d!e!a!b = ab!c!d!e + !a!b!c!d!e
Factorising problem
ab!c!d!e + !a!b!c!d!e = !c!d!e(ab + !a!b)
!c!d!e(ab + !a!b)
Simplify terms within brackets
ab + !a!b = a XNOR b
Put simplified terms into bracket
!c!d!e(ab + !a!b) = !c!d!e(a XNOR b)
I enter boolean algebra with 2 terms
and it will show the steps and final expression
!code kindly use code block
you could just used code block like said on the bot's message
what does a code block do?
Sorry I'm new to this
Enter the problem to solve: ab!c!d!e + !c!d!e!a!b
Simplify with single variable theorems
ab!c!d!e + !c!d!e!a!b = ab!c!d!e + !a!b!c!d!e
Factorising problem
ab!c!d!e + !a!b!c!d!e = !c!d!e(ab + !a!b)
!c!d!e(ab + !a!b)
Simplify terms within brackets
ab + !a!b = a XNOR b
Put simplified terms into bracket
Oh
you could try to make it OOP, to make the code cleaner and more readable
thanks I'll try that
I don't think 300 lines in one .py file is needed for this, you can maybe break it up into seperate files
And add classes
well usualy i have something like 500 lines of code on single file...
I'm not saying it's bad
Depends on the project
Surely you can use a class for this - py def check_for_error(problem): terms = problem.split('+') #a,+,b,+ spacing = problem.split() problem_check = all(ch.isalpha() or ch.isdigit() or ch == '+' or ch == ' ' or ch == '!' for ch in problem) #check for valid characters if '(' in problem or ')' in problem: #declines brackets return 'Brackets are not accepted' if not problem.strip(): #declines empty input return 'please enter a valid input' if '!!' in problem: #checks for typos like !! return "double '!' is not allowed" if problem_check == False: #checks if characters are valid return 'Invalid input' if terms[0] in ('',' ') or terms[-1] in ('', ' '): #check if there are any equation errors, like +a or ++ return 'Terms are not accepted' if len(terms) > 2: #enforces only 2 operands return 'Maximum 2 terms' elif len(terms) < 2: return 'single' #returns single if only 1 term, for simplification if len(spacing) != 3: #checks for spacing return 'Please ensure correct spacing' return 'pass'
or loop list
you can do parser with separate code that does the lexer and parsing
Can I see an example of this
what do you mean?
parser with separate code that does the lexer and parsing
huh?
what do u mean
like this? - precedence = (
('left', 'STRING', 'KEYWORD'),
('left', 'MULTIPLY', 'DIVIDE')
)
its more like this
tokens = lexer(data)
output = parser(tokens)
I see
so you would hold this in a seperate py file?
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.