Essential Knowledge Questions

  1. Explain in your own words what each logical operator does

a. NOT : displays opposite of data inputted b. AND : determine if two conditions are met c. OR : determine if one of the conditions is met


Logical Operators

Code your own scenario that makes sense for each logical operator

AND

water = 10
if water > 5 and water <= 20:
    print("drink more water")

OR

water = 1
ice = 21
if water <= 0 or ice > 20:
    print("too cold")

NOT

clouds = False
result = not(clouds)
print(result)

Grader

Create an array with integers, each integer representing one score from a student's taken tests. If the average of the student's test scores are at least 75 percent, then display that the student is elligible for credit, and if not, display that the student must retake the tests over break.

grades = ['30', '80', '90', '89', '75', '60']
average = sum(grades)/len(grades)
# printing extra credit
if average > 75:
    print("extra credit!")
# if less then 75
if average < 75:
    print ("retake :(")

Algorithm Calculator

Create an algorithm that calculates the sum of two numbers, then determines whether the sum is greater than or less than 100. (number oriented and creative)

# user input of data numbers
x = input("type a number:")
y = input("type your second number:")
# adding the numbers
sum = int(x) + int(y)
# printing the sum
print("the sum is:", sum)
x = input("type a number:")
y = input("type your second number:")

sum = int(x) + int(y)
# if it is greater than
if sum > 100:
    print("the number is less than 100!")
# if it is less than
else:
    num = list(range(sum,101,1))
    print("the number is more than 100")

Flowcharts in Code

Create 3 different flow charts representing nested statements and transfer them into code.

1

1

weather = "sunny"
temp = "80"
if weather == "sunny":
    if temp =="80":
        print("right weather wrong temp")
    elif temp =="80":
        print("right temp and right weather")

else:
    if temp =="80":
        print("wrong weather wrong temp")
    elif temp =="80":
        print("wrong weather and right size")

2

weather = "cloudy"
temp = "40"
if weather == "cloudy":
    if temp =="40":
        print("right weather wrong temp")
    elif temp =="40":
        print("right temp and right weather")

else:
    if temp =="40":
        print("wrong weather wrong temp")
    elif temp =="40":
        print("wrong weather and right size")

3

if temp > 80:
    if weather == "hot":
        print("wear light clothes")
    elif store == "cold":
        print("wear a jacket")
else:
    print("no weather report today")

Four Statement Code

Create a piece of code that displays four statements instead of three. Try to do more if you can.

if temp > 100:
    if weather == "cold":
        print("it will be cold today")
    elif clouds == "rainy":
        print("bring an umbrella")
    elif sunny == "it will be a nice day":
        print("go outside")
# if temp is < than 100
else:
    print("it's too hot")

Class Recommendations

Make piece of code that gives three different recommendations for possible classes to take at a school based on two different condtions. These conditions could be if the student likes STEM or not.

STEM = True
ART = True
# if STEM was chosen
if STEM:
    print("APCalculus, APChem, APBiology")
# if ART was chosen
elif ART:
    print("APArtandDesign, APArtHistory, APMusicTheory ")