Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chad labs #181

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions Code/chadL/Python/Lab14.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#1
"""
import time
import requests
import re

response = requests.get("https://icanhazdadjoke.com", headers={
'Accept': 'application/json'
})

response_dict = response.json()
joke = response_dict["joke"]


joke_list = re.split(pattern = r"[.,?!]",
string = joke)

for i in joke_list:
if i == '':
del joke_list[-1]

print(joke_list[0])
time.sleep(3)
print(joke_list[1])
"""

#2
import time
import requests
import re

while True:

search_term = input("What would you like to search for? Type 'done' to exit. ")

if search_term == "done":
break

response = requests.get(f"https://icanhazdadjoke.com/search?term=${search_term}", headers={
'Accept': 'application/json'
})

response_dict = response.json()
print(response_dict)

"""
joke = response_dict["joke"]


joke_list = re.split(pattern = r"[.,?!]",
string = joke)

for i in joke_list:
if i == '':
del joke_list[-1]

print(joke_list[0])
time.sleep(3)
print(joke_list[1])
"""

Where do rabbits go after they get married? On a bunny-moon. Where do rabbits go after they get married
PZDd', 'joke': 'When does a joke become a dad joke? When it becomes apparent.'},
{'id': 'FBQ7wskbMmb', 'joke': "Want to hear a joke about construction? Nah, I'm still working on it."},
{'id': 'rc2E6EdiNe', 'joke': "Want to hear my pizza joke? Never mind, it's too cheesy."},
{'id': 'EYo4TCAdUf', 'joke': 'I tried to write a chemistry joke, but could never get a reaction.'},
{'id': '8USSSfVn3ob', 'joke': "I've been trying to come up with a dad joke about momentum . . . but I just can't seem to get it going."},
{'id': 'ozPmbFtWDlb', 'joke': "Some people say that comedians who tell one too many light many levels."}
], 'search_term': '$joke', 'status': 200, 'total_jokes': 12, 'total_pages': 1}
47 changes: 47 additions & 0 deletions Code/chadL/Python/lab7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#Lab 7: ROT Cipher

hacker = input("What shall we encypt? ").lower() #ask user for words to encypt

rot13_dict = { #dictinary of associated letters
"a": "n",
"b": "o",
"c": "p",
"d": "q",
"e": "r",
"f": "s",
"g": "t",
"h": "u",
"i": "v",
"j": "w",
"k": "x",
"l": "y",
"m": "z",
"n": "a",
"o": "b",
"p": "c",
"q": "d",
"r": "e",
"s": "f",
"t": "g",
"u": "h",
"v": "i",
"w": "j",
"x": "k",
"y": "l",
"z": "m",
" ": " "
}

hacker = list(hacker) #turn input into list


def rot_13(hacker): #fucntion to turn input into list.
rot13_list = []
for letter in hacker: #loop to add appended letter to list
cypher = rot13_dict[letter]
rot13_list.append(cypher) # add cypher to rot13 list

final_answer = ''.join(rot13_list) # .join seperates everything except the letters.
print(f"Your encrypted code is: {final_answer}")

rot_13(hacker)
44 changes: 44 additions & 0 deletions Code/chadL/Python/lab8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
data = [1, 2 , 3, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9] #peaks and valleys list


def peaks(data):
for index, number in enumerate(data):
if index == 0 or index == len(data) -1: #not running first index or last
continue

elif number > data[index -1 ] and number > data[index + 1]: #checking if index before or after is less then number
print(index)

def valleys(data):
for index, number in enumerate(data):
if index == 0 or index == len(data) -1:
continue

elif number < data[index -1 ] and number < data[index + 1]: ##checking if index before or after is greater then number
print(index)

def peaks_valleys(data):
for index, number in enumerate(data):
if index == 0 or index == len(data) -1:
continue

elif number > data[index -1 ] and number > data[index + 1]:
print(index)

elif number < data[index -1 ] and number < data[index + 1]:
print(index)

peaks_valleys(data)


"""
Lab 8: Peaks and Valleys
Define the following functions:

peaks - Returns the indices of peaks. A peak has a lower number on both the left and the right.

valleys - Returns the indices of 'valleys'. A valley is a number with a higher number on both the left and the right.

peaks_and_valleys - uses the above two functions to compile a single list of the peaks and valleys in order of appearance in the original data.
"""

97 changes: 97 additions & 0 deletions Code/chadL/Python/lab9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# compute ARI

with open("text.txt") as file:
text = file.read()

character_count = 0
for character in text:
if character == " " or character == "," or character == ".":
continue
else:
character_count += 1

word_list = text.split(" ")
word_list = len(word_list)

sentence_list = text.split(".")
sentence_list = len(sentence_list)

formula = 4.71 * (character_count / word_list) + 0.5 * (word_list / sentence_list) - 21.43
print(formula)


ari_scale = {
1: {'ages': '5-6', 'grade_level': 'Kindergarten'},
2: {'ages': '6-7', 'grade_level': '1st Grade'},
3: {'ages': '7-8', 'grade_level': '2nd Grade'},
4: {'ages': '8-9', 'grade_level': '3rd Grade'},
5: {'ages': '9-10', 'grade_level': '4th Grade'},
6: {'ages': '10-11', 'grade_level': '5th Grade'},
7: {'ages': '11-12', 'grade_level': '6th Grade'},
8: {'ages': '12-13', 'grade_level': '7th Grade'},
9: {'ages': '13-14', 'grade_level': '8th Grade'},
10: {'ages': '14-15', 'grade_level': '9th Grade'},
11: {'ages': '15-16', 'grade_level': '10th Grade'},
12: {'ages': '16-17', 'grade_level': '11th Grade'},
13: {'ages': '17-18', 'grade_level': '12th Grade'},
14: {'ages': '18-22', 'grade_level': 'College'}
}

#print(f'The ARI for "text.txt" is 12 This corresponds to a 11th Grade level of difficulty that is suitable for an average person {ari_scale[]} years old.')


'''
Score Ages Grade Level
1 5-6 Kindergarten
2 6-7 First Grade
3 7-8 Second Grade
4 8-9 Third Grade
5 9-10 Fourth Grade
6 10-11 Fifth Grade
7 11-12 Sixth Grade
8 12-13 Seventh Grade
9 13-14 Eighth Grade
10 14-15 Ninth Grade
11 15-16 Tenth Grade
12 16-17 Eleventh grade
13 17-18 Twelfth grade
14 18-22 College


Lab 9: Compute Automated Readability Index
Compute the ARI for a given body of text loaded in from a file.
The automated readability index (ARI) is a formula for computing the U.S. grade level for a given block of text.
The general formula to compute the ARI is as follows:

ARI Formula

The score is computed by multiplying the number of characters divided by the number of words by 4.71,
adding the number of words divided by the number of sentences multiplied by 0.5, and subtracting 21.43.
If the result is a decimal, always round up.
Scores greater than 14 should be presented as having the same age and grade level as scores of 14.

ari_scale = {
1: {'ages': '5-6', 'grade_level': 'Kindergarten'},
2: {'ages': '6-7', 'grade_level': '1st Grade'},
3: {'ages': '7-8', 'grade_level': '2nd Grade'},
4: {'ages': '8-9', 'grade_level': '3rd Grade'},
5: {'ages': '9-10', 'grade_level': '4th Grade'},
6: {'ages': '10-11', 'grade_level': '5th Grade'},
7: {'ages': '11-12', 'grade_level': '6th Grade'},
8: {'ages': '12-13', 'grade_level': '7th Grade'},
9: {'ages': '13-14', 'grade_level': '8th Grade'},
10: {'ages': '14-15', 'grade_level': '9th Grade'},
11: {'ages': '15-16', 'grade_level': '10th Grade'},
12: {'ages': '16-17', 'grade_level': '11th Grade'},
13: {'ages': '17-18', 'grade_level': '12th Grade'},
14: {'ages': '18-22', 'grade_level': 'College'}
}
the output should look like:
--------------------------------------------------------

The ARI for gettysburg-address.txt is 12
This corresponds to a 11th Grade level of difficulty
that is suitable for an average person 16-17 years old.

--------------------------------------------------------
'''
48 changes: 48 additions & 0 deletions Code/chadL/html_css/lab1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="lab1style.css">
</head>

<body>
<p>
Taserface is the up and coming leader of a band of brigands, who will rule the galaxies with fear and respect.
</p>
<img src="lab1pic.jpg" alt="Alien guy">
<br>
<a href="https://marvelcinematicuniverse.fandom.com/wiki/Taserface">
Wiki_Button
<style type = "text/css">
a:link {color: lightblue;}
a:visited {color: #796feb}
a:hover {color: #FCFC0C}
a:active {color: #C0F0FC}
</style>
</a>

<p>
Tazerface has lived in space most of his life.
</p>


<ul>
<li>eclector</li>
<li>various planets</li>
<li>various Spaceships </li>
</ul>



<p class = "quote">
"You're the one what killed those men by leading them down the wrong path.<br>
Because you're weak and stupid! It's time for the Ravagers to rise once again to glory with a new captain: Taserface!"<br>
―Taserface to Yondu Udonta
</p>

<background-image url="https://getwallpapers.com/wallpaper/full/d/d/8/557330.jpg">
</body>
</html>
48 changes: 48 additions & 0 deletions Code/chadL/html_css/lab1/lab1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="lab1style.css">
</head>

<body>
<p>
Taserface is the up and coming leader of a band of brigands, who will rule the galaxies with fear and respect.
</p>
<img src="lab1pic.jpg" alt="Alien guy">
<br>
<a href="https://marvelcinematicuniverse.fandom.com/wiki/Taserface">
Wiki_Button
<style type = "text/css">
a:link {color: lightblue;}
a:visited {color: #796feb}
a:hover {color: #FCFC0C}
a:active {color: #C0F0FC}
</style>
</a>

<p>
Tazerface has lived in space most of his life.
</p>


<ul>
<li>eclector</li>
<li>various planets</li>
<li>various Spaceships </li>
</ul>



<p class = "quote">
"You're the one what killed those men by leading them down the wrong path.<br>
Because you're weak and stupid! It's time for the Ravagers to rise once again to glory with a new captain: Taserface!"<br>
―Taserface to Yondu Udonta
</p>

<background-image url="https://getwallpapers.com/wallpaper/full/d/d/8/557330.jpg">
</body>
</html>
Binary file added Code/chadL/html_css/lab1/lab1pic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions Code/chadL/html_css/lab1/lab1style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.quote {font-family: fantasy;
font-style: italic;
font-size: 22px;
}

body {text-align: center;
color: red;
font-size: 12;
}

p {margin: 50px;
padding: auto;
font-family: monospace;

}
html{
background-image: url(https://getwallpapers.com/wallpaper/full/d/d/8/557330.jpg);
}
img {border-radius: 200px}

Binary file added Code/chadL/html_css/lab1pic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading