From 3954d3b1bf66b6b9b37a2e046597a6f442383f33 Mon Sep 17 00:00:00 2001 From: Gentleman-DE Date: Tue, 29 Oct 2024 14:11:37 +0100 Subject: [PATCH] a --- WS24_25/PyCharm/pythonProject/P4/data.py | 125 ++++++++++++++++++++ WS24_25/PyCharm/pythonProject/P5/compute.py | 55 +++++++++ WS24_25/WebTech/ue4/1/seite.html | 18 +++ WS24_25/WebTech/ue4/1/syle.css | 0 WS24_25/WebTech/ue4/2/seite.html | 27 +++++ WS24_25/WebTech/ue4/2/style.css | 19 +++ WS24_25/WebTech/ue4/3/seite.html | 33 ++++++ WS24_25/WebTech/ue4/3/style.css | 19 +++ WS24_25/WebTech/ue4/4/seite.html | 43 +++++++ WS24_25/WebTech/ue4/4/style.css | 25 ++++ 10 files changed, 364 insertions(+) create mode 100644 WS24_25/WebTech/ue4/1/seite.html create mode 100644 WS24_25/WebTech/ue4/1/syle.css create mode 100644 WS24_25/WebTech/ue4/2/seite.html create mode 100644 WS24_25/WebTech/ue4/2/style.css create mode 100644 WS24_25/WebTech/ue4/3/seite.html create mode 100644 WS24_25/WebTech/ue4/3/style.css create mode 100644 WS24_25/WebTech/ue4/4/seite.html create mode 100644 WS24_25/WebTech/ue4/4/style.css diff --git a/WS24_25/PyCharm/pythonProject/P4/data.py b/WS24_25/PyCharm/pythonProject/P4/data.py index e69de29..7e6be1f 100644 --- a/WS24_25/PyCharm/pythonProject/P4/data.py +++ b/WS24_25/PyCharm/pythonProject/P4/data.py @@ -0,0 +1,125 @@ +import matplotlib.pyplot as plt +from collections import Counter + +def frequency(input_file: str): + data = [] + frequencies = {} + + # Step 1: Read the CSV file manually + with open(input_file, 'r') as file: + lines = file.readlines() + + # Step 2: Parse the first line to get the headers + headers = lines[0].strip().split(';') + + # Step 3: Parse the subsequent lines to get the data + for line in lines[1:]: + values = line.strip().split(';') + row_dict = {headers[i]: values[i] for i in range(len(headers))} + data.append(row_dict) + + # Step 4: Compute frequencies for each discrete variable + discrete_variables = ['Street', 'Neighborhood', 'Bldg Type', 'House Style', + 'Overall Qual', 'Overall Cond', 'Mo Sold', 'Yr Sold', + 'Sale Type', 'Sale Condition'] + + for var in discrete_variables: + var_values = [row[var] for row in data] + frequencies[var] = Counter(var_values) + + # Step 5: Print the frequency counts to the console + for var, freq_dict in frequencies.items(): + print(f'Frequencies for {var}:') + for value, count in freq_dict.items(): + print(f'{value}: {count}') + print() # Blank line for readability + + + + + +def plot_frequency(input_file: str): + data = [] + frequencies = {} + + # Step 1: Read the CSV file manually + with open(input_file, 'r') as file: + lines = file.readlines() + + # Step 2: Parse the first line to get the headers + headers = lines[0].strip().split(';') + + # Step 3: Parse the subsequent lines to get the data + for line in lines[1:]: + values = line.strip().split(';') + row_dict = {headers[i]: values[i] for i in range(len(headers))} + data.append(row_dict) + + # Step 4: Compute frequencies for each discrete variable + discrete_variables = ['Street', 'Neighborhood', 'Bldg Type', 'House Style', + 'Overall Qual', 'Overall Cond', 'Mo Sold', 'Yr Sold', + 'Sale Type', 'Sale Condition'] + + for var in discrete_variables: + var_values = [row[var] for row in data] + frequencies[var] = Counter(var_values) + + # Step 5: Plot the frequencies using bar charts and pie charts + for var, freq_dict in frequencies.items(): + labels = list(freq_dict.keys()) + counts = list(freq_dict.values()) + + # Bar chart + plt.figure(figsize=(10, 6)) + plt.bar(labels, counts, color='skyblue') + plt.title(f'Bar Chart for {var}') + plt.xlabel(var) + plt.ylabel('Frequency') + plt.xticks(rotation=45, ha='right') + plt.tight_layout() + plt.show() + + # Pie chart + plt.figure(figsize=(8, 8)) + plt.pie(counts, labels=labels, autopct='%1.1f%%', colors=plt.cm.Paired.colors) + plt.title(f'Pie Chart for {var}') + plt.show() + +def plot_histogram(input_file: str): + data = [] + + # Step 1: Read the CSV file manually + with open(input_file, 'r') as file: + lines = file.readlines() + + # Step 2: Parse the first line to get the headers + headers = lines[0].strip().split(';') + + # Step 3: Parse the subsequent lines to get the data + for line in lines[1:]: + values = line.strip().split(';') + row_dict = {headers[i]: values[i] for i in range(len(headers))} + data.append(row_dict) + + # Step 4: Extract the "SalePrice" variable and convert it to numeric values + sale_prices = [int(row['SalePrice']) for row in data] + + # Step 5: Plot the histogram for the "SalePrice" variable + plt.figure(figsize=(10, 6)) + plt.hist(sale_prices, bins=20, color='skyblue', edgecolor='black') + plt.title('Histogram of SalePrice') + plt.xlabel('SalePrice') + plt.ylabel('Frequency') + plt.grid(axis='y', alpha=0.75) + plt.tight_layout() + plt.show() + + +# Example usage +#frequency('AmesHousing.csv') + +# Example usage 2 +#plot_frequency('AmesHousing.csv') + +# Example usage 3 +plot_histogram('AmesHousing.csv') diff --git a/WS24_25/PyCharm/pythonProject/P5/compute.py b/WS24_25/PyCharm/pythonProject/P5/compute.py index e69de29..c51732d 100644 --- a/WS24_25/PyCharm/pythonProject/P5/compute.py +++ b/WS24_25/PyCharm/pythonProject/P5/compute.py @@ -0,0 +1,55 @@ +import matplotlib.pyplot as plt +import pandas as pd + +def int_list(input_file: str, vars: []): + data = [] + with open(input_file, 'r') as file: + lines = file.readlines() + headers = lines[0].strip().split(';') + for line in lines[1:]: + values = line.strip().split(';') + row_dict = {headers[i]: values[i] for i in range(len(headers))} + data.append(row_dict) + discrete_variables = vars + for var in discrete_variables: + var_values = [row[var] for row in data] + int_values = [int(numeric_string) for numeric_string in var_values] + return int_values + +def do_stuff(input_file: str): + int_values = int_list(input_file, ['SalePrice']) + s = pd.Series(int_values) + print(f'Median: {s.median()}') + print(f'Mean: {s.mean()}') + print(f'Quartile: {s.quantile(0.25)} {s.quantile(0.75)}') + print(f'Decile: {s.quantile(0.1)} {s.quantile(0.9)}') + print() + print(f'Range: {s.max() - s.min()}') + print(f'Qartile diff: {s.quantile(0.75) - s.quantile(0.25)}') + print(f'STD: {s.std()}') + +def do_stuff2(input_file: str): + print() + # plt.boxplot(int_list(input_file, ['Year Built'])) + # plt.show() + # plt.boxplot(int_list(input_file, ['Year Remod/Add'])) + # plt.show() + data = [int_list(input_file, ['Year Built']),int_list(input_file, ['Year Remod/Add'])] + fig = plt.figure(figsize=(11, 7)) + + # Creating axes instance + ax = fig.add_axes([0, 0, 1, 1]) + + + # Creating plot + bp = ax.boxplot(data) + + # show plot + plt.show() + + +def test(): + print(int_list("AmesHousing.csv",['SalePrice, Year Built, Year Remod/Add'])) + +do_stuff2("AmesHousing.csv") +#test() diff --git a/WS24_25/WebTech/ue4/1/seite.html b/WS24_25/WebTech/ue4/1/seite.html new file mode 100644 index 0000000..dbec9c9 --- /dev/null +++ b/WS24_25/WebTech/ue4/1/seite.html @@ -0,0 +1,18 @@ + + + + + CSS einbinden + + + + + + +

Erste Überschrift

+

Zweite Überschrift

+ \ No newline at end of file diff --git a/WS24_25/WebTech/ue4/1/syle.css b/WS24_25/WebTech/ue4/1/syle.css new file mode 100644 index 0000000..e69de29 diff --git a/WS24_25/WebTech/ue4/2/seite.html b/WS24_25/WebTech/ue4/2/seite.html new file mode 100644 index 0000000..68a0e39 --- /dev/null +++ b/WS24_25/WebTech/ue4/2/seite.html @@ -0,0 +1,27 @@ + + + + + Übung: CSS lesen + + + + + +

Cascading Stylesheets

+ +
+

Einleitung

+

Mit Cascading Stylesheets (CSS) kann die Darstellung von HTML-Elementen definiert werden.

+
Hinweis: Damit unterstützt CSS die saubere Trennung zwischen Darstellung und + Inhalt/Struktur.
+
+
+

Syntax

+

Eine CSS-Regel besteht aus einem Selektor und einem Deklarationsblock mit 1-n Deklarationen.

+
Hinweis: Deklarationen werden mit Semikolons getrennt.
Weitere Infos im Standard... +
+ + + \ No newline at end of file diff --git a/WS24_25/WebTech/ue4/2/style.css b/WS24_25/WebTech/ue4/2/style.css new file mode 100644 index 0000000..4e23e66 --- /dev/null +++ b/WS24_25/WebTech/ue4/2/style.css @@ -0,0 +1,19 @@ +/* Regel 1 */ +h1 { color:red; } +/* Regel 2 ("text-transform: uppercase" setzt Text in Großbuchstaben) */ +h1, h2 { text-transform: uppercase; } +/* Regel 3 ("text-transform: lowercase" setzt Text in Kleinbuchstaben) */ +h1 h2 { text-transform: lowercase; } +/* Regel 4 */ +.hinweis { background-color: lightblue; } +/* Regel 5 */ +#hinweis { background-color: red; } +/* Regel 6 */ +a[href^="#"] { color: green; } +/* Regel 7 */ +nav a:hover { +background-color: green; +color: white; +} +/* Regel 8 ("font-style: italic" stellt Text kursiv dar) */ +*[id] { font-style: italic; } \ No newline at end of file diff --git a/WS24_25/WebTech/ue4/3/seite.html b/WS24_25/WebTech/ue4/3/seite.html new file mode 100644 index 0000000..8e8e06c --- /dev/null +++ b/WS24_25/WebTech/ue4/3/seite.html @@ -0,0 +1,33 @@ + + + + + CSS-Selektoren + + + + + +

Selectors Level 3

+
+

Abstract

+

+ Selectors are patterns + that match against elements in a tree, and + as such form one of several technologies that + can be used to select nodes in an XML document. +

+
+
+

Selectors

+

+ A Selector represents + a structure. This structure can be used as a + condition (e.g. in a CSS rule) that determines + which elements a selector matches in the + document tree. +

+
+ + + \ No newline at end of file diff --git a/WS24_25/WebTech/ue4/3/style.css b/WS24_25/WebTech/ue4/3/style.css new file mode 100644 index 0000000..9b2f04b --- /dev/null +++ b/WS24_25/WebTech/ue4/3/style.css @@ -0,0 +1,19 @@ +/* Setzt die Farbe des Texts in allen

und

Überschriften auf blau */ +h1 { + color: blue; +} + +/* Setzt den Hintergrund der Elemente mit der Klasse "box" auf orange */ +.box { + background-color: orange; +} + +/* Setzt den Hintergrund des Elements mit der ID "abstract" auf rot */ +#abstract { + background-color: red; +} + +/* Fügt das ™-Zeichen nach jedem Element mit der Klasse "tm" hinzu */ +.tm::after { + content: "™"; +} diff --git a/WS24_25/WebTech/ue4/4/seite.html b/WS24_25/WebTech/ue4/4/seite.html new file mode 100644 index 0000000..15f1513 --- /dev/null +++ b/WS24_25/WebTech/ue4/4/seite.html @@ -0,0 +1,43 @@ + + + + + CSS schreiben + + + + + +

Überschrift

+ + + + + + + + + + + + + + + + + +
#background-color
1.lightblue
2.white
3.lightblue
+
+

Sektionsüberschrift

+

Der erste Absatz.

+

Der zweite Absatz.

+
+

Noch eine Sektionsüberschrift

+

Der dritte Absatz.

+

Der vierte Absatz.

+
+

Der fünfte Absatz.

+
+ + + \ No newline at end of file diff --git a/WS24_25/WebTech/ue4/4/style.css b/WS24_25/WebTech/ue4/4/style.css new file mode 100644 index 0000000..2fd3450 --- /dev/null +++ b/WS24_25/WebTech/ue4/4/style.css @@ -0,0 +1,25 @@ +/* Tabellenkopf in roter Schrift */ +th { + color: red; +} + +/* Abwechselnde Zeilenfarben in der Tabelle: lightblue und white */ +tr:nth-child(even) td { + background-color: lightblue; +} + +tr:nth-child(odd) td { + background-color: white; +} + +/* Hintergrundfarbe für die Absätze 2, 4 und 5 auf gelb setzen */ +/* section > p:nth-of-type(2), +section > section > p:nth-of-type(2), +section > p:nth-of-type(3) { + background-color: yellow; +} */ + +/* Gelber Hintergrund für alle Absätze außer dem ersten in jeder Section */ +section p:not(:first-of-type) { + background-color: yellow; +} \ No newline at end of file