Orbtronics Junior
Program (Python)

Our STEM programs provide students with the knowledge, skills, and practical experience needed to succeed in the fields of science, technology, and engineering, opening up new doors to opportunity.

Logical Operator Exercise

1. Logical AND (and) Operator:
Write a program that checks if a number is divisible by both 2 and 5. If it is, print "The number is divisible by both 2 and 5". If it isn't, print "The number is not divisible by both 2 and 5".

2. Logical OR (or) Operator:
Write a program that checks if a number is either negative or greater than 100. If it is, print "The number is negative or greater than 100". If it isn't, print "The number is positive and less than or equal to 100".

3. Logical NOT (not) Operator:
Write a program that checks if a number is not divisible by 7. If it isn't, print "The number is not divisible by 7". If it is, print "The number is divisible by 7".

Assignment Operator Exercise

Basic assignment operator (=):
1. Assign the value 10 to a variable named num. Then print the value of num.

Add AND assign (+=):
2. Increase the value of num by 5 using the += operator. Then print the new value of num.

Subtract AND assign (-=):
3. Decrease the value of num by 3 using the -= operator. Then print the new value of num.

Multiply AND assign (*=):
4. Double the value of num using the *= operator. Then print the new value of num.

Divide AND (/=):
5. Halve the value of num using the /= operator. Then print the new value of num.

Exercise: Truth Tables for Logical Operators

Objective: This exercise aims to solidify your understanding of logical operators in Python - AND, OR, and NOT.

× How can we help you?