Notes:

Nested Conditionals

  • Nested conditional statements consist of conditional statements within conditional statements
  • they're nested one inside the other
  • An else if inside of another else if
  • Can be used for a varying amount of "else if statements." The first if statement can represent if two coditions are true. The first else if can represent if only one or the other is true. The last else if represents if neither of the conditions are true.

Take aways

  • Learn how to determine the result of nested condtional statements
  • Nested conditional statements consist of conditional statements within conditional statements

Essential Knowledge

  • Conditional statements ("if" statements) affect the sequential flow of control by executing different statements based on the value of a Boolean expression.
  • In which the code in block of statements is executed if the Boolean expression condition evaluates to true; no action is taken if condition evaluates to false

  • Conditionals allow for the expression of algorithms that utilize selection without a programming language.

  • Writing conditional statements is key to computer science.
  • Determine the result of conditional statements

  • The defention of a Boolean is a denoting a system of algebraic notation used to represent logical propositions, especially in computing and electronics.

  • A boolean expresions are either true or false.
  • Testing if two numbers or variables are equal is a common example.
  • For example: The sky is blue = True

Hacks

  • Explain in your own words what each logical operator does
    • AND: used to check if conditions are met
    • OR: used to check if one condition is met
    • NOT: it displays the opposite of whatever the data is. Mainly used for true/false, and does not effect the variable.
  • Code your own scenario that makes sense for each logical operator
pulling = True
result = not(pulling)
print(result)
False
handsomeness = 95
if handsomeness > 70 and handsomeness <= 100:
    print("You can pull!")
You can pull!
Handsomeness = 1
Personality = 21
if Handsomeness <= 0 or Personality > 20:
    print("You cant pull :(")
You cant pull :(
test1= 65
test2 = 67
test3 = 92
overall = test1 + test2 + test3
average = overall / 3
print(average)

if average >= 75:
    print("you passes the class!")
else: 
    print(" you failed, you must be a failure to your parents. see you in summer 🤡")
74.66666666666667
 you failed, you must be a failure to your parents. see you in summer 🤡

i did more than what the hack said to do.... a 1 maybe?

num1 = int(input("enter number one >>"))
num2 = int(input("enter number one >>"))
num = num1 + num2

print(num1, "+", num2, "=", num)
if num <= 100:
    print("Your number is less than 100 :(")
else:
    print("Your number is greater than 100!")
35 + 61 = 96
Your number is less than 100 :(

Pythagoras theorem.

import time 
import math

print("Solving for the hyp, leg A (vertical) or leg B (horizontal)?")
print("(1) - Hyp.")
print("(2) - Leg A")
print("(3) - Leg B")
response= input(">>")

if response == "1":
    print("------------------------------------------------------------")
    print("Solving for the hypotenuse")
    print("------------------------------------------------------------")
    print("Please input the value of variable A")
    a=int(input(">>"))
    print("please input the value of variole B")
    b=int(input(">>"))

    x=a**2
    y=b**2

    c= x+y

    answer=math.sqrt(c)
    print("variable C is:")
    print(answer)
    print("------------------------------------------------------------")
    time. sleep(2)
else:
    if response == "2":
        print("------------------------------------------------------------")
        print("Solving for the leg B")
        print("------------------------------------------------------------")
        print ("please input the value of variable A")
        b2= int(input(">>"))

        print ("please input the value of variable C / hypotenuse.")
        c2= int(input(">>"))

        b3=b2**2
        c3=c2**2

        a2=c3-b3

        answer2= math.sqrt(a2)

        print(answer2)

        print("------------------------------------------------------------")
        time. sleep(2)

    else:
        if response == "3":
            print("------------------------------------------------------------")
            print("Solving for the leg A")
            print("------------------------------------------------------------")
            print ("please input the value of variable B")
            b4=int(input(">>"))

            print ("please input the value of variable C / hypotenuse.")
            c4= int(input(">>"))

            b5=b4**2
            c5=c4**2

            a3=c5-b5

            answer3= math.sqrt(a3)

            print(answer3)

            print("------------------------------------------------------------")
            time. sleep(2)
Solving for the hyp, leg A (vertical) or leg B (horizontal)?
(1) - Hyp.
(2) - Leg A
(3) - Leg B
------------------------------------------------------------
Solving for the leg B
------------------------------------------------------------
please input the value of variable A
please input the value of variable C / hypotenuse.
4.0
------------------------------------------------------------

^ the varible for the a and b was 3 & 5

Color = "white"
size = "10.5"
if Color=="white":
    if size !="10.5":
        print("right color wrong size")
    elif size == "10.5":
        print("right color and right size")
else: 
    if size !="10.5":
        print("wrong color wrong size")
    elif size == "10.5":
        print("wrong color and right size")
right color and right size
Temp = 95
raining = True
if Temp >55 :
    if raining == True:
        print("it is hot and raining")
    elif raining == False:
        print("it is hot and not raining")
elif Temp<55:
    if raining == True:
        print("it is cold and raining")
    elif raining == False:
        print("it is cold and not raining")
it is hot and raining
bladder = 25
bathroom_pass = "gone"
if bladder > 50:
    if bathroom_pass == "gone":
        print("you cant go to the bathroom")
    elif bathroom_pass == "there":
        print("you can go to the bathroom")
else:
    print("dont use the bathroom")
dont use the bathroom
bladder = 56
bathroom_pass = "gone"
Teachers_mood = "horrible"
if bladder > 50 and Teachers_mood == "good":
    if bathroom_pass == "gone":
        print("you cant go to the bathroom")
    elif bathroom_pass == "there":
        print("you can go to the bathroom")
if Teachers_mood == "horrible" and bladder > 50:
        print("pee your pants. boohoo.")
else:
    print("dont use the bathroom")
pee your pants. boohoo.
STEM = False
Electives = True
if STEM:
  print("Calculus, Physics, Biology")
elif Electives:
  print("Photography, APCSP, APCSA, Robotics")
else:
  print("PE, art, english")
Photography, APCSP, APCSA, Robotics