Hack 1: 3.5

[x] Explain in your own words what each logical operator does [x] Code your own scenario that makes sense for each logical operator

Hack 1

  • NOT: The NOT logical operator returns the opposite condtion of the data
  • AND: The AND logical operator determines if 2 conditions are met
  • OR: The OR logical operator determines if 1 of the conditions are met
ispassing = False
isstudentpassing = not(ispassing)
print(isstudentpassing)
True
temp = input("what is the temperature today?")
if int(temp) >= 40 and int(temp) <= 70:
    print("Bring a hoodie!")
if int(temp) < 40:
    print("bring snow gear!")
if int(temp) > 70:
    print("No jacket today!")
Bring a hoodie!
APscore = 4
Finalscore = 68
if APscore >= 3 or Finalscore >= 75:
    print("student passed this class")
else:
    print("student did not pass this class")
student passed this class

Hack 2: 3.6

[x] Level I: Vowel Count Return the number (count) of vowels in the given string. We will consider a, e, i, o, u as vowels for this challenge (but not y). The input string will only consist of lower case letters and/or spaces.

Hint: If you use a lot of if-statements and there are more than one outcome, that is to be expected. If not, don't panic, just keep trying.

[x] Level III: Mutliples of 3 or 5 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in. Additionally, if the number is negative, return 0 (for languages that do have them).

Note: If the number is a multiple of both 3 and 5, only count it once.

Hint: What do you know about for loops? Since your code incorporates a list of numbers from 1 to the max number, can you use for loops along with conditionals?

[x] binary conditional logic [x] define key terms

Defining Key Terms:

  • Boolean: a boolean is an operator that determines if a condition is true or false
  • Selection: When an algorithm must make a decision (if a condition is met)
  • AND: AND is a logical operator that determines of 2 conditions are both met
  • OR: OR is a logical operator that determines if 1 of 2 conditions is met
  • NOT: NOT is a logical operator that displays the oposition condition of the data
gpa = 4.0
extracirriculars = "present"
if gpa >= 4.0 and extracirriculars == "present":
    major = input("What is your major")
    if major == "math" or major == "science":
        print("You have been accepted into our STEM program!")
    elif major == "english" or major == "history":
        print("You have been accepted into our arts program!")
    else:
        print("You have been accepted into our " + major + " program!")
else:
    print("I'm sorry, you are not accepted to this program")
You have been accepted into our STEM program!
input_string = input("Input a string to check how many vowels it has. ")
vowelcount = 0
for character in input_string: #iterates through the string character by character
    if character == "a":
        vowelcount += 1
    elif character == "e":
        vowelcount += 1
    elif character == "i":
        vowelcount += 1
    elif character == "o":
        vowelcount += 1
    elif character == "u":
        vowelcount += 1
print(vowelcount)
7
numberstring = input("Input a number to find the sum of all the multiples of 3 or 5 below it. ")
numbertocheck = int(numberstring)
totalmultiples = 0
if numbertocheck >= 0: # if the number is negative it will display the sum as 0
    for n in range(numbertocheck+1):
        if n/3 == int(n/3): #checks for multiples of 3
            print(str(n) + " is a multiple of 3")
            totalmultiples += n    #elif prevents duplicates of numbers with both multiples of 3 and 5
        elif n/5 == int(n/5): # checks for multiples of 5
            print(str(n) + " is a multiple of 5")
            totalmultiples += n
print(totalmultiples)
0 is a multiple of 3
3 is a multiple of 3
5 is a multiple of 5
6 is a multiple of 3
9 is a multiple of 3
10 is a multiple of 5
12 is a multiple of 3
15 is a multiple of 3
18 is a multiple of 3
20 is a multiple of 5
21 is a multiple of 3
24 is a multiple of 3
143

Hack 3

[x] For the first hack, pretend you are a school's test 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. [x] The second hack is more number-oriented. Create an algorithm that calculates the sum of two numbers, then determines whether the sum is greater than or less than 100. [x] The hacks above was heavily derived from CollegeBoard. As a computer science student, you should be able to create an algorithm utilizing conditionals. Try something number-oriented if you get stuck. Creativity gets points.

def average(lst):
    return sum(lst)/len(lst)

gradelist = [92, 83, 90, 74, 86, 97]
averagegrade = average(gradelist)

print(str(averagegrade) + " is the student's grade average")

if averagegrade >= 75:
    print("student is eligible for credit")
else:
    print("student needs to retake tests during break")
87.0 is the student's grade average
student is eligible for credit
num1 = input("What is your first number?")
num2 = input("What is your second number?")
sumofnumbers = int(num1) + int(num2)
if sumofnumbers >= 100:
    print(str(sumofnumbers) + " is greater than or equal to 100")
else:
     print(str(sumofnumbers) + " is less than than 100")
202 is greater than or equal to 100
# to test if a show is included in Netflix, and if it is recommended
showdictionary = {
    'Wednesday':5,  # key=title name and value=rating out of 5 stars
    'You':3, 
    'Knight Before Christmas':4, 
    'Red Notice':5,
    'Truth or Dare':1
}
show = input("What show are you looking for?")
if show in showdictionary.keys():
    print(show + " is available on Netflix")
    if showdictionary[show] >= 3:
         print("show/movie is recommended")
    else:
        print("show is not recommended")
else:
    print(show + " is not available on Netflix")
You is available on Netflix
show/movie is recommended

Hack 4

[x] Create 3 differnt flow charts representing nested statements and transfer them into code. [] Create a piece of code that displays four statements instead of three. Try to do more if you can. [x] Make piece of code that gives three different recommandations 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 = input("Are you intrested in STEM? Y or N")
if STEM == "Y":
    subject = input("Do you like math or science better?")
    if subject == "math":
        print("Class recommendations: Advanced Function Analysis, AP Calculus AB, AP Calculus BC, AP Statistics")
    if subject == "science":
        print("Class recommendations: Chemistry, Physics, AP Enviornmental Science, AP Physics, AP Chemistry")
else:
    language = input("Are you intrested in language? Y or N")
    if language == "Y":
        lansubject = input("Do you prefer a foreign language or English?")
        if lansubject == "foreign language":
            print("Class recommendations: Spanish, Mandarin, AP Spanish, AP Mandarin")
        if lansubject == "English":
            print("Class recommendations: American Literature, AP English Literature")
    if language == "N":
        print("See class list for more options!")
Class recommendations: Advanced Function Analysis, AP Calculus AB, AP Calculus BC, AP Statistics

Flowchart #1: Is it cold?

<!-- <img src="_images/ColdFlowChart.png" alt="flowchart1">
temp = input("what is the temperature today?")
if int(temp) <= 73:
    print("It is cold!")
    if int(temp) <= 40:
        print("Bring a snow jacket!")
    else:
        print("Bring a hoodie!")
else:
    print("It's warm today! Don't bring a jacket :)")
It is cold!
Bring a hoodie!

Flowchart #2: Is the class difficult?

<!-- <img src="_images/Istheclassdifficult.png" alt="flowchart2">
passingrate = 72
testaverage = 82
if passingrate > 70 and passingrate <= 100:
    if testaverage >= 80:
        print("This class is not difficult")
    else:
        print("this class is difficult")
else:
    print("this class is difficult")
This class is not difficult

Flowchart #3: Should Alexa work at school during first period off roll?

<!-- <img src="_images/Offrollflowchart.png" alt="flowchart3"> -->
feeling = input("Are you tired today?")
if feeling == "yes":
    print("Stay home and sleep")
if feeling == "no":
    homework = input("Do you have homework to do?")
    if homework == "yes":
        print("Go to school")
    else:
        print("Stay home and sleep")
Go to school
drinkable = "potable"
temperature = "warm"
if drinkable == "potable":
    print("water is potable")
    if temperature == "cold":
        print("water is " + str(temperature)) 
        print("water is in ideal condition")
        print("drink up!")
    else:
        print("water is " + str(temperature)) 
        print("water is not in ideal condition")
        print("chill with ice")
else:
    print("do not drink, water is not potable")
water is potable
water is warm
water is not in ideal condition
chill with ice

Kahoot quiz: The Kahoot is not playble