Nighthawk Pages

Homeworks and Popcorn Hacks for Lessons

All homeworks and hacks for 3.6, 3.7

Summary for Sprint 2 Lessons

Summary Without Examples

Summary without Examples

Lesson Topic
3.5 Boolean Expressions
Booleans are true or false statements. a == b (equals) a != b (not equal to) a > b (greater than) a < b (less than) a >= b (greater than or equal to) a <= b (less than or equal to) Are very case sensitve, depending on how many equal signs are used 5 !== '5' //true 5 != '5' // false
3.7 Nested Conditionals
Nested conditionals are pretty much the same if else, and they allow to check multiple conditions in a single sequence. This can be done by asking a user for information (See above at 3.4 for how to ask users)
3.10 Lists
Lists have already been covered in 3.1 and 3.2 ! Additional info: In python, index 1 is basically the second number in the list. Python starts counting at 0.

3.1

  • Variables: Help to define elemnts in your code.
    • variable = “whatever” OR let variable = “whatever”;
    • Types include Integers, Strings, Boolean, Float, and Lists
  • JavaScript variables also fall under the same types as the Python ones.
# Integer
a = 77

# String
song_lyrics = "La la al al al al alla lalala "

# Boolean (True/ false)
is_tall = False 

#Float (Integer, but decimal)
pi = 3.1415

#List
days_in_a_week = ["Monday", "Tuesday", "Wednesday"]

3.2

  • Tuples: immutable (unchangable). Often used in math to signify coordinates.
    • JavaScript : [8,12] Python: (8,12)
  • Abstractions: Allows you to add or remove things from a list or elements.
    • JavaScript: myset.delete Python: myset.remove
    • Javascript: ([]); Python: {“}
myset = {"orange", "banana"}
myset.add ("apples")
for i in myset: 
    print (i)

3.3

  • Easy stuff! Only thing new is MOD
    • Python + Javascript: %
numb1 = 10
numb2 = 15
numb3 = numb1 % numb2
print (numb3)

3.4

  • Concat strings: Combining two variable together using +
    • Can also prompt the user, and use the new information given to make a message.
    • JavaScript: prompt Python: input
favoriteFood = input ("Enter your favorite food: ")
favoriteSport = input("Enter your favorite sport: ")

message = "Your favorite food is " + favoriteFood + " and your favorite sport is " + favoriteSport + "."

print (message)

3.6

  • If else statements are used to satsify different conditions
    • if , elif, else (in Python) In java script, elif is typed out as ‘else if’
a = 12
if a > 5:
    print ("Greater than 5")
else: 
    print ("Smaller than 5")

3.7

Nested conditionls are pretty much the same if else, and they allow to check multiple conditions in a single sequence. This can be done by asking a user for information (See above at 3.4 for how to ask users)

Overall

  • JavaScript and Python are pretty much the same, with slight differences
    • JavaScript requires ; to be used at the end of every statement
    • Variables in JavaScript have a ‘let’ in front of them
    • JavaScript prints with console.log
  • My favorite hack was from 3.6 and 3.7 when we had to make a quiz based off of a subject that we were interested in
    • Code is very versatile, doesn’t have to be used for only technical things
Scroll to top