Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+7 votes

hey guys,
im working on a personal project, and i was looking for some help online and i came across some examples online that add "and not" inside the if statements, if anyone is familir with this, could you please let me know hen do i have to add them?

asked in CSC201 Spring 2021 by (2.3k points)
edited by
+2

Yeah! We would love to see what you've been working on :)

+1

i am currently working on pathfinding algorithms, the A* one to be more specific :)

3 Answers

+2 votes

Hey Adam, can you please be more specific on what project you are working on and the help you are seeking?

answered by (2.2k points)
+1

not looking for any specific help, i was just asking about the if statement thing, dm me I'll tell you the details

+2 votes
answered ago by (2.7k points)
+1 vote

I'm not familiar with 'and not' statements. Could you mean just the 'not' method is a logical operator in python so if you used to return objects that would be true if the expression would be false. The 'and' part of the statement is just defining what the operator should return just like we learned about with 'or', and 'and' statements.

for e.x:

x = 6
if  not x > 6:
   print ('true')
else:
   print('false')
>>> true

This code returns true because although x = 6 is not greater than the numerical value defined in the if statements, the 'not' operator changed the false return to true. If you removed the 'not' operator the code would run normally returning false.

x = 6
if x > 6:
     print ('true')
else:
     print ('false')
>>> false

I hope this helps and answers your question because again I've never experienced 'and not' statements just 'not' statements.

answered ago by (732 points)
...