Student Lessons
- This is my blog about WiStem
- This is My Blog about the second lesson with my boy Theo
- Barn homework and Hacks
- Barn Python Practice
- PGK Homework and Hacks
- Exercise for PGK
- Sections 9 and 11 Homework and Hacks
- Section 14-15
- Section 16 Hacks
- Homework and Hacks Section 17 & 18
This is my blog about WiStem
Thought the lesson I learaned about Varibles and data abstraction.
I answered all of the question in the homework and placed top 10 in the kahoot and getting any of the questions wrong
An example of one of the HW problems and the answer was iscold, boolean
You are storing true or false in a variable that asks if the classroom is cold. What is the best variable name and data type?
weather, integer weather, boolean isCold, boolean cold, string
languages_list = []
languages_list = ["Python", "C++", "JavaScript", "One","BigBOi"]
languages_list = []
languages_list = ["Python", "C++", "JavaScript"]
print()
languages_list = []
languages_list = ["Python", "C++", "JavaScript"]
print(languages_list[0])
listA = []
listA = [1, 55, 8, 2, 76]
listB = []
listB = [22, 7, 13]
print()
listA = ["James", "Caleb"]
listB = ["Navan","Andrew"]
I worked on the Bianey Hacks/Questions and got 4 of the 6 correct but they was simple mistakes
Eample-
- 44
I said 101110
Answer is 101100
I tried the Extra Binary Hacks for if you changed your bits to 24 but really struggled in understanting it but asked my friend and he helped explain it and I got 3 correct for decimal notation and got 2/3 of the binary notation
Binary Hacks
Convert these binary notation to decimal notation. (the way we normally count)
The binary number 111.
Answer - 7
The binary number 1011.
Answer - 11
The binary number 1101011
Answer - 107
12
Answer - 1100
44
Answer - 101100
254
Answer - 11111110
Some of the problems I did for WiStem hacks and HW
Consider the following code segment:
num1 ⟵ 4
num2 ⟵ 6
num1 ⟵ num 2
DISPLAY(num1)
DISPLAY(num2)
What is displayed after running this code segment?
4 6
6 4
4 4
6 6
Answer - 4
p ⟵ 10
q ⟵ 20
r ⟵ 30
s ⟵ 40
p ⟵ q
q ⟵ r
s ⟵ q
r ⟵ p
What is the value of r as a result of running this code segment
10
20
30
40
Answer - 20
This is My Blog about the second lesson with my boy Theo
I think this was more of a refresher for me cause I knew this information pretty well and knew how to solve the equation from the start.
For the pratice problems under the vocab I tried for the first practice problem and then just looked at the answers for the rest but i did get the first problem correct legit using a calc.
num 1 ⟵ 25
num 2 ⟵ 43
num 3 ⟵ 18
average ⟵ (num 1 + num 2 + num 3)/3
display average A = 28.6666
For video 3 I understood the materal very well and again just looked at the answer without trying.
For 3.4 Video 1 I really diddn't know those vocab and teached me new stuff but am still mad that you said school has 5 letters when is has 6.
numbers = [0,1,2,3,4,5,6,7,8,9,10]
evens = []
for i in numbers:
if (numbers[i] % 2 == 0):
evens.append(numbers[i])
print(evens)
i = 1
starString = "*"
while i <= 5:
j = 1
while j <= i:
print ("*", end= "")
j += 1
print ()
i += 1
For video 2 hacks I actually did the work for the questions and was fairly easy not taking to much time
given the following code segment below: a ⟵ 7
b ⟵ 1
c ⟵ 3
d ⟵ 4
a ⟵ b
b ⟵ c + d
d ⟵ b
find the value for a, b, c, d a = 1 b = 7 c = 3 d = 7
Sequencing was fairly easy too I got the answer correct and was not a challenge. It is good practice though
num1 = 3
num2 = 1
num3 = 5
num1 = num2 + num3
num2 = num1 + num3
print(num1,num2)
3.4 Video 1 Hacks
This was fairly easy again not much challenge and didn't take me long to complete
Test 1
firstName <- "Bob" lastName <- "Smith" var <- substring(firstName, 1, 1) name <- concat(lastName, var) email <- concat(name, "@gmail.com") DISPLAY(email)
Answer = SmithB@gmail.com
Test 2
word1 <- "computer" word2 <- "textbooks" length1 <- len(word1)/2 length2 <- len(word2)/3 first <- substring(word1, 2, len1) second <- substring(word2, len2+3, len2) newWord <- concat(first, second) DISPLAY(newWord)
Answer = ompuook
Barn homework and Hacks
This is my blog for the Barn homework and hack and my answers to the questions.
3.5 Note Hacks
These are just some of the homework and hacks though all of the videos for Barn
- 90(D) = 1000(B)
A. True B. False
Answer - False
- 10(D) ≠ 0110(B)
A. True B. False
Answer - True
- 56(D) ≥ 111000(B)
A. True B. False
Answer - True
- 99(D) < 1110011(B)
A. True B. False
Answer - True
Value 1 | Value 2 | Result |
---|---|---|
1 | 1 | 1 |
1 | 0 | 0 |
0 | 1 | 0 |
0 | 0 | 0 |
Value 1 | Value 2 | Result |
---|---|---|
1 | 1 | 1 |
1 | 0 | 1 |
0 | 1 | 1 |
0 | 0 | 0 |
Not | Value | Result |
---|---|---|
Not | 1 | 0 |
Not | 0 | 1 |
Barn Python Practice
Vocab/Important information
For Loop - FOR LOOP repeats a function for a set number of times; I is the number of times repeated
While Loop - The while loop is used to repeat a section of code an unknown number of times until a specific condition is met
Initialization - What sets the counter variable to a starting value. For example (var i = 0) represents an initial value of 0.
Condition - Allows the computer to know whether or not to keep repeating the loop.
Increment/decrement - Modifies the counter variable after each repetition.
Append, remove, pop - Various methods, append adds an element to the end, remove removes at an index, and pop removes the last item.
Iterative statements are also called loops, and they repeat themselves over and over until the condition for stopping is met
# Practice with these statements
print(20 == 20) # How can you change the operator to print a value of False?
x = 30
y = 20
z = 10
print(x > y + z) # How can this return true by only manipulating the operator?
# Manipulate the variables x, y, and z to make the below statement return true
print(x == z)
The answer is True False False
AP Prep Homework & Hacks
1. What is displayed by this code?
- result <-- 75
- IF result < 80 { DISPLAY("Please schedule a retake.") }
- ELSE { DISPLAY("Nice job!") }
- Nice job!
- Display
- Please schedule a retake.
- 75
Answer - 3. Please schedule a retake
2. How is an if statement different from an if-else statement.
- Extra words.
- An if statement will only go through a process if a condition is met. An if-else statement will go through code no matter the conditions.
- They are the exact same.
- An if statement will go through the entire code segment every single time and the if-else statement is always used in an algorithm, no matter the conditions.
Answer - 2. An if statement will only go through a process if a condition is met. An if-else statement will go through code no matter the conditions.
3. What would be most appropriate for this situation? Ben wants to check his bank account. If his car fuel is full, he will go to the bank. Otherwise, he will go home. If he goes to the bank, he will withdraw money only if his balance is above $1000.
- If statement
- If-else statement
Answer - 2. If-else statement
4. What would be most appropriate for this situation? Luke wants to play basketball. If it is sunny outside he will go to the park to play basketball.
- If statement
- If-else statement
Answer - 1. If statement
animals = ["snake", "rat", "bird", "Humans", "jellyfish"]
for i in animals:
if i == "snake": # What boolean value does this statement cause?
print("A snake lives in the desert")
else:
if i == "rat": # What boolean value does this statement cause?
print("The rat is alive")
else:
print("Jellyfish sucks")
# Practice
# Using only one more if statement, alter the code to print out a statement saying if an animal lives in the desert, based on booleans
3.7 Hacks homework
This is my dictionary for the Exercise
Exercise 1
- Create dictionaries for multiple food items, with the listed specifications
- Chicken Alfredo, Meat: Chicken, Time to Prepare: 60 minutes
- Cheese Quesadilla, Meat: None, Time to Prepare: 10 minutes
- Beef Wellington, Meat: Beef, Time to Prepare: 150 minutes
- Used nested conditionals, determine which meal you can cook, given that a) you have no meat at home, and b) you only have 30 minutes to make the meal
chickendict = {
"meat": True,
"prepareTime": 60,
"name" : "chicken alfredo",
}
cheesedict = {
"meat": False,
"prepareTime": 10,
"name" : "cheese quesadilla",
}
beefdict = {
"meat": True,
"prepareTime": 150,
"name" : "beef wellington",
}
def mealPrep(prep):
if prep["prepareTime"] <= 30:
if prep["meat"] == False:
print(prep["name"], "is good for how much time you have")
else:
print("You have no meat you can't make", prep["name"])
else:
print("You don't have enough time for", prep["name"])
mealPrep(chickendict)
mealPrep(cheesedict)
mealPrep(beefdict)
PGK Homework and Hacks
I did these homework and hacks it took me some time but was not to hard but was good.
Quiz on the Website
This is my homework and hacks and Question 2 and 3 I got wrong and were challenging for me.
I had an image but it didn't work
These were my problems and were the ones I really didn't know. I knew the rest knowing them mostly.
list = [1, 2, 3, 4, 5]
list.reverse()
print("Sorted Lists", list)
list = [9, 8, 4, 3, 5, 2, 6, 7, 1, 0]
list.sort()
print("Sorted Lists", list)
Sections 9 and 11 Homework and Hacks
Here are some of the hacks for section 9 and 11
Question 1
{
if(isRaining){
day --> "cold"
}
if(isCold){
day --> "cold"
}
}
Question 2
import random
def turn():
max_int = 0
for i in range(4):
nint = random.randint(1, 10)
if nint > max_int:
max_int = nint
print(max_int)
turn()
turn()
Question 3
{
if CANMOVEFORWARD{
moveForwards
}
else{
if CANTURNRIGHT{
turnright
}
if CANTURNLEFT{
turnleft
}
}
}
Problem 4
Make a binary search tree of different the list [1,2,3,4,6,9,11,69]
Problem 5
Explain thoroughly how to find the number 69 in the list above (use key words)
We can use sequential search
Iterate through the list
Compare each number until we ind 69
We can also use binary search
Begin from the middle index then continue to the other numbers
Problem 6.
Make a diagram explaining how you found the list (not tree, include equation
Middle index
(1+8)/2=4.5~5
Make a diagram explaining how you found the list (not tree, include equation)
Question 7
["Market”, ”Ralphs”, “store”, "Target”, ”Walmart”]
You could add this in this order in order to put them in alphabetical order, ascending. This way these could be properly compared, as numbers are greater, you can compare which numerical value of these ascii characters is greater.
Question 8
Binary search is far quicker than sequential search because binary search inherently rules out half of the possibilities every iteration. Since you start at the middle index, you can either choose to pick the group that is greater than the middle index, or the group that is lower. As a result, you will rule out half of the known possibilities every single time you make a cut.
Question 9
[64,36,16,11,9] Explain which number you are finding, how many check it would take, and make a binary search tree
I am searching for the number 9, which would take 3 iterations. You would start at 16, the middle index. Then you would do 4+4/2 to get 4, so the next index would be 9.
Section 14-15
This is my notes and hacks for the sections 14 and 15
Vocab
Documentation: Text that explains the what, how, or why of your code.
Libraries: A collection of prewritten code or procedures that coders can use to maximize their efficiency.
Application Programming Interface: A type of software through several computers are able to communicate information amongst each other.
Notes
Libraries contain procedures that make programming easier.
procedures are especially good for reusing segments of code by calling the procedure.
random procedure: Random(a,b) provides a random number in the range [a, b]
Hacks
Multiple Choice
B) a random integer between 'a' and 'b' inclusive
A) x = start, y = stop, z = step
A) random.item() does not exist
Short Answer
Libraries are convenient because they provide procedures and prewritten code to maximize the efficiency of programmers
This procedure takes a list of strings and returns who will buy the meal today
import random
# takes user input, puts it into a list of names
names_string = input("Give me everybody's names, seperated by a comma.")
names = names_string.split(",")
num_items = len(names)
# uses random to choose a random number
random_choice = random.randint(0, num_items - 1)
# associates random number with a name
person_who_will_pay = names[random_choice]
# prints name
print(f"{person_who_will_pay} is going to buy the meal today!")
import random
NAMES = ["Aiden", "Brayden", "Bradley", "Harambe", "Charles", "BigChungus", "Chad", "Brett", "Dorian", "Ryan", "Varalu", "Rohin", "Advay", "SmallChungus"]
rand_list = []
def randomPeople(names, new_names):
count = 1
while count <= 5:
number = random.randint(0, len(names) - 1)
new_names.append(names[number])
count += 1
return new_names
print(randomPeople(NAMES, rand_list))
import random
score1 = 0
score2 = 0
def greatestRoll():
score1 = random.randint(1, 6) + random.randint(1, 6)
score2 = random.randint(1, 6) + random.randint(1, 6)
if score1 > score2:
print("Player 1 won with a score of " + str(score1) + " points!")
if score1 < score2:
print("Player 2 won with a score of " + str(score2) + " points!")
if score1 == score2:
print("Both players tied with " + str(score1) + " points!")
greatestRoll()
Section 16 Hacks
Notes
Simulations are system based processes that can be used to study behavior and different outcomes for multiple conditions. Simulations are mostly based on mathematical and statistical models which run through situations that are hard to analyze directly
Experiments are controlled studies that directly study behavioral and mathematical systems. In most circumstances, these involve changing certain variables to alter and study the outcomes.
Answers
Caleb Navarro
Question | Answer | |
---|---|---|
1 | N/A | |
2 | N/A | |
3 | C | |
4 | B | |
5 | A | |
7 | A | |
8 | N/A | |
9 | B |
Homework and Hacks Section 17 & 18
HACK 1
Please write a short 1-2 sentence explanation describing the difference between decidable and undecidable problems. Make sure to provide at least one example of each.
<font color=#FF0000>Undecidable problems are problems that algorithms simply cannot solve. One of the first problems discovered is the halting problem. Most of these problems are paradoxical and theoretical situations where answers are most likely are subjective. However, some of these problems can have situations where some inputs have values. But not all values are going to have outputs.</p>
Decidable problems are problems that algorithms can return an output for all inputs. Mostly, these are algebraical problems that are simply solvable.
</div> </div> </div>
HACK 2
Which of the following is a 3 step algorithm?
A. 2 x 6 x 8
B. 4^5
C. (3 x 8)^2
D. None of the above
E. All of the above
<font color=#FF0000>ANSWER: C</p>
STEP 1: 3 x 8
STEP 2 & 3: (24)^2
The first step is simply multiplying two numbers. The second and third is squaring the result of step one.
</div> </div> </div>
HACK 3: Rewrite this JavaScript Code in a More Efficient Way (Hint: Use Binary Search)
function peak_finder(array){
let counter = 0
let peak = 0
let peak_index =0
while (counter <= array.length){
console.log(counter)
if (counter === 0){
if (a[0]>=a[1]){
peak = a[0]
peak_index = counter
counter = array.length
return The ${counter-1} indexed number, ${peak} is a peak
}else{
counter+=1
}
}else if(counter === array.length-1){
if (a[array.length-1] >= a[array.length-2]){
peak = a[array.length-1]
peak_index = counter
counter = array.length
return The ${counter-1} indexed number, ${peak} is a peak
}
}else{
if (a[counter]> a[counter+1] && a[counter]> a[counter-1]){
peak = a[counter]
peak_index = counter
counter = array.length
return The ${counter-1} indexed number, ${peak} is a peak
}else{
counter += 1
}
}
}
}
new one below
function sum(n) { if (n <= 1) { return n; } return n + sum(n - 1); }
HACK 4: Rewrite this Python Code in a More Efficient Way
def merge_sort(data):
if len(data) <= 1:
return
#splits data in half, defines left and right
mid = len(data) // 2
left_data = data[:mid]
right_data = data[mid:]
merge_sort(left_data)
merge_sort(right_data)
left_index = 0
right_index = 0
data_index = 0
while left_index < len(left_data) and right_index < len(right_data):
if left_data[left_index] < right_data[right_index]:
data[data_index] = left_data[left_index]
left_index += 1
else:
data[data_index] = right_data[right_index]
right_index += 1
data_index += 1
if left_index < len(left_data):
del data[data_index:]
data += left_data[left_index:]
elif right_index < len(right_data):
del data[data_index:]
data += right_data[right_index:]
if __name__ == '__main__':
data = [9, 1, 7, 6, 2, 8, 5, 3, 4, 0]
merge_sort(data)
print(data)
data = [9, 1, 7, 6, 2, 8, 5, 3, 4, 0]
print("original list")
print(data)
data.sort()
print("-----------------")
print("sorted list")
print(data)
def heap_permutation(data, n):
if n == 1:
print(data)
return
for i in range(n):
heap_permutation(data, n - 1)
if n % 2 == 0:
data[i], data[n-1] = data[n-1], data[i]
else:
data[0], data[n-1] = data[n-1], data[0]
if __name__ == '__main__':
data = [1, 2, 3]
heap_permutation(data, len(data))
from itertools import permutations
perm = permutations([1, 2, 3])
for i in list(perm):
print(i)