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 all 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
28 changes: 28 additions & 0 deletions Code/chadL/Javascript/lab1/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
let body = document.body
let unit = prompt('Enter a unit of measure: inches, feet, meters, yards, kilometers, miles')
let number = prompt('Enter number to be converted')
console.log(unit);
console.log(number);

let values = {"feet": 0.3048,
"miles": 1609.34,
"meters": 1,
"kilometers": 1000,
"yards": 0.9144,
"inch:": 0.0254
}


let unitValue = values[unit];
let change = unitValue * number;
body.append(`Your input ${unit},
conversion: ${change} meters.`);


document.body.style.backgroundColor = "tan";


document.body.style.font = "italic bold 25px arial,serif";


document.getElementById("border").style.borderTop = "thick solid #0000FF";
17 changes: 17 additions & 0 deletions Code/chadL/Javascript/lab1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!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>
<script defer src="app.js"></script>
</head>
<body>
<div id="border">
<h1>Conversion Calculator</h1>
</div>

<p>Please enter your unit of measure to convert. </p>
</body>
</html>
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.

--------------------------------------------------------
'''
22 changes: 22 additions & 0 deletions Code/chadL/django/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_proj.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
21 changes: 21 additions & 0 deletions Code/chadL/django/redo/redo_app/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'redo_app.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Empty file.
16 changes: 16 additions & 0 deletions Code/chadL/django/redo/redo_app/redid_proj/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for redo_app project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'redo_app.settings')

application = get_asgi_application()
Loading