R
R
Roman Pertsev2021-11-15 07:24:57
Python
Roman Pertsev, 2021-11-15 07:24:57

I can't figure out what exactly is the syntax error?

If anyone needs a task, then here:

Denote by DEL(n,m) the statement "a natural number n is divisible without
remainder by a natural number m". For what largest natural number A is the
formula
¬DIV(x, A) → (DIV(x, 6) → ¬DIV(x, 9))
identically true (that is, it takes the value 1 for any natural
value of the variable x)?


Error code:
def Del(n, m):
    if n % m == 0:
        return True
    else:
        return False


for A in range(1, 10000):
    flag = True
    for x in range(1, 10000):
        if ( not(Del(x,A)) <= (Del(x,6) <= not(Del(x,9))) ) == False:
            flag = False
    if flag == True:
        print(A)


Actually the error itself:
File "d:\Geek\UmShool\November\lesson_6\main.py", line 11
if ( not(Del(x,A)) <= (Del(x,6) <= not (Del( x,9))) ) == False: (The pointer falls on "not") SyntaxError: invalid syntax Here's what Pylance says:

6191e114c5164753120358.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Savelyev, 2021-11-15
@Asics6789

You need a parenthesis before not:

if ( not(Del(x,A)) <= (Del(x,6) <= (not(Del(x,9)))) ) == False:

And only junas write like this:
if ... == False

And in general, no one ever applies arithmetic operations like <= to boolean values.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question