From ede0ee318b874c14899471998ec16c3735187fad Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Mon, 3 Nov 2025 17:08:35 +0100 Subject: [PATCH] Format There really is no hope of making this code even half-way decent without spending the time to rewrite them all properly. Don't want to do any of that --- .clang-format | 276 ++++++++++++++++++++ Animation/Animation_Simple.py | 9 +- Animation/Animation_dot.py | 3 +- Animation/Animation_ship.py | 31 +-- Animation/Erde und Mond.py | 12 +- Animation/Main_hub.py | 352 +++++++++++++++++++++----- Animation/Viereck drehung.py | 15 +- Animation/Wartesymbol.py | 4 +- ArrayOperations/Listenformatierung.py | 2 +- C/Addierer.c | 12 +- C/helloworld.cpp | 11 +- C/histogram.cpp | 32 ++- C/histogram2.cpp | 37 ++- ExamStuff/Aufgabe 7 Prfg Spirale.py | 5 +- ExamStuff/Prüfung Testfile.py | 2 +- ExamStuff/prfg Aufgabe 8 Cross.py | 17 +- IO/Calculator.py | 30 ++- IO/Coinflip.py | 8 +- IO/Eingabe Umwandlung easy.py | 9 +- IO/Frankengewinnspiel.py | 68 ++--- IO/Idioms.py | 22 +- IO/Input + outupt.py | 8 +- IO/Umwandlung Zahlensysteme.py | 8 +- IO/Zeit des Lichts zur Erde.py | 4 +- IO/Zufall Not quite.py | 4 +- README.md | 4 +- RandomOtherStuff/Clock.py | 41 +-- RandomOtherStuff/Test.py | 15 +- RandomOtherStuff/Test_exe.py | 4 +- RandomOtherStuff/Textverbinder.py | 3 +- RandomOtherStuff/While_rekursion.py | 36 +-- RandomOtherStuff/Wortraten spiel.py | 111 +++++--- RandomOtherStuff/timetest.py | 6 +- RandomTurtle/Binäruhr.py | 26 +- RandomTurtle/Digitale Uhr.py | 12 +- RandomTurtle/Dots.py | 11 +- RandomTurtle/Eiskristall-Rekursion.py | 25 +- RandomTurtle/Halbkreis.py | 14 +- RandomTurtle/Huhn.py | 48 ++-- RandomTurtle/Kleeblatt.py | 12 +- RandomTurtle/Kreis_zufall_pre.py | 14 +- RandomTurtle/Progressbar.py | 8 +- RandomTurtle/Striche.py | 3 +- RandomTurtle/Test_while_rekursiojn.py | 10 +- RandomTurtle/TicTacToe.py | 88 ++++--- RandomTurtle/blume.py | 25 +- StringOperations/reverser.py | 4 +- TextAdventure/Adventure_Crash_neu.py | 300 ++++++++++++++-------- 48 files changed, 1219 insertions(+), 582 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..ea63d60 --- /dev/null +++ b/.clang-format @@ -0,0 +1,276 @@ +# ───────────────────────────────────────────────────────────────────── +# ╭─────────────────────────────────────────────────╮ +# │ clang-format config │ +# ╰─────────────────────────────────────────────────╯ +# ───────────────────────────────────────────────────────────────────── +BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: Left +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: Never +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AttributeMacros: + - __capability +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Always +BreakAfterJavaFieldAnnotations: false +BreakAfterReturnType: None +BreakArrays: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Attach +BreakBeforeConceptDeclarations: Always +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +BreakTemplateDeclarations: MultiLine +ColumnLimit: 100 +CommentPragmas: "^ IWYU pragma:" +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: Always +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: ^"(llvm|llvm-c|clang|clang-c)/ + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: ^(<|"(gtest|gmock|isl|json)/) + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: .* + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: (Test)?$ +IncludeIsMainSourceRegex: "" +IndentAccessModifiers: true +IndentCaseBlocks: true +IndentCaseLabels: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: BeforeHash +IndentRequiresClause: true +IndentWidth: 4 +IndentWrappedFunctionNames: true +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: true + AtStartOfFile: true +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: "" +MacroBlockEnd: "" +MainIncludeChar: Quote +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PPIndentWidth: -1 +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +QualifierAlignment: Left +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: true +RemoveParentheses: MultipleParentheses +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Always +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDeclarationName: true + AfterFunctionDefinitionName: true + AfterIfMacros: true + AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Custom +SpacesInParensOptions: + ExceptDoubleParentheses: false + InConditionalStatements: true + InCStyleCasts: false + InEmptyParentheses: false + Other: true +SpacesInSquareBrackets: true +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 4 +TableGenBreakInsideDAGArg: DontBreak +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE diff --git a/Animation/Animation_Simple.py b/Animation/Animation_Simple.py index cdfdda9..3e59a19 100755 --- a/Animation/Animation_Simple.py +++ b/Animation/Animation_Simple.py @@ -2,17 +2,19 @@ import turtle import time -turtle.setup(500,500) +turtle.setup(500, 500) turtle.speed(0) turtle.width(4) + def quadrat(): for i in range(4): turtle.fd(100) turtle.rt(90) - + + turtle.pu() -turtle.setpos(-350,-50) +turtle.setpos(-350, -50) turtle.pd() turtle.ht() @@ -24,4 +26,3 @@ while True: turtle.fd(1) time.sleep(0.01) turtle.update() - diff --git a/Animation/Animation_dot.py b/Animation/Animation_dot.py index 4a1f089..7937d31 100755 --- a/Animation/Animation_dot.py +++ b/Animation/Animation_dot.py @@ -9,7 +9,7 @@ turtle.color("red") turtle.ht() turtle.pu() -turtle.setpos(-700,-700) +turtle.setpos(-700, -700) turtle.lt(45) turtle.pd() @@ -23,4 +23,3 @@ while True: turtle.dot(50) turtle.fd(0.5) turtle.update() - \ No newline at end of file diff --git a/Animation/Animation_ship.py b/Animation/Animation_ship.py index 725b731..ff18d4b 100755 --- a/Animation/Animation_ship.py +++ b/Animation/Animation_ship.py @@ -1,10 +1,11 @@ -from turtle import* +from turtle import * import time import math speed_boat = 0.01 + def ship(): clear() fd(130) @@ -27,6 +28,7 @@ def ship(): lt(50) update() + def ship_2(): clear() fd(130) @@ -35,53 +37,53 @@ def ship_2(): lt(130) fd(240) rt(130) - - def speed_more(): global speed_boat speed_boat += 0.5 - - + + def goleft(): lt(1) bk(1) - - + + def goright(): rt(1) bk(1) - + def speed_less(): global speed_boat speed_boat -= 0.5 - + + def speed_stop(): global speed_boat speed_boat = -1.35 - + + def speed_exelerate_fast(): global speed_boat speed_boat += 2 - + + def speed_reduce_fast(): global speed_boat speed_boat -= 2 + def reset_system(): global speed_boat speed_boat = 0.01 home() pu() - setpos(-350,-50) + setpos(-350, -50) pd() tracer(0) ht() - - reset_system() @@ -98,4 +100,3 @@ while True: onkeypress(goleft, "Left") onkeypress(speed_less, "Down") listen() - diff --git a/Animation/Erde und Mond.py b/Animation/Erde und Mond.py index 3378a8e..8e792fa 100755 --- a/Animation/Erde und Mond.py +++ b/Animation/Erde und Mond.py @@ -1,25 +1,26 @@ -#Import der Module +# Import der Module import turtle import time -#Aufsetzen der Turtle instanzen +# Aufsetzen der Turtle instanzen earth = turtle.Turtle() sun = turtle.Turtle() -#Vorbereiten der Benutzeroberfläche +# Vorbereiten der Benutzeroberfläche turtle.bgcolor("black") turtle.addshape("earth.gif") turtle.addshape("sun.gif") earth.shape("earth.gif") sun.shape("sun.gif") -#Erde umkreist Sonne + +# Erde umkreist Sonne def earth_move(): for i in range(10): earth.fd(1) earth.rt(0.2) time.sleep(0.01) - + turtle.tracer(2) @@ -29,4 +30,3 @@ earth.rt(90) while True: earth_move() - \ No newline at end of file diff --git a/Animation/Main_hub.py b/Animation/Main_hub.py index 17b4b65..c4ed2f0 100755 --- a/Animation/Main_hub.py +++ b/Animation/Main_hub.py @@ -1,16 +1,17 @@ -#Imporieren aller module -from turtle import* +# Imporieren aller module +from turtle import * import random import time import math title("Main Hub") -#Wichtige Vorbereitungen +# Wichtige Vorbereitungen + def hi(): pu() - setpos(-100,0) + setpos(-100, 0) pd() lt(90) fd(200) @@ -21,45 +22,82 @@ def hi(): fd(100) bk(200) pu() - setpos(50,0) + setpos(50, 0) pd() fd(200) + speed(10000) ht() -#Lässt den Benutzer auswählen, ob die Formen zufällig oder in einem Kreis angeordnet, nach Wünschen des Benutzers gezeichnet werden sollen. +# Lässt den Benutzer auswählen, ob die Formen zufällig oder in einem Kreis angeordnet, nach Wünschen des Benutzers gezeichnet werden sollen. print("ready") hi() -program_choice = int(numinput("Welches Program sollte ausgeführt werden?", " 1=Custom, 2=Random, 3=Drunken Man ",1,minval=1)) +program_choice = int( + numinput( + "Welches Program sollte ausgeführt werden?", + " 1=Custom, 2=Random, 3=Drunken Man ", + 1, + minval=1, + ) +) -#Definition des Befehls Vieleck(). Der Grundbaustein des Programms -def vieleck(anzahl_seiten,radius, anzahl_kreis_printed, figuren, kreise, figur_nummer, save_first): +# Definition des Befehls Vieleck(). Der Grundbaustein des Programms +def vieleck( + anzahl_seiten, + radius, + anzahl_kreis_printed, + figuren, + kreise, + figur_nummer, + save_first, +): parts_circle = 1 time_durchgang_start = time.time() for i in range(anzahl_seiten): - fd(radius/anzahl_seiten) - rt(360/anzahl_seiten) + fd(radius / anzahl_seiten) + rt(360 / anzahl_seiten) parts_circle += 1 - if parts_circle / anzahl_seiten * 100 >= 50 and parts_circle / anzahl_seiten * 100 < 50.1: - print(" Circle:",parts_circle / anzahl_seiten * 100, "%") + if ( + parts_circle / anzahl_seiten * 100 >= 50 + and parts_circle / anzahl_seiten * 100 < 50.1 + ): + print(" Circle:", parts_circle / anzahl_seiten * 100, "%") time_durchgang_end = time.time() - exact_timecalculation(time_durchgang_start, time_durchgang_end, anzahl_seiten, radius, anzahl_kreis_printed, figuren, kreise, figur_nummer, save_first) + exact_timecalculation( + time_durchgang_start, + time_durchgang_end, + anzahl_seiten, + radius, + anzahl_kreis_printed, + figuren, + kreise, + figur_nummer, + save_first, + ) -#Definition des Befehls, der mit beendigung des Auswahlverfahrens aufgerufen wird. Verwaltet die wichtigsten feautures -def figur(seite,radiusin,anzahlkr,anzahl_figuren,erh_input): +# Definition des Befehls, der mit beendigung des Auswahlverfahrens aufgerufen wird. Verwaltet die wichtigsten feautures +def figur(seite, radiusin, anzahlkr, anzahl_figuren, erh_input): figur_number = 1 first_time = 1 print("Globally: 0 % done") for i in range(anzahl_figuren): change_color(figur_number) - print("drawing figure number",figur_number) + print("drawing figure number", figur_number) anzahl_kr_printed = 0 for i in range(anzahlkr): - vieleck(seite,radiusin, anzahl_kr_printed, anzahl_figuren, anzahlkr, figur_number, first_time) - rt(360/anzahlkr) + vieleck( + seite, + radiusin, + anzahl_kr_printed, + anzahl_figuren, + anzahlkr, + figur_number, + first_time, + ) + rt(360 / anzahlkr) anzahl_kr_printed += 1 print(anzahl_kr_printed / anzahlkr * 100, "%") radiusin += erh_input @@ -67,12 +105,34 @@ def figur(seite,radiusin,anzahlkr,anzahl_figuren,erh_input): print("done") print("Globally:", (figur_number - 1) / anzahl_figuren * 100, "% done") -#Berechnet, sobald das Programm begonnen hatte zu zeichnen, wie lange der Vorgang noch dauern wird. -def exact_timecalculation(time_durchgang_end_1, time_durchgang_start_1, seitenzahl, radiusinput, anzahl_kreise_printed, figuren, kreise, figur_number, save_1): + +# Berechnet, sobald das Programm begonnen hatte zu zeichnen, wie lange der Vorgang noch dauern wird. +def exact_timecalculation( + time_durchgang_end_1, + time_durchgang_start_1, + seitenzahl, + radiusinput, + anzahl_kreise_printed, + figuren, + kreise, + figur_number, + save_1, +): print("Time per shape", time_durchgang_start_1 - time_durchgang_end_1) - remaining_circles = (figuren * kreise) - ((anzahl_kreise_printed + ((figur_number - 1) * kreise))) - remaining_time = remaining_circles * ((time_durchgang_end_1 - time_durchgang_start_1) * -1) - print(((anzahl_kreise_printed + ((figur_number - 1) * kreise))), "/", (kreise * figuren), "shapes got already printed.", remaining_circles, "remaining") + remaining_circles = (figuren * kreise) - ( + (anzahl_kreise_printed + ((figur_number - 1) * kreise)) + ) + remaining_time = remaining_circles * ( + (time_durchgang_end_1 - time_durchgang_start_1) * -1 + ) + print( + ((anzahl_kreise_printed + ((figur_number - 1) * kreise))), + "/", + (kreise * figuren), + "shapes got already printed.", + remaining_circles, + "remaining", + ) print("ETA:", remaining_time, "seconds or", remaining_time / 60, "minutes") if save_1 > 1: remaining_time = save_time_end @@ -80,7 +140,8 @@ def exact_timecalculation(time_durchgang_end_1, time_durchgang_start_1, seitenza else: save_1 = 0 -#Wechselt die Farbe + +# Wechselt die Farbe def change_color(anz_figuren): if anz_figuren >= 1 and anz_figuren < 2: color("red") @@ -97,20 +158,25 @@ def change_color(anz_figuren): color("black") -#Führt den zufälligen Teil des Programms aus +# Führt den zufälligen Teil des Programms aus def vieleck_random_randomize(): amount_circles_drawn = 0 pu() amount_circles = random.randint(25, 75) - print(amount_circles, "shapes need to be printed. Esitmated time:", amount_circles * 0.35, "seconds") + print( + amount_circles, + "shapes need to be printed. Esitmated time:", + amount_circles * 0.35, + "seconds", + ) print("0 / 0 or 0 % done") for i in range(amount_circles): - color(random.random(),random.random(),random.random()) + color(random.random(), random.random(), random.random()) size = random.randint(50, 250) width(random.randint(2, 10)) ecken = random.randint(3, 20) - setpos(random.randint(-300,300), random.randint(-300,300)) - fuellen = random.randint(0,1) + setpos(random.randint(-300, 300), random.randint(-300, 300)) + fuellen = random.randint(0, 1) pd() if fuellen >= 1: begin_fill() @@ -124,17 +190,32 @@ def vieleck_random_randomize(): rt(360 / ecken) amount_circles_drawn += 1 pu() - print(amount_circles_drawn, "/", amount_circles, "or", amount_circles_drawn / amount_circles * 100, "% drawn.") + print( + amount_circles_drawn, + "/", + amount_circles, + "or", + amount_circles_drawn / amount_circles * 100, + "% drawn.", + ) print("100 % done. Process ended with a 0") - -#Definition des Betrunkenen Mannes?? -def drunken_man_walk_show(schritte,distanz): + + +# Definition des Betrunkenen Mannes?? +def drunken_man_walk_show(schritte, distanz): for i in range(schritte): fd(distanz) setheading(random.randint(0, 360)) - -def drunken_man_walk_calculate(anzahl_tests,anzahl_figuren_test,add,anzahl_tests_pro,ausgabe): - print("started. Going to make the test", anzahl_tests, "times to get a result which is as acurate as possible") + + +def drunken_man_walk_calculate( + anzahl_tests, anzahl_figuren_test, add, anzahl_tests_pro, ausgabe +): + print( + "started. Going to make the test", + anzahl_tests, + "times to get a result which is as acurate as possible", + ) schritte = 100 schritte_begin = schritte distanz = 20 @@ -144,9 +225,16 @@ def drunken_man_walk_calculate(anzahl_tests,anzahl_figuren_test,add,anzahl_tests for i in range(anzahl_figuren_test): amount_atemps_per = 0 for i in range(anzahl_tests): - print("Collecting data for", schritte,"steps, collecting data for try number", amount_atemps_per + 1, "/", anzahl_tests) + print( + "Collecting data for", + schritte, + "steps, collecting data for try number", + amount_atemps_per + 1, + "/", + anzahl_tests, + ) for i in range(anzahl_tests_pro): - drunken_man_walk_show(schritte,distanz) + drunken_man_walk_show(schritte, distanz) x = xcor() y = ycor() d = math.sqrt(x**2 + y**2) @@ -155,12 +243,24 @@ def drunken_man_walk_calculate(anzahl_tests,anzahl_figuren_test,add,anzahl_tests home() pd() summe_calc = summe / anzahl_tests_pro - print("Average dislocation of 0.0 is:", summe_calc,"pixels, with a amount of steps of", schritte,".") + print( + "Average dislocation of 0.0 is:", + summe_calc, + "pixels, with a amount of steps of", + schritte, + ".", + ) summe_second += summe_calc reset() summe = 0 amount_atemps_per += 1 - print("TOTAL Average dislocation of 0.0 is:", summe_second / anzahl_tests, "pixels with", schritte, "steps") + print( + "TOTAL Average dislocation of 0.0 is:", + summe_second / anzahl_tests, + "pixels with", + schritte, + "steps", + ) print("Next size getting executed") result = summe_second / anzahl_tests l.append(result) @@ -169,7 +269,7 @@ def drunken_man_walk_calculate(anzahl_tests,anzahl_figuren_test,add,anzahl_tests l.remove(1) l.reverse() print("\n\n\n") - print("entire list:",l) + print("entire list:", l) print("\n_________________________ \n\n\n") if ausgabe == 1: for i in range(anzahl_figuren_test): @@ -183,34 +283,94 @@ def drunken_man_walk_calculate(anzahl_tests,anzahl_figuren_test,add,anzahl_tests show = l.pop() print(schritte_begin, " | ", show) schritte_begin += add - - - - -#Wird ausgeführt, wenn der vom Benutzer einstellbare Modus ausgewählt wird. + + +# Wird ausgeführt, wenn der vom Benutzer einstellbare Modus ausgewählt wird. if program_choice >= 1 and program_choice < 2: title("Custom Design") reset() ht() speed(10000) print("Custom Design") - seiteninput = int(numinput("Wie viele Seiten?", " Gerade Zahl von 3-unendlich ",10,minval=3)) - radiusinput = int(numinput("Wie gross soll der Radius sein?", " Gerade Zahl von 50-unendlich ",50,minval=50)) - anzahlkrinput = int(numinput("Wie viele Kreise sollen gezeichnet werden??", " Gerade Zahl von 1-unendlich ",5,minval=1)) - figureninput = int(numinput("Wie viele Figuren sollen gezeichnet werden?", " Gerade Zahl von 1-unendlich ",5,minval=1)) - erhinput = int(numinput("Um wieviel soll sich sich der Radius der Kreise erhöhen?", " Gerade Zahl von 20-unendlich ",50,minval=20)) - verzoegerung = int(numinput("Wie schnell soll die Animation laufen?", " Gerade Zahl von 1-unendlich, umso höher, desto schneller ",50,minval=0)) + seiteninput = int( + numinput( + "Wie viele Seiten?", " Gerade Zahl von 3-unendlich ", 10, minval=3 + ) + ) + radiusinput = int( + numinput( + "Wie gross soll der Radius sein?", + " Gerade Zahl von 50-unendlich ", + 50, + minval=50, + ) + ) + anzahlkrinput = int( + numinput( + "Wie viele Kreise sollen gezeichnet werden??", + " Gerade Zahl von 1-unendlich ", + 5, + minval=1, + ) + ) + figureninput = int( + numinput( + "Wie viele Figuren sollen gezeichnet werden?", + " Gerade Zahl von 1-unendlich ", + 5, + minval=1, + ) + ) + erhinput = int( + numinput( + "Um wieviel soll sich sich der Radius der Kreise erhöhen?", + " Gerade Zahl von 20-unendlich ", + 50, + minval=20, + ) + ) + verzoegerung = int( + numinput( + "Wie schnell soll die Animation laufen?", + " Gerade Zahl von 1-unendlich, umso höher, desto schneller ", + 50, + minval=0, + ) + ) print("starting process...") tracer(verzoegerung) - print(anzahlkrinput * figureninput, "circles need to be printed. Estimated time until completion:", (anzahlkrinput * figureninput * (seiteninput * 0.0330383)), "seconds or", (anzahlkrinput * figureninput * (seiteninput * 0.0330383)) / 60, "minutes") + print( + anzahlkrinput * figureninput, + "circles need to be printed. Estimated time until completion:", + (anzahlkrinput * figureninput * (seiteninput * 0.0330383)), + "seconds or", + (anzahlkrinput * figureninput * (seiteninput * 0.0330383)) / 60, + "minutes", + ) time.sleep(2) draw_time_start = time.time() - figur(seiteninput,radiusinput,anzahlkrinput,figureninput,erhinput) + figur(seiteninput, radiusinput, anzahlkrinput, figureninput, erhinput) draw_time_end = time.time() - draw_time = (draw_time_end - draw_time_start) - (anzahlkrinput * figureninput * (seiteninput * 0.0330383)) - print("Drawing of", anzahlkrinput * figureninput, "shapes has taken", draw_time_end - draw_time_start , "seconds or", (draw_time_end - draw_time_start) / 60, "minutes, estimated:", (anzahlkrinput * figureninput * (seiteninput * 0.0330383)), "seconds, which means a diffrence of", draw_time, "seconds or missed by", draw_time * 100, "%") + draw_time = (draw_time_end - draw_time_start) - ( + anzahlkrinput * figureninput * (seiteninput * 0.0330383) + ) + print( + "Drawing of", + anzahlkrinput * figureninput, + "shapes has taken", + draw_time_end - draw_time_start, + "seconds or", + (draw_time_end - draw_time_start) / 60, + "minutes, estimated:", + (anzahlkrinput * figureninput * (seiteninput * 0.0330383)), + "seconds, which means a diffrence of", + draw_time, + "seconds or missed by", + draw_time * 100, + "%", + ) print("Click to exit") - + else: if program_choice >= 2 and program_choice < 3: @@ -222,7 +382,7 @@ else: draw_time_start = time.time() vieleck_random_randomize() draw_time_end = time.time() - print("Drawing has taken", draw_time_end - draw_time_start , "seconds") + print("Drawing has taken", draw_time_end - draw_time_start, "seconds") print("Click to exit") else: if program_choice >= 3 and program_choice < 4: @@ -231,22 +391,74 @@ else: ht() speed(0) print("Drunken Man's Walk") - easy_difficult = int(numinput("Soll es gezeigt oder eine Tabelle erstellt werden?", " 1=Normal, 2=Tabelle ",1,minval=1)) + easy_difficult = int( + numinput( + "Soll es gezeigt oder eine Tabelle erstellt werden?", + " 1=Normal, 2=Tabelle ", + 1, + minval=1, + ) + ) if easy_difficult == 1: title("Drunken Man's Walk: standard") - drunken_man_walk_show(100,20) + drunken_man_walk_show(100, 20) else: title("Drunken Man's Walk: List") - tests_total = int(numinput("Wie viele unterschiedliche Längen sollten getestet werden?", " Dauer erhöht sich extrem, Genauigkeit genauso ",10,minval=1)) - tests_per = int(numinput("Wieviele Tests sollten pro Länge durchgeführt werden?", " Dauer erhöht sich extrem, Genauigkeit genauso ",10,minval=1)) - addition = int(numinput("Um wieviel soll die Schrittzahl vergrössert werden?", " Dauer erhöht sich unbedeutend, abhängig von Tests ", 100, minval=1)) - executes_per = int(numinput("Wie viele Spuren sollen gezeichnet werden?", " Dauer erhöht sich ziemlich, Genauigkeit genauso ",1000,minval=1)) - tracerdelay = int(numinput("Alle wie viele Striche soll aktualisiert werden?", " umso höher, desto schneller ",10000,minval=1)) - output = int(numinput("Wie soll die Liste ausgegeben werden?", " 1 = Liste, 2 = Tabelle ",1,minval=1, maxval=2)) + tests_total = int( + numinput( + "Wie viele unterschiedliche Längen sollten getestet werden?", + " Dauer erhöht sich extrem, Genauigkeit genauso ", + 10, + minval=1, + ) + ) + tests_per = int( + numinput( + "Wieviele Tests sollten pro Länge durchgeführt werden?", + " Dauer erhöht sich extrem, Genauigkeit genauso ", + 10, + minval=1, + ) + ) + addition = int( + numinput( + "Um wieviel soll die Schrittzahl vergrössert werden?", + " Dauer erhöht sich unbedeutend, abhängig von Tests ", + 100, + minval=1, + ) + ) + executes_per = int( + numinput( + "Wie viele Spuren sollen gezeichnet werden?", + " Dauer erhöht sich ziemlich, Genauigkeit genauso ", + 1000, + minval=1, + ) + ) + tracerdelay = int( + numinput( + "Alle wie viele Striche soll aktualisiert werden?", + " umso höher, desto schneller ", + 10000, + minval=1, + ) + ) + output = int( + numinput( + "Wie soll die Liste ausgegeben werden?", + " 1 = Liste, 2 = Tabelle ", + 1, + minval=1, + maxval=2, + ) + ) tracer(tracerdelay) - drunken_man_walk_calculate(tests_per,tests_total,addition,executes_per,output) - + drunken_man_walk_calculate( + tests_per, tests_total, addition, executes_per, output + ) + else: print("wrong") update() -exitonclick() \ No newline at end of file +exitonclick() diff --git a/Animation/Viereck drehung.py b/Animation/Viereck drehung.py index cd7066e..0132a65 100755 --- a/Animation/Viereck drehung.py +++ b/Animation/Viereck drehung.py @@ -1,13 +1,15 @@ -from turtle import* +from turtle import * import time -#tracer(1) -#ht() + +# tracer(1) +# ht() + def viereck(): for i in range(1000000000000000): clear() pu() - setpos(0,0) + setpos(0, 0) rt(10) fd(50) rt(90) @@ -17,5 +19,6 @@ def viereck(): rt(90) fd(50) time.sleep(0.05) - -viereck() \ No newline at end of file + + +viereck() diff --git a/Animation/Wartesymbol.py b/Animation/Wartesymbol.py index d796e37..08271d1 100755 --- a/Animation/Wartesymbol.py +++ b/Animation/Wartesymbol.py @@ -19,6 +19,6 @@ while True: else: print("\t/", end="\r") time.sleep(0.5) - os.system( 'clear' ) + os.system("clear") strich += 1 - strich = 1 \ No newline at end of file + strich = 1 diff --git a/ArrayOperations/Listenformatierung.py b/ArrayOperations/Listenformatierung.py index 04c7939..a490545 100755 --- a/ArrayOperations/Listenformatierung.py +++ b/ArrayOperations/Listenformatierung.py @@ -1,3 +1,3 @@ inventory = ["Test", "Test2"] for item in inventory: - print("*"+item) \ No newline at end of file + print("*" + item) diff --git a/C/Addierer.c b/C/Addierer.c index d6c76bc..204c1df 100755 --- a/C/Addierer.c +++ b/C/Addierer.c @@ -1,10 +1,12 @@ +#include + int main() { int summe = 0; - for(int i=0; i<5; i++) { - printf("Gib die Zahl ein:") + for ( int i = 0; i < 5; i++ ) { + printf( "Gib die Zahl ein:" ); int zahl; - scanf("%d", &zahl); + scanf( "%d", &zahl ); summe = summe + zahl; } - printf("Summe: %d\n", summe); -} \ No newline at end of file + printf( "Summe: %d\n", summe ); +} diff --git a/C/helloworld.cpp b/C/helloworld.cpp index 9ec0f09..763a9c0 100755 --- a/C/helloworld.cpp +++ b/C/helloworld.cpp @@ -1,16 +1,13 @@ #include -#include #include +#include using namespace std; -int main() -{ - vector msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"}; +int main() { + vector msg { "Hello", "C++", "World", "from", "VS Code", "and the C++ extension!" }; - for (const string& word : msg) - { + for ( const string &word : msg ) cout << word << " "; - } cout << endl; } diff --git a/C/histogram.cpp b/C/histogram.cpp index db09c6d..df82f52 100755 --- a/C/histogram.cpp +++ b/C/histogram.cpp @@ -1,30 +1,28 @@ #include -int main() -{ +int main() { // Deklaration der Variablen - int hist[26] = {}; + int hist[ 26 ] = {}; int i, k, c, count; int num = 0; - + // Zeichen bis EOF einlesen (nur a-z werden berücksichtigt) // EOF wird im Terminal mit CTRL-D eingegeben! - while ((c = getchar()) != EOF) { - if ((c>96) && (c<123)) { + while ( ( c = getchar() ) != EOF ) { + if ( ( c > 96 ) && ( c < 123 ) ) { // Zähler für diesen Buchstaben erhöhen - hist[c-97]++; + hist[ c - 97 ]++; num++; } } - - // Histogramm ausgeben - printf("\n"); - for (i=0; i<26; i++) { - count = hist[i]; - if (count > 0) { - printf("%c : %f\n",i+97, (count/(float)num)*100); - } + + // Histogramm ausgeben + printf( "\n" ); + for ( i = 0; i < 26; i++ ) { + count = hist[ i ]; + if ( count > 0 ) + printf( "%c : %f\n", i + 97, ( count / (float) num ) * 100 ); } - + return 0; -} \ No newline at end of file +} diff --git a/C/histogram2.cpp b/C/histogram2.cpp index 8ae51b4..f1afa23 100755 --- a/C/histogram2.cpp +++ b/C/histogram2.cpp @@ -1,31 +1,30 @@ #include -int main() -{ +int main() { // Deklaration der Variablen - int hist[26] = {}; + int hist[ 26 ] = {}; int i, k, c, count; - + // Zeichen bis EOF einlesen (nur a-z werden berücksichtigt) // EOF wird im Terminal mit CTRL-D eingegeben! - while ((c = getchar()) != EOF) { - if ((c>96) && (c<123)) { + while ( ( c = getchar() ) != EOF ) { + if ( ( c > 96 ) && ( c < 123 ) ) { // Zähler für diesen Buchstaben erhöhen - hist[c-97]++; + hist[ c - 97 ]++; } } - - // Histogramm ausgeben - printf("\n"); - for (i=0; i<26; i++) { - count = hist[i]; - if (count > 0) { - printf("%c : ",i+97); - for (k=0; k 0 ) { + printf( "%c : ", i + 97 ); + for ( k = 0; k < count; k++ ) + printf( "*" ); + printf( "\n" ); } } - + return 0; -} \ No newline at end of file +} diff --git a/ExamStuff/Aufgabe 7 Prfg Spirale.py b/ExamStuff/Aufgabe 7 Prfg Spirale.py index 82414c3..b5ebf62 100755 --- a/ExamStuff/Aufgabe 7 Prfg Spirale.py +++ b/ExamStuff/Aufgabe 7 Prfg Spirale.py @@ -1,4 +1,5 @@ -from turtle import* +from turtle import * + shape("turtle") color("blue") @@ -16,4 +17,4 @@ for i in range(2): rt(20) stamp() distance += 2 - print(orientation) \ No newline at end of file + print(orientation) diff --git a/ExamStuff/Prüfung Testfile.py b/ExamStuff/Prüfung Testfile.py index 5be3e20..1ab64af 100755 --- a/ExamStuff/Prüfung Testfile.py +++ b/ExamStuff/Prüfung Testfile.py @@ -3,4 +3,4 @@ minutes = seconds // 60 seconds_rest = minutes % 60 hours = minutes // 60 minutes_rest = minutes % 60 -print(hours, minutes_rest, seconds_rest) \ No newline at end of file +print(hours, minutes_rest, seconds_rest) diff --git a/ExamStuff/prfg Aufgabe 8 Cross.py b/ExamStuff/prfg Aufgabe 8 Cross.py index 52f979b..ea29cee 100755 --- a/ExamStuff/prfg Aufgabe 8 Cross.py +++ b/ExamStuff/prfg Aufgabe 8 Cross.py @@ -1,11 +1,18 @@ -from turtle import* +from turtle import * import math rt(45) go = 1 color("red") -distance_in = int(numinput("Wie weit darf sich die Turtle vom Mittelpunkt entfernen??", " Gerade Zahl von 1-unendlich ",300,minval=1)) +distance_in = int( + numinput( + "Wie weit darf sich die Turtle vom Mittelpunkt entfernen??", + " Gerade Zahl von 1-unendlich ", + 300, + minval=1, + ) +) for i in range(4): go = 1 @@ -20,9 +27,9 @@ for i in range(4): else: if distance <= -distance_in: go = 0 - + else: go = 1 - + bk(distance_in) - rt(90) \ No newline at end of file + rt(90) diff --git a/IO/Calculator.py b/IO/Calculator.py index cceefac..433659c 100755 --- a/IO/Calculator.py +++ b/IO/Calculator.py @@ -1,10 +1,11 @@ -#Library import +# Library import import math -#Startup +# Startup out = 0 -print(""" +print( + """ ,--------. ,--. ,--. '--. .--',--,--. ,---. ,---.| ,---. ,---. ,--,--, ,--.--. ,---. ,---.| ,---. ,--,--, ,---. ,--.--. @@ -17,17 +18,18 @@ print(""" Build 1 28.05.21 - """) + """ +) -#Userinput +# Userinput i = input("Rechung eingeben: ") -#Separation +# Separation l = i.split() x1 = l.pop(0) x = int(x1) -#Calculation +# Calculation if len(l) == 1: print("Wrong entry, retry, use spaces in between numbers and operands.") else: @@ -45,22 +47,22 @@ else: elif "/" or ":" in l: out = x / y - + elif "^" or "**" in l: - out = x ** y - + out = x**y + elif "<>" in l: math.sqrt(x) else: print("unkown operand, retry") - + if len(l) != 0: operand = l.pop(0) x = out else: print("The result is:") - -#Output -print(out) \ No newline at end of file + +# Output +print(out) diff --git a/IO/Coinflip.py b/IO/Coinflip.py index 38f96d0..abff6e1 100755 --- a/IO/Coinflip.py +++ b/IO/Coinflip.py @@ -11,8 +11,8 @@ go = 1 while go == 1: - zahl = random.randint(1,2) - + zahl = random.randint(1, 2) + if st1 == st2: if st2a == st3: go = 0 @@ -26,7 +26,7 @@ while go == 1: print("K") else: print("N") - + else: anzahl += 1 st3 = st2 @@ -37,4 +37,4 @@ while go == 1: print("K") else: print("N") -print("Took", anzahl, "tries") \ No newline at end of file +print("Took", anzahl, "tries") diff --git a/IO/Eingabe Umwandlung easy.py b/IO/Eingabe Umwandlung easy.py index 7505d9c..100be98 100755 --- a/IO/Eingabe Umwandlung easy.py +++ b/IO/Eingabe Umwandlung easy.py @@ -5,17 +5,14 @@ system = int(input("Zahlensystem: ")) if system == 2: y = bin(eingabe) print("Resultat:", y) - + elif system == 16: y = hex(eingabe) print("Resultat:", y) - + elif system == 8: y = oct(eingabe) print("Resultat:", y) - + else: print("wrong") - - - diff --git a/IO/Frankengewinnspiel.py b/IO/Frankengewinnspiel.py index fc06504..30a478a 100755 --- a/IO/Frankengewinnspiel.py +++ b/IO/Frankengewinnspiel.py @@ -1,26 +1,28 @@ -#FRANKENGEWINNSPIEL -#------------------------------------------------- +# FRANKENGEWINNSPIEL +# ------------------------------------------------- -#Import of Modules and setup variables -#import turtle +# Import of Modules and setup variables +# import turtle -#Definition of Turtle instances +# Definition of Turtle instances - -#Preparations, so setup of the game output window and choice of diffrent gamemodes +# Preparations, so setup of the game output window and choice of diffrent gamemodes programchoice = 200 while (programchoice < 1) or (programchoice > 99): - programchoice = programchoice = int(input("Welcher Modus? 1 = Normales Spiel, 2 = Liste aller Gewinne mit angabe des Höchsten, 3 = angabe des höchsten Gewinnes, 4 = andgabe des höchsten erreichbaren Feldes: ")) + programchoice = programchoice = int( + input( + "Welcher Modus? 1 = Normales Spiel, 2 = Liste aller Gewinne mit angabe des Höchsten, 3 = angabe des höchsten Gewinnes, 4 = andgabe des höchsten erreichbaren Feldes: " + ) + ) if (programchoice < 1) or (programchoice > 99): print("Number not within designated range. Try again") print("Willkommen") - -#MAINGAME -#----------------------- +# MAINGAME +# ----------------------- def playgame(field): global winning winning = 0 @@ -32,10 +34,11 @@ def playgame(field): else: next = field / 2 winning += next - field = next - -#GAMEMODE 1 -#------------------------- + field = next + + +# GAMEMODE 1 +# ------------------------- def gamemode1(): s = 200 while (s < 1) or (s > 99): @@ -49,17 +52,18 @@ def gamemode1(): print("Your winnings:", winning) -#GAMEMODE 2 -#-------------------------- +# GAMEMODE 2 +# -------------------------- def gamemode2(): fieldascending = 1 for i in range(99): playgame(fieldascending) - print("You win",winning,"with startpoint",fieldascending) + print("You win", winning, "with startpoint", fieldascending) fieldascending += 1 - -#GAMEMODE 3 -#-------------------------- + + +# GAMEMODE 3 +# -------------------------- def gamemode3(): fieldascending = 1 global winning @@ -71,10 +75,11 @@ def gamemode3(): currentwinning = winning currentfield = fieldascending fieldascending += 1 - print("Biggest possible winning is", currentwinning,"on field", currentfield) - -#GAMEMODE 4 -#----------------------------- + print("Biggest possible winning is", currentwinning, "on field", currentfield) + + +# GAMEMODE 4 +# ----------------------------- def gamemode4(): fieldascending = 1 global winning @@ -94,18 +99,19 @@ def gamemode4(): next = field / 2 field = next fieldascending += 1 - print("Biggest possible field is", biggestfield,"on startfield", currentfield) + print("Biggest possible field is", biggestfield, "on startfield", currentfield) -#RUN -#------------------------- + +# RUN +# ------------------------- if programchoice == 1: gamemode1() - + elif programchoice == 2: gamemode2() - + elif programchoice == 3: gamemode3() - + else: gamemode4() diff --git a/IO/Idioms.py b/IO/Idioms.py index df308e5..0b1b959 100755 --- a/IO/Idioms.py +++ b/IO/Idioms.py @@ -1,7 +1,7 @@ -#Idioms +# Idioms import random -#Check user input +# Check user input s = 200 while (s < 1) or (s > 99): @@ -12,28 +12,28 @@ while (s < 1) or (s > 99): print("Ok") -#Find biggest number +# Find biggest number output = 0 for i in range(100): n = random.randint(1, 1000) if n > output: output = n - + print(output) -#Summ up -summ = 0 +# Sum up +sum = 0 for i in range(100): n = random.randint(1, 1000) - summ += n - -print(summ) + sum += n + +print(sum) -#even or uneven? +# even or uneven? z = random.randint(1, 1000) if (z % 2) == 1: print("odd") else: - print("even") \ No newline at end of file + print("even") diff --git a/IO/Input + outupt.py b/IO/Input + outupt.py index d020f75..92df660 100755 --- a/IO/Input + outupt.py +++ b/IO/Input + outupt.py @@ -1,13 +1,9 @@ import math -#Eingabe +# Eingabe s = int(input("Seitenlänge: ")) -#Verarbeitung +# Verarbeitung for i in range(s): print(s * "* ") - - - - diff --git a/IO/Umwandlung Zahlensysteme.py b/IO/Umwandlung Zahlensysteme.py index 8531770..41dc0be 100755 --- a/IO/Umwandlung Zahlensysteme.py +++ b/IO/Umwandlung Zahlensysteme.py @@ -8,8 +8,8 @@ stelle = 1 while y > 0: y = y // system outadd = y % system - out += (outadd * stelle) + out += outadd * stelle stelle *= 10 - - -print(out) \ No newline at end of file + + +print(out) diff --git a/IO/Zeit des Lichts zur Erde.py b/IO/Zeit des Lichts zur Erde.py index 0c3d30b..c3bddd1 100755 --- a/IO/Zeit des Lichts zur Erde.py +++ b/IO/Zeit des Lichts zur Erde.py @@ -1,3 +1,3 @@ -c = (1.4962375e8 / 2.99792458e5)/60 +c = (1.4962375e8 / 2.99792458e5) / 60 -print(c) \ No newline at end of file +print(c) diff --git a/IO/Zufall Not quite.py b/IO/Zufall Not quite.py index 366c6fc..f7dadcd 100755 --- a/IO/Zufall Not quite.py +++ b/IO/Zufall Not quite.py @@ -6,5 +6,5 @@ m = 32 x = int(time.time()) % m for i in range(10): - x = (a*x + c) % m - print(x) \ No newline at end of file + x = (a * x + c) % m + print(x) diff --git a/README.md b/README.md index dd2534d..89e32cf 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,6 @@ All project files of GLF Informatik at KSWO (bad, but mostly working code) # Contents -This repo contains all the code that was used in the Computer Science basics course @KSWO. Use at your own risk :)... I wasn't even remotely at the level I am at now when it comes to coding! \ No newline at end of file +This repo contains all the code that was used in the Computer Science basics course @KSWO. Use at your own risk :)... I wasn't even remotely at the level I am at now when it comes to coding! + +***Please!!!*** Do as as I say (do not put any umlaut or any other kind of non-ascii BS or spaces into filenames), not as I did diff --git a/RandomOtherStuff/Clock.py b/RandomOtherStuff/Clock.py index 848e251..922b531 100755 --- a/RandomOtherStuff/Clock.py +++ b/RandomOtherStuff/Clock.py @@ -1,9 +1,9 @@ -#Import der Module +# Import der Module import turtle import time import datetime -#Setup der einzelnen Turtle instanzen. +# Setup der einzelnen Turtle instanzen. turtle.tracer(0) sekundenzeiger = turtle.Turtle() minutenzeiger = turtle.Turtle() @@ -13,7 +13,8 @@ sekundenzeiger.color("red") minutenzeiger.color("blue") stundenzeiger.width(2) -#Definition des Ziffernblattes + +# Definition des Ziffernblattes def clock_bg(): uhr.pd() uhr.dot(10) @@ -32,7 +33,8 @@ def clock_bg(): uhr.rt(0.5) uhr.pu() -#Funktion des Sekundenzeigers + +# Funktion des Sekundenzeigers def sekzeiger(): sekundenzeiger.pu() sekundenzeiger.home() @@ -42,21 +44,21 @@ def sekzeiger(): sekundenzeiger.lt(90) sekundenzeiger.bk(40) sekundenzeiger.fd(220) - - -#Funktion des Minutenzeigers + + +# Funktion des Minutenzeigers def minzeiger(): minutenzeiger.pu() minutenzeiger.home() minutenzeiger.pd() minuten = datetime.datetime.now().minute - minutenzeiger.lt((minuten * 6) *(-1)) + minutenzeiger.lt((minuten * 6) * (-1)) minutenzeiger.lt(90) minutenzeiger.bk(30) minutenzeiger.fd(215) - - -#Funktion des Stundenzeigers + + +# Funktion des Stundenzeigers def stzeiger(): stundenzeiger.pu() stundenzeiger.home() @@ -77,7 +79,8 @@ def stzeiger(): stundenzeiger.bk(15) stundenzeiger.fd(135) -#Ganze Uhr + +# Ganze Uhr def clock(): sekundenzeiger.clear() minutenzeiger.clear() @@ -93,13 +96,14 @@ def clock(): stzeiger() turtle.update() -#Stoppen der Uhr + +# Stoppen der Uhr def stop(): global run run = 0 -#Hauptschleife +# Hauptschleife def settings(): print("Welcome!") global run @@ -115,11 +119,10 @@ def settings(): print("stopped, click to exit") turtle.exitonclick() print("process ended") - - - -#Startzeit einblenden + + +# Startzeit einblenden print(time.strftime("%H:%M:%S")) -#Ausführen des Programms +# Ausführen des Programms settings() diff --git a/RandomOtherStuff/Test.py b/RandomOtherStuff/Test.py index 2aa1dfc..aeb6973 100755 --- a/RandomOtherStuff/Test.py +++ b/RandomOtherStuff/Test.py @@ -1,14 +1,16 @@ -from turtle import* +from turtle import * addshape("testimage.gif") -screensize(1080,1920) +screensize(1080, 1920) shape("testimage.gif") color("red") speed(1000) + + def walk(): - w=10 - length=100 + w = 10 + length = 100 for i in range(4): w += 10 width(w) @@ -16,6 +18,7 @@ def walk(): length += 40 fd(length) rt(90) - + + walk() -exitonclick() \ No newline at end of file +exitonclick() diff --git a/RandomOtherStuff/Test_exe.py b/RandomOtherStuff/Test_exe.py index 62c8725..fbdd8cf 100755 --- a/RandomOtherStuff/Test_exe.py +++ b/RandomOtherStuff/Test_exe.py @@ -1,4 +1,4 @@ -from turtle import* +from turtle import * import subprocess -subprocess.run(Kreis_zufall_pre.py) \ No newline at end of file +subprocess.run(Kreis_zufall_pre.py) diff --git a/RandomOtherStuff/Textverbinder.py b/RandomOtherStuff/Textverbinder.py index 8579150..6fe8bd7 100755 --- a/RandomOtherStuff/Textverbinder.py +++ b/RandomOtherStuff/Textverbinder.py @@ -1,3 +1,4 @@ +# Yes, that is called concat, but sure x = input("Wert x: ") y = input("Wert y: ") z = input("Wert z: ") @@ -11,5 +12,3 @@ while remaining > 1: start += 6 ending += 6 remaining -= 6 - - \ No newline at end of file diff --git a/RandomOtherStuff/While_rekursion.py b/RandomOtherStuff/While_rekursion.py index ea2bd63..c5b19fe 100755 --- a/RandomOtherStuff/While_rekursion.py +++ b/RandomOtherStuff/While_rekursion.py @@ -1,10 +1,10 @@ -from turtle import* +# No, there is not in fact any recursion here +from turtle import * t1 = Turtle() t2 = Turtle() - go = 3 t1.lt(90) t1.speed(1000) @@ -13,41 +13,41 @@ t1.ht() def gogo(): go = 2 - while go>1: - if t1.xcor() < (window_width()/2 -50): + while go > 1: + if t1.xcor() < (window_width() / 2 - 50): for i in range(50): t1.fd(2) - t1.rt(180/50) - if t1.xcor() < (window_width()/2 -50): + t1.rt(180 / 50) + if t1.xcor() < (window_width() / 2 - 50): for i in range(50): t1.fd(2) - t1.lt(180/50) - + t1.lt(180 / 50) + else: print("done") print(xcor()) go = 1 - - - while go>0 and go<2: - if t1.xcor() > (window_width()/2 - window_width()/2 + 50): + + while go > 0 and go < 2: + if t1.xcor() > (window_width() / 2 - window_width() / 2 + 50): for i in range(50): t1.bk(2) - t1.lt(180/50) - if t1.xcor() > (window_width()/2 - window_width()/2 + 50): + t1.lt(180 / 50) + if t1.xcor() > (window_width() / 2 - window_width() / 2 + 50): for i in range(50): t1.bk(2) - t1.rt(180/50) + t1.rt(180 / 50) else: print("home") go = 0 onkey(gogo, "space") print("ready") - + + t2.ht() onkey(gogo, "space") listen() - -print("ready") \ No newline at end of file + +print("ready") diff --git a/RandomOtherStuff/Wortraten spiel.py b/RandomOtherStuff/Wortraten spiel.py index 929640e..dec1e26 100755 --- a/RandomOtherStuff/Wortraten spiel.py +++ b/RandomOtherStuff/Wortraten spiel.py @@ -1,4 +1,5 @@ import os + global mistakes mistakes = 0 global wortelements @@ -6,10 +7,11 @@ wortelements = [] global done done = [] + def clear_screen(): - os.system('cls') - - + os.system("cls") + + def worteingabe(): global wort wort = input("Suchen sie ein Wort, welches erraten werden soll, ein: ") @@ -17,17 +19,21 @@ def worteingabe(): print("Vielen Dank. Das Wort wurde gespeichert.") print("Geben Sie das Gerät weiter.") ausgabe(wort) - + + def ausgabe(wort): global wortelements - print(""" + print( + """ Das Wort: -""") - print(len(wort)*"*") +""" + ) + print(len(wort) * "*") global wholewordlist wholewordlist = list(wort) - wortelements = list(len(wort)*"*") + wortelements = list(len(wort) * "*") + def ersetzen(letter): global wort @@ -41,15 +47,17 @@ def ersetzen(letter): wortelements.pop(pos) wortelements.insert(pos, letter) - + def raten(): global wort global wortelements global wholewordlist - global go + global go go = 1 while go == 1: - buchstabe = input("Suchen sie einen Buchstaben aus, welcher sich im Wort befinden könnte: ") + buchstabe = input( + "Suchen sie einen Buchstaben aus, welcher sich im Wort befinden könnte: " + ) if buchstabe in wholewordlist: print("Der Buchstabe kommt hier vor:") ersetzen(buchstabe) @@ -59,7 +67,7 @@ def raten(): print("Dieser Buchstabe wurde bereits eingetippt.") addman() elif buchstabe == wort: - wholewordlist = list(len(wort)*"*") + wholewordlist = list(len(wort) * "*") else: print("Dieser Buchstabe ist nicht Teil des Wortes") done.append(buchstabe) @@ -69,28 +77,33 @@ def raten(): if len(wort) - counts <= 0: go = 0 else: - print(""" + print( + """ DAS WORT WURDE GEFUNDEN Das Wort: -""") +""" + ) print(wort) - - + + def addman(): global mistakes mistakes += 1 if mistakes == 1: - print(""" + print( + """ __________ -""") +""" + ) elif mistakes == 2: - print(""" + print( + """ @@ -98,9 +111,11 @@ def addman(): | _____|_____ -""") +""" + ) elif mistakes == 3: - print(""" + print( + """ @@ -108,9 +123,11 @@ def addman(): | | _____|_____ -""") +""" + ) elif mistakes == 4: - print(""" + print( + """ | | @@ -118,9 +135,11 @@ def addman(): | |\ _____|_\___ -""") +""" + ) elif mistakes == 5: - print(""" + print( + """ _____ | | @@ -128,9 +147,11 @@ def addman(): | |\ _____|_\___ -""") +""" + ) elif mistakes == 6: - print(""" + print( + """ _____ | | | ° @@ -138,9 +159,11 @@ def addman(): | |\ _____|_\___ -""") +""" + ) elif mistakes == 6: - print(""" + print( + """ _____ | | | ° @@ -148,9 +171,11 @@ def addman(): | |\ _____|_\___ -""") +""" + ) elif mistakes == 7: - print(""" + print( + """ _____ | | | ° @@ -158,9 +183,11 @@ def addman(): | |\ _____|_\___ -""") +""" + ) elif mistakes == 8: - print(""" + print( + """ _____ | | | ° @@ -168,9 +195,11 @@ def addman(): | / |\ _____|_\___ -""") +""" + ) elif mistakes == 9: - print(""" + print( + """ _____ | | | ° @@ -181,13 +210,11 @@ def addman(): DEAD -""") +""" + ) global go go = 0 - - - - - + + worteingabe() -raten() \ No newline at end of file +raten() diff --git a/RandomOtherStuff/timetest.py b/RandomOtherStuff/timetest.py index 819f4c3..7b1a011 100755 --- a/RandomOtherStuff/timetest.py +++ b/RandomOtherStuff/timetest.py @@ -1,5 +1,5 @@ import time -print ("time.time(): %f " % time.time()) -print (time.localtime( time.time())) -print (time.asctime( time.localtime(time.time()))) \ No newline at end of file +print("time.time(): %f " % time.time()) +print(time.localtime(time.time())) +print(time.asctime(time.localtime(time.time()))) diff --git a/RandomTurtle/Binäruhr.py b/RandomTurtle/Binäruhr.py index f13a0fb..d5ecc1a 100755 --- a/RandomTurtle/Binäruhr.py +++ b/RandomTurtle/Binäruhr.py @@ -3,12 +3,13 @@ import datetime import time -#Setup +# Setup turtle.ht() turtle.tracer(0) turtle.speed(0) -#Definition der Kreise + +# Definition der Kreise def circles(fill): turtle.pu() turtle.bk(20) @@ -21,11 +22,13 @@ def circles(fill): turtle.end_fill() turtle.pu() + turtle.home() turtle.pu() turtle.bk(25) -#Postitionieren der Turtle + +# Postitionieren der Turtle def distance(pixels): turtle.home() turtle.pu() @@ -33,17 +36,17 @@ def distance(pixels): turtle.bk(pixels) turtle.rt(90) -#Berechnen der einzelnen Stellen + +# Berechnen der einzelnen Stellen def main(): turtle.clear() turtle.home() h = datetime.datetime.now().hour min = datetime.datetime.now().minute sec = datetime.datetime.now().second - hr_pos2 = h//2 - mn_pos2 = min//2 - sk_pos2 = sec//2 - + hr_pos2 = h // 2 + mn_pos2 = min // 2 + sk_pos2 = sec // 2 for i in range(6): hr_pos2 = hr_pos2 // 2 @@ -63,10 +66,11 @@ def main(): sk_pos2 = sk_pos2 // 2 sk_pos = sk_pos2 % 2 circles(sk_pos) - + turtle.update() -#Ausführen + +# Ausführen while True: main() - time.sleep(0.1) \ No newline at end of file + time.sleep(0.1) diff --git a/RandomTurtle/Digitale Uhr.py b/RandomTurtle/Digitale Uhr.py index 199ba46..d99cdc9 100755 --- a/RandomTurtle/Digitale Uhr.py +++ b/RandomTurtle/Digitale Uhr.py @@ -1,11 +1,11 @@ -from turtle import* +from turtle import * import datetime import time style = ("Minecraftia", 75, "normal") tracer(0) -#Ausführen der Uhr. +# Ausführen der Uhr. while True: time.sleep(1) clear() @@ -15,7 +15,7 @@ while True: min = datetime.datetime.now().minute h = datetime.datetime.now().hour bk(350) -#Abstände definieren + # Abstände definieren if h >= 10: write(h, font=style) fd(200) @@ -24,7 +24,7 @@ while True: fd(100) write(h, font=style) fd(100) - write(":", font=style, align = "left") + write(":", font=style, align="left") fd(50) if min >= 10: write(min, font=style) @@ -34,7 +34,7 @@ while True: fd(100) write(min, font=style) fd(100) - write(":", font=style, align = "left") + write(":", font=style, align="left") fd(50) if sec >= 10: write(sec, font=style) @@ -45,4 +45,4 @@ while True: write(sec, font=style) fd(100) home() - update() \ No newline at end of file + update() diff --git a/RandomTurtle/Dots.py b/RandomTurtle/Dots.py index 3a8dd9a..4b1f507 100755 --- a/RandomTurtle/Dots.py +++ b/RandomTurtle/Dots.py @@ -1,10 +1,11 @@ -from turtle import* +from turtle import * import time + def scene(d): - dot(500/d) - - + dot(500 / d) + + ht() color("red") bgcolor("black") @@ -22,4 +23,4 @@ for i in range(200): update() a -= 1 time.sleep(0.025) - fd(1) \ No newline at end of file + fd(1) diff --git a/RandomTurtle/Eiskristall-Rekursion.py b/RandomTurtle/Eiskristall-Rekursion.py index a3fa073..9b20427 100755 --- a/RandomTurtle/Eiskristall-Rekursion.py +++ b/RandomTurtle/Eiskristall-Rekursion.py @@ -1,36 +1,39 @@ from turtle import * import time -r = numinput("PENTAGON","Wie gross soll die Seitenlänge des Pentagons sein?",200) -rl = numinput("PENTAGON","Wie viele Ebenen sollen benuzt werden?",3) + +r = numinput("PENTAGON", "Wie gross soll die Seitenlänge des Pentagons sein?", 200) +rl = numinput("PENTAGON", "Wie viele Ebenen sollen benuzt werden?", 3) tracer(0) + def pentagon(n, radius): if n == 0: - #ausgefülltes Pentagon zeichnen + # ausgefülltes Pentagon zeichnen color("Red") begin_fill() for i in range(5): fd(radius) - rt(360/5) - end_fill() + rt(360 / 5) + end_fill() else: for i in range(5): - #Positionierung der Turtle + # Positionierung der Turtle pu() fd(radius * 2.62 * 0.381966) - rt(360/5) + rt(360 / 5) pd() - #Rekursion - pentagon(n - 1,radius * 0.381966) + # Rekursion + pentagon(n - 1, radius * 0.381966) update() + starttime = time.time() pu() lt(90) fd(r) rt(90) -bk(r*0.6) +bk(r * 0.6) pd() pentagon(rl, r) -exitonclick(); \ No newline at end of file +exitonclick() diff --git a/RandomTurtle/Halbkreis.py b/RandomTurtle/Halbkreis.py index b63a117..eefb52c 100755 --- a/RandomTurtle/Halbkreis.py +++ b/RandomTurtle/Halbkreis.py @@ -1,14 +1,14 @@ -from turtle import* +from turtle import * speed(10000) ht() +def kreis_halb(anzahl_seiten, radius): + for i in range(anzahl_seiten): + fd(radius / anzahl_seiten) + rt(360 / anzahl_seiten) -def kreis_halb(anzahl_seiten,radius): - for i in range(anzahl_seiten): - fd(radius / anzahl_seiten) - rt(360 / anzahl_seiten) - -kreis_halb(500,800) + +kreis_halb(500, 800) exitonclick() diff --git a/RandomTurtle/Huhn.py b/RandomTurtle/Huhn.py index fba7f58..c98752f 100755 --- a/RandomTurtle/Huhn.py +++ b/RandomTurtle/Huhn.py @@ -9,7 +9,9 @@ sideby = int(turtle.numinput("Huhn", "Punkt B, cord y", -100)) sidebx = int(turtle.numinput("Huhn", "Punkt B, cord x", -200)) sidecy = int(turtle.numinput("Huhn", "Punkt C, cord y", 200)) sidecx = int(turtle.numinput("Huhn", "Punkt C, cord x", 0)) -anzahl_durchgaenge = int(turtle.numinput("Huhn", "Anzahl Durchgänge", 10, minval=1, maxval=100)) +anzahl_durchgaenge = int( + turtle.numinput("Huhn", "Anzahl Durchgänge", 10, minval=1, maxval=100) +) stiftdicke = int(turtle.numinput("Huhn", "Stiftdicke", 2, minval=1, maxval=50)) durchgang = 0 @@ -23,8 +25,8 @@ huhn.pu() huhn.ht() -def motion(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke): - edge = random.randint(1,3) +def motion(sideay, sideax, sideby, sidebx, sidecy, sidecx, stiftdicke): + edge = random.randint(1, 3) if edge == 1: x = sideax y = sideay @@ -35,16 +37,17 @@ def motion(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke): else: x = sidecx y = sidecy - + huhn.setheading(huhn.towards(x, y)) - nextpos = (math.sqrt((x - huhn.xcor())**2 + (y - huhn.ycor()) **2)) / 2 + nextpos = (math.sqrt((x - huhn.xcor()) ** 2 + (y - huhn.ycor()) ** 2)) / 2 huhn.fd(nextpos) huhn.pd() huhn.dot(stiftdicke) huhn.pu() - -def motion_pre(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke): - edge = random.randint(1,3) + + +def motion_pre(sideay, sideax, sideby, sidebx, sidecy, sidecx, stiftdicke): + edge = random.randint(1, 3) if edge == 1: x = sideax y = sideay @@ -55,33 +58,34 @@ def motion_pre(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke): else: x = sidecx y = sidecy - + huhn.setheading(huhn.towards(x, y)) - nextpos = (math.sqrt((x - huhn.xcor())**2 + (y - huhn.ycor()) **2)) / 2 + nextpos = (math.sqrt((x - huhn.xcor()) ** 2 + (y - huhn.ycor()) ** 2)) / 2 huhn.fd(nextpos) -def cagedraw(sideax,sideay,sidebx,sideby,sidecx,sidecy): + +def cagedraw(sideax, sideay, sidebx, sideby, sidecx, sidecy): cage.pu() - cage.setpos(sideax,sideay) + cage.setpos(sideax, sideay) cage.pd() - cage.setpos(sidebx,sideby) - cage.setpos(sidecx,sidecy) - cage.setpos(sideax,sideay) - + cage.setpos(sidebx, sideby) + cage.setpos(sidecx, sidecy) + cage.setpos(sideax, sideay) + print("Started drawing Triangle") -cagedraw(sideax,sideay,sidebx,sideby,sidecx,sidecy) +cagedraw(sideax, sideay, sidebx, sideby, sidecx, sidecy) print("Started mapping... Printing Points of Tranche:") turtle.tracer(1000) print("initialisation") for i in range(50): - motion_pre(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke) - + motion_pre(sideay, sideax, sideby, sidebx, sidecy, sidecx, stiftdicke) + for i in range(anzahl_durchgaenge): for i in range(1000): - motion(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke) + motion(sideay, sideax, sideby, sidebx, sidecy, sidecx, stiftdicke) durchgang += 1 - print(durchgang,"/", anzahl_durchgaenge) + print(durchgang, "/", anzahl_durchgaenge) print("done, click to exit") -turtle.exitonclick() \ No newline at end of file +turtle.exitonclick() diff --git a/RandomTurtle/Kleeblatt.py b/RandomTurtle/Kleeblatt.py index 2834274..2d548b6 100755 --- a/RandomTurtle/Kleeblatt.py +++ b/RandomTurtle/Kleeblatt.py @@ -1,17 +1,19 @@ -from turtle import* +from turtle import * speed(1000) -def blatt(seite,winkel,anzahl): + +def blatt(seite, winkel, anzahl): for i in range(anzahl): begin_fill() for i in range(3): fd(seite) lt(winkel) end_fill() - rt(360/anzahl) + rt(360 / anzahl) + ht() color("green") -blatt(100,120,4) -exitonclick() \ No newline at end of file +blatt(100, 120, 4) +exitonclick() diff --git a/RandomTurtle/Kreis_zufall_pre.py b/RandomTurtle/Kreis_zufall_pre.py index 22bd079..262d2ee 100755 --- a/RandomTurtle/Kreis_zufall_pre.py +++ b/RandomTurtle/Kreis_zufall_pre.py @@ -4,14 +4,15 @@ import time turtle.pu() + def vieleck_random_randomize(): for i in range(random.randint(25, 100)): - turtle.color(random.random(),random.random(),random.random()) + turtle.color(random.random(), random.random(), random.random()) size = random.randint(50, 200) turtle.width(random.randint(2, 10)) ecken = random.randint(3, 20) - turtle.setpos(random.randint(-300,300), random.randint(-300,300)) - fuellen = random.randint(0,1) + turtle.setpos(random.randint(-300, 300), random.randint(-300, 300)) + fuellen = random.randint(0, 1) turtle.pd() if fuellen >= 1: turtle.begin_fill() @@ -24,12 +25,13 @@ def vieleck_random_randomize(): turtle.fd(size / ecken) turtle.rt(360 / ecken) turtle.pu() - + + print("Random Design") draw_time_start = time.time() vieleck_random_randomize() draw_time_end = time.time() -print("Drawing has taken", draw_time_end - draw_time_start , "seconds") +print("Drawing has taken", draw_time_end - draw_time_start, "seconds") print("Click to exit") -turtle.exitonclick(); \ No newline at end of file +turtle.exitonclick() diff --git a/RandomTurtle/Progressbar.py b/RandomTurtle/Progressbar.py index 6be0841..62bb54f 100755 --- a/RandomTurtle/Progressbar.py +++ b/RandomTurtle/Progressbar.py @@ -3,9 +3,9 @@ import os while True: for i in range(4): - print("=", end=" ",flush=True) + print("=", end=" ", flush=True) time.sleep(0.5) - print("=", end="\r",flush=True) + print("=", end="\r", flush=True) + time.sleep(0.5) + os.system("cls") time.sleep(0.5) - os.system( 'cls' ) - time.sleep(0.5) \ No newline at end of file diff --git a/RandomTurtle/Striche.py b/RandomTurtle/Striche.py index e192ca8..2484a20 100755 --- a/RandomTurtle/Striche.py +++ b/RandomTurtle/Striche.py @@ -1,4 +1,4 @@ -from turtle import* +from turtle import * dicke = 3 lt(90) @@ -13,4 +13,3 @@ for i in range(10): lt(90) width(dicke) dicke += 2 - diff --git a/RandomTurtle/Test_while_rekursiojn.py b/RandomTurtle/Test_while_rekursiojn.py index e42cc3f..9b3eaa1 100755 --- a/RandomTurtle/Test_while_rekursiojn.py +++ b/RandomTurtle/Test_while_rekursiojn.py @@ -1,7 +1,9 @@ -from turtle import* +from turtle import * -a = int(numinput("Wie alt bist du?", "Bitte als Zahl eingeben",16,minval=1,maxval=100)) +a = int( + numinput("Wie alt bist du?", "Bitte als Zahl eingeben", 16, minval=1, maxval=100) +) -while (a>=16) and (a<=20): +while (a >= 16) and (a <= 20): fd(100) - a = 1 \ No newline at end of file + a = 1 diff --git a/RandomTurtle/TicTacToe.py b/RandomTurtle/TicTacToe.py index 9c99933..d1916aa 100755 --- a/RandomTurtle/TicTacToe.py +++ b/RandomTurtle/TicTacToe.py @@ -1,10 +1,10 @@ -#TICTACTOE V 1.0 +# TICTACTOE V 1.0 import time -#Variables5 +# Variables5 global bd -bd = [[0,0,0],[0,0,0],[0,0,0]] +bd = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] global filled_fields filled_fields = 0 global player @@ -15,8 +15,8 @@ global play play = 1 -#FUNCTIONS -#-------------------- +# FUNCTIONS +# -------------------- def inputs(): global playershow global bd @@ -28,17 +28,22 @@ def inputs(): z = int(zl) - 1 s = ord(sp) - 65 if bd[z][s] > 0: - print(""" + print( + """ THAT FIELD IS ALREADY TAKEN, CHOOSE DIFFERENT ONE! -""") +""" + ) else: - inputremap(z,s) + inputremap(z, s) else: - print(""" + print( + """ PLEASE TYPE IN A LEGIT COORDINATE: FORM: Coordinate Y Coordinate X --> Ex. A1/A2 - """) - + """ + ) + + def inputremap(z, s): global player global playershow @@ -51,9 +56,9 @@ def inputremap(z, s): playershow = 1 player = 1 global filled_fields - filled_fields += 1 + filled_fields += 1 full(filled_fields) - + def winning(): global play @@ -63,9 +68,11 @@ def winning(): global go go = 1 count = 0 - print(""" + print( + """ checking for winner -""") +""" + ) while go == 1: if sum(bd[x]) == 3: go = 0 @@ -88,11 +95,14 @@ checking for winner y += 1 if count >= 2: go = 0 - print("""no winner yet -""") + print( + """no winner yet +""" + ) else: count += 1 + def full(filled_field): global bd if filled_field == 9: @@ -103,7 +113,7 @@ def full(filled_field): winning() -#BOARD DRAWING +# BOARD DRAWING def board_draw(): print("\n") xx = 0 @@ -112,17 +122,17 @@ def board_draw(): while yy < 3: while xx < 3: if bd[xx][yy] == 0: - print(" ", end = " ") + print(" ", end=" ") elif bd[xx][yy] == 1: - print(" X ", end = " ") + print(" X ", end=" ") elif bd[xx][yy] == 7: - print(" O ", end = " ") + print(" O ", end=" ") else: print(""" CRITICAL ERROR""") if xx < 2: - print("|", end = " ") + print("|", end=" ") else: - print(" ", end = " ") + print(" ", end=" ") xx += 1 print(" ") xx = 0 @@ -131,14 +141,13 @@ def board_draw(): else: print(" ") yy += 1 - - -#MAIN CYCLE -print(50*("\n")) - -print(""" +# MAIN CYCLE +print(50 * ("\n")) + +print( + """ ------------------------------------------------------ @@ -153,35 +162,42 @@ print(""" by Janis Hutz -""") +""" +) time.sleep(2) print("starting...") time.sleep(3) print("\n\n\n") goahead = 1 -print(""" +print( + """ | | ---------------- | | ---------------- | | - """) + """ +) while goahead == 1: while play == 1: inputs() board_draw() time.sleep(2) - print(""" + print( + """ REPLAY? -""") +""" + ) i = input("""Choose: (y/n)""") if i == "y": goahead = 1 play = 1 else: goahead = 0 -print(""" +print( + """ GOOD BYE! -""") \ No newline at end of file +""" +) diff --git a/RandomTurtle/blume.py b/RandomTurtle/blume.py index d77df09..ce500d5 100755 --- a/RandomTurtle/blume.py +++ b/RandomTurtle/blume.py @@ -1,9 +1,10 @@ -from turtle import* +from turtle import * lt(90) width(3) speed(1000) + def stiel(orientation): color("green") for i in range(50): @@ -13,31 +14,29 @@ def stiel(orientation): else: fd(7) rt(1) - + def leaves(): color("red") for i in range(100): fd(3) - rt(360/100) - - - - -def blume(orientation_in,blaetter): + rt(360 / 100) + + +def blume(orientation_in, blaetter): stiel(orientation_in) for i in range(blaetter): leaves() - rt(360/blaetter) - + rt(360 / blaetter) + ht() -blume(2,5) +blume(2, 5) pu() home() fd(50) lt(90) pd() -blume(1,10) -exitonclick() \ No newline at end of file +blume(1, 10) +exitonclick() diff --git a/StringOperations/reverser.py b/StringOperations/reverser.py index b5fa577..934a9d3 100755 --- a/StringOperations/reverser.py +++ b/StringOperations/reverser.py @@ -2,12 +2,10 @@ eingabe = input("Dein Text: ") caracter = -1 morecaracters = True amountleft = len(eingabe) -while morecaracters == True: +while morecaracters: print(eingabe[caracter], end="") if amountleft > 1: caracter -= 1 amountleft -= 1 else: morecaracters = False - - \ No newline at end of file diff --git a/TextAdventure/Adventure_Crash_neu.py b/TextAdventure/Adventure_Crash_neu.py index 17925f1..5960bef 100755 --- a/TextAdventure/Adventure_Crash_neu.py +++ b/TextAdventure/Adventure_Crash_neu.py @@ -1,5 +1,6 @@ import time import random + global stepscount stepscount = 0 inventory = [] @@ -9,10 +10,9 @@ global goahead goahead = 0 - - def cover(): - print(""" + print( + """ @@ -48,15 +48,18 @@ def cover(): -""") +""" + ) time.sleep(2) - print(""" + print( + """ DIES BASIERT AUF EINER WAHREN TATSACHE. DIE SPIELELEMENTE SIND VEREINFACHT UND TEILS UNREALISTISCH DARGESTELLT. WICHTIGE DETAILS WERDEN ZUR EINFACHEREN VERSTÄNDLICHKEIT WEGGELASSEN. DER ERMITTLUNGSPROZESS IST IN WIRKLICHKEIT EINE UNGEHEURLICH SCHWIERIGE AUFGABE UND WIRD HIER AUF EIN MÖGLICHST ÜBERSCHAUBARES MASS GEKÜRZT. -""") +""" + ) time.sleep(5) go = 0 while go == 0: @@ -67,7 +70,6 @@ AUFGABE UND WIRD HIER AUF EIN MÖGLICHST ÜBERSCHAUBARES MASS GEKÜRZT. print("wrong, retry") global start start = time.time() - def gameoverpossible(): @@ -84,31 +86,36 @@ def gameoverpossible(): gameover() else: current = time.time() - + + def gameover1(): - if random.randint(0,10) == 1: - gameover() - else: - current = time.time() - -def gameover2(): - if random.randint(0,6) == 1: + if random.randint(0, 10) == 1: gameover() else: current = time.time() -def gameover3(): - if random.randint(0,3) == 1: + +def gameover2(): + if random.randint(0, 6) == 1: gameover() else: current = time.time() + +def gameover3(): + if random.randint(0, 3) == 1: + gameover() + else: + current = time.time() + + def gameover(): global next next = 0 global exit exit = 0 - print(""" + print( + """ NEW YORK TIMES DIE KATASTROPHE @@ -125,34 +132,41 @@ Flugverbot für die 737 MAX ausgesprochen hatte. Oh weh. Das wird einige Konsequenzen für dich nach sich ziehen. -""") +""" + ) time.sleep(4) - print(""" + print( + """ Es ist der nächste Morgen. Du machst dich auf zum Gericht. Die Richter entziehen den Fall deiner Verantwortung und verurteilen dich zu lebenslänglicher Haft, aufgrund von fahrlässiger Tötung. Das ist das Ende deiner Karriere. -""") - +""" + ) + print("Punktezahl: 0") - - + def einfuehrung(): - print("""Es ist Samstagmorgen... Urplötzlich stürzt eine fast brandneue Boeing 737MAX + print( + """Es ist Samstagmorgen... Urplötzlich stürzt eine fast brandneue Boeing 737MAX von Ethiopian Airlines ab. Die Welt ist schockiert, da dies bereits der zweite Absturz dieses Typs ist. Beides Mal waren fast brandneue Flugzeuge involviert. Beide Abstürze ähnelten sich -massiv. Deine Aufgabe ist es nun, die Absturze zu klären.""") - print(""" +massiv. Deine Aufgabe ist es nun, die Absturze zu klären.""" + ) + print( + """ Als neu ernannter Ermittler musst du dir bereits jetzt eine wichtige Frage stellen: Solltest du ein weltweites Flugverbot für diesen Flugzeugtypen verhängen? Sowohl Boeing als auch die Fluggesellschaften werden sich dagegen sträuben. -""") +""" + ) i = userinput("Willst du das Flugverbot verhängen? (y/n)") if i == "y": - print(""" + print( + """ NEW YORK TIMES NTSB ERMITTLER VERHÄNGT FLUGVERBOT FÜR UNGLÜCKSFLIEGER @@ -163,22 +177,27 @@ zu verhängen. Dies ist auf massive Proteste seitens der Fluggesellschaften und gestossen. Jedoch: Viele Aviatikexperten befürworten den Entscheid des Ermittlers. Die Sicherheit der Passagiere muss um jeden Preis gewährleistet werden. Die einzige Möglichkeit dies zu gewährleisten ist, ein Flugverbot auszusprechen. -""") +""" + ) done.append("grounding") elif i == "n": - print(""" + print( + """ Die Wirtschaft ist wichtig, ein Pilotenfehler kann ja nicht ausgeschlossen werden. Ermitteln wir! -""") +""" + ) else: print("wrong, retry") einfuehrung() time.sleep(4) + def grundriss(): if "grounding" in done: - print(""" + print( + """ _________________________________________________________________________________________________________ @@ -188,9 +207,11 @@ braucht sie, um das Flugzeug zu verbessern. Der Zeitdruck ist aber geringer, da weiteren Abstürze geschehen können. Hier kannst du alle Gegenstände, welche du auf der Unfallstelle finden kannst untersuchen, um die mögliche Unfallursache herauszufinden. -""") +""" + ) else: - print(""" + print( + """ _________________________________________________________________________________________________________ @@ -199,33 +220,39 @@ Dies ist dein Arbeitsplatz an der Unfallstelle. Du solltest dich so schnell wie möglich um diesen Fall kümmern, denn sonst könnte es zu weiteren Abstürzen kommen. Hier kannst du alle Gegenstände, welche du auf der Unfallstelle finden kannst untersuchen, um die mögliche Unfallursache herauszufinden. -""") - - +""" + ) + + def abspann(): - print(""" + print( + """ DU HAST ES GESCHAFFT! GLÜCKWUNSCH! - """) + """ + ) global start global stepscount times = time.time() - start - points = times*2 + stepscount**2 - 110 + points = times * 2 + stepscount**2 - 110 if points < 0: - print("Deine Zeit: ",times) + print("Deine Zeit: ", times) print("\n\nDeine Punkte (Je geringer desto besser): 0") print("\nDeine Anzahl Schritte (Je geringer desto besser):", stepscount) else: - print("Deine Zeit: ",times) - print("\n\nDeine Punkte (Je geringer desto besser): ",points) + print("Deine Zeit: ", times) + print("\n\nDeine Punkte (Je geringer desto besser): ", points) print("\nDeine Anzahl Schritte (Je geringer desto besser):", stepscount) bewertung(points) + def bewertung(punkte): - print(""" - DEINE BEWERTUNG:""") + print( + """ + DEINE BEWERTUNG:""" + ) if punkte <= 0: print(""" GOD """) if punkte < 20: @@ -240,76 +267,97 @@ def bewertung(punkte): print(""" D """) elif punkte > 300: print(""" D- """) - + def userinput(question): return input(question).lower() + def makedone(item): inventory.remove(item) done.append(item) - + + def eb(): global stepscount stepscount += 1 - print("""Du befindest dich jetzt im Ermittlerbüro. -""") + print( + """Du befindest dich jetzt im Ermittlerbüro. +""" + ) while len(inventory) > 0: stepscount += 1 if "blackbox" in inventory: makedone("blackbox") - print("""Da du ja jetzt die Blackbox des Flugzeugs gefunden hast, + print( + """Da du ja jetzt die Blackbox des Flugzeugs gefunden hast, kannst du sie hier im Ermittlerbüro aufmachen und die Flugdaten auslesen. Dies dauert jedoch eine gewisse Zeit. Du öffnest ihn und hoffst, dass einer -deiner Spezialisten die Daten retten kann.""") +deiner Spezialisten die Daten retten kann.""" + ) time.sleep(7) - print("""Dein Spezialist hat es geschafft! Die Daten konten wiederhergestellt werden! + print( + """Dein Spezialist hat es geschafft! Die Daten konten wiederhergestellt werden! Du siehst eine Auffälligkeit in den Daten der Flughöhe und der vertikalen Geschwindigkeit. Dies deutet auf massive technische Probleme hin. Auch die Daten des Anstellwinkelsensors 1, sind auffällig: Er hatte die ganze Zeit denselben Anstellwinkel angezeigt. -""") +""" + ) if "anstellwinkelsensor" in inventory: - print("""Glücklicherweise hast du ihn bereits auf dem Trümmerfeld entdeckt. -Du untersuchst ihn nun.""") + print( + """Glücklicherweise hast du ihn bereits auf dem Trümmerfeld entdeckt. +Du untersuchst ihn nun.""" + ) elif "anstellwinkelsensor" in done: print("""Du hast ihn ja bereits untersucht. """) else: print("""Du solltest dich vielleicht nach dem Sensor umsehen.""") elif "anstellwinkelsensor" in inventory: makedone("anstellwinkelsensor") - print("""Da du ja zuvor den Anstellwinkelsensor des Flugzeugs gefunden hast, + print( + """Da du ja zuvor den Anstellwinkelsensor des Flugzeugs gefunden hast, kannst du ihn jetzt auf Schäden überprüfen. Du untersuchst die Ströme, welche der Sensor bei Bewegung ausgibst und machst eine Entdeckung: ER FUNKTIONIERT NICHT! -Logischerweise könnte er auch durch den Aufprall beschädigt sein, """) +Logischerweise könnte er auch durch den Aufprall beschädigt sein, """ + ) if "blackbox" in done: - print("""aber die Blackbox bestätigt ja den Ausfall des Sensors. -Du bist der Ursache auf der Spur. Glückwunsch!""") + print( + """aber die Blackbox bestätigt ja den Ausfall des Sensors. +Du bist der Ursache auf der Spur. Glückwunsch!""" + ) global goahead goahead = 1 inventory.clear() else: - print("""du solltest deshalb die Blackbox finden, um den Ausfall zu + print( + """du solltest deshalb die Blackbox finden, um den Ausfall zu bestätigen. -""") +""" + ) print("\n") elif "turbine" in inventory: - print("""Du hast eine der beiden Turbinen in das Büro transportieren lassen. + print( + """Du hast eine der beiden Turbinen in das Büro transportieren lassen. Als mögliche Absturzursache hast du Triebwerksversagen im Verdacht. Beim Betrachten der Triebwerke erkennst du aber an der Verformung der Schaufeln und dem Dreck in der Turbine selbst, also im Kompressor, dass sie voll funktionstüchtig war. Somit kann ein Absturz durch Triebwerksversagen ausgeschlossen werden. -Denn ein modernes Flugzeug kann auch mit nur einem Triebwerk problemlos fliegen.""") +Denn ein modernes Flugzeug kann auch mit nur einem Triebwerk problemlos fliegen.""" + ) makedone("turbine") elif "zeugen" in inventory: makedone("zeugen") - print("""Du hast ja auch bereits die Zeugen befragt. Du schaust dir deine + print( + """Du hast ja auch bereits die Zeugen befragt. Du schaust dir deine Notizen lange an, kannst aber nichts erkennen, was dir für den Fall helfen könnte. -Du verwirfst die Aussagen als nicht aussagekräftig.""") +Du verwirfst die Aussagen als nicht aussagekräftig.""" + ) time.sleep(5) if goahead == 1: stepscount += 1 - print("""Du wendest dich nun den Pilotenakten zu. Der Kapitän hatte beachtliche + print( + """Du wendest dich nun den Pilotenakten zu. Der Kapitän hatte beachtliche 8000 Flugstunden und soweit du erkennen magst, auch keine bekannten Probleme. Auch die (kurze) Karriere des Copiloten war makellos, er hatte jedoch nur 200 Flugstunden. Die Piloten hatten beim Kontakt mit dem Tower Probleme gemeldet und zur Umkehr @@ -328,32 +376,41 @@ gewährleisten. Dies hatte dazu geführt, dass bei dem schon sehr alten Flugzeug Pitch-Up moment grösser wurde und somit die Nase des Flugzeugs in gewissen Fluglagen unkontrolliert nach oben gehen kann. Das MCAS sollte dies verhindern, denn diese Fluglage führt unweigerlich zu einem Strömungsabriss, bei welchem das Flugzeug sogesagt "vom Himmel -fallen würde".""") +fallen würde".""" + ) time.sleep(10) if "grounding" in done: stepscount -= 2 - print(""" + print( + """ Nachdem du ja glücklicherweise bereits bei Ermittlungsbeginn das Grounding des Typs andgeordnet hattest. Die Fluggesellschaften und Boeing hatten zwar nicht sehr positiv darauf reagiert, aber mit dem was du herausgefunden hattest, sind jetzt alle froh, dass du es getan hattest. Die 737 MAX war anschliessend bis im Dezember 2020 gegroundet und Boeing fuhr durch dieses Problem massive Verluste ein. -""") +""" + ) else: stepscount += 10 - print(""" + print( + """ Alle sind schockiert, dass du nicht bereits bei Ermittlungsbeginn ein Grounding angeordnet hattest. Boeing und auch die Fluggesellschaften fanden es zwar erst besser, aber auch sie sind jetzt der Meinung, dass es besser gewesen wäre, wenn du bereits da ein Grounding angeordnet hättest. Deine Haltung davon ist zwar verständlich, aber du wirst trotzdem zur Verantwortung gezogen. Du musst eine Haftstrafe von einem Jahr absitzen, da du viele Personen in Gefahr gebracht hast. Trotzdem, der Fall ist geklärt. -""") +""" + ) return 0 else: - print("""Um etwas untersuchen zu können, musst du erst etwas in dein Inventar nehmen, + print( + """Um etwas untersuchen zu können, musst du erst etwas in dein Inventar nehmen, dann hier zurückkehren. Gehe dazu hinaus auf die Unfallstelle. -Auch da könnten sich wichtige Hinweise verstecken.""") - i = userinput("Wo willst du hin? Zum Cockpit (c), zum Flügel (f), zum Heck (h) oder willst du Zeugen befragen (z)? ") +Auch da könnten sich wichtige Hinweise verstecken.""" + ) + i = userinput( + "Wo willst du hin? Zum Cockpit (c), zum Flügel (f), zum Heck (h) oder willst du Zeugen befragen (z)? " + ) if i == "c": return 4 if i == "f": @@ -362,15 +419,16 @@ Auch da könnten sich wichtige Hinweise verstecken.""") return 3 if i == "z": return 5 - - + def fl(): global stepscount stepscount += 1 if "flügel" in visited: print("""Du hast den Flügel bereits untersucht.""") - i = userinput("Wo willst du hin? Zum Cockpit (c), zum Heck (h), zum Büro (b) oder willst du Zeugen befragen (z)? ") + i = userinput( + "Wo willst du hin? Zum Cockpit (c), zum Heck (h), zum Büro (b) oder willst du Zeugen befragen (z)? " + ) if i == "c": return 4 if i == "b": @@ -382,20 +440,24 @@ def fl(): else: print("wrong, retry") return 2 - else: - print(""" + else: + print( + """ Der Flügel. Komplett zertrümmert. Er scheint in einem beinahe 90° Winkel aufgeschlagen zu sein. Du und dein Team finden eine der beiden Turbinen. Du lässt sie in dein Büro transportieren, um sie dort zu untersuchen. Du kannst entweder -in dein Büro gehen oder weitersuchen.""") +in dein Büro gehen oder weitersuchen.""" + ) i = userinput("Willst du zurück? (y/n)") visited.append("flügel") time.sleep(2) - if i == 'y': + if i == "y": return 1 - elif i == 'n': + elif i == "n": print("""Du willst also weitersuchen.""") - i = userinput("Wo willst du hin? Zum Cockpit (c), zum Heck (h) oder willst du Zeugen befragen (z)? ") + i = userinput( + "Wo willst du hin? Zum Cockpit (c), zum Heck (h) oder willst du Zeugen befragen (z)? " + ) if i == "c": return 4 if i == "h": @@ -405,15 +467,16 @@ in dein Büro gehen oder weitersuchen.""") else: print("wrong, retry") return 2 - - + def hk(): global stepscount stepscount += 1 if "heck" in visited: print("""Du hast das Heck bereits untersucht.""") - i = userinput("Wo willst du hin? Zum Cockpit (c), zum Flügel (f), zum Büro (b) oder willst du Zeugen befragen (z)? ") + i = userinput( + "Wo willst du hin? Zum Cockpit (c), zum Flügel (f), zum Büro (b) oder willst du Zeugen befragen (z)? " + ) if i == "c": return 4 if i == "b": @@ -426,19 +489,23 @@ def hk(): print("wrong, retry") return 3 else: - print(""" + print( + """ Du entdeckst etwas, das wie das Seitenleitwerks des Flugzeugs aussehen könnte. Dein grösstes Ziel ist, die Blackbox zu finden. Du hebst Teile an, und plötzlich siehst du sie: -Die Blackbox. Du hebst sie auf und lässt sie in dein Büro bringen. """) +Die Blackbox. Du hebst sie auf und lässt sie in dein Büro bringen. """ + ) inventory.append("blackbox") time.sleep(1) visited.append("heck") i = userinput("Willst du zurück? (y/n)") - if i == 'y': + if i == "y": return 1 - elif i == 'n': + elif i == "n": print("""Du willst also weitersuchen.""") - i = userinput("Wo willst du hin? Zum Cockpit (c), zum Flügel (h) oder willst du Zeugen befragen (z)? ") + i = userinput( + "Wo willst du hin? Zum Cockpit (c), zum Flügel (h) oder willst du Zeugen befragen (z)? " + ) if i == "c": return 4 if i == "f": @@ -448,15 +515,16 @@ Die Blackbox. Du hebst sie auf und lässt sie in dein Büro bringen. """) else: print("wrong, retry") return 3 - - - + + def zg(): global stepscount stepscount += 1 if "zeugen" in visited: print("""Du hast die Zeugen bereits befragt.""") - i = userinput("Wo willst du hin? Zum Cockpit (c), zum Flügel (f), zum Büro (b) oder zum Heck (h)? ") + i = userinput( + "Wo willst du hin? Zum Cockpit (c), zum Flügel (f), zum Büro (b) oder zum Heck (h)? " + ) if i == "c": return 4 if i == "b": @@ -469,7 +537,8 @@ def zg(): print("wrong, retry") return 5 else: - print(""" + print( + """ Du machst dich auf den Weg in ein nahegelegenes Dorf, da du gehört hast, dass eine Person den Absturz gesehen hat. - Hallo. Sie haben den Absturz mitverfolgt? @@ -481,16 +550,19 @@ den Absturz gesehen hat. - Vielen Dank. Sie haben mir geholfen. Du machst dich auf den Weg zurück zur Unfallstelle. Willst du dir direkt Gedanken über die - Aussagen machen? Dafür musst du ins Büro zurück. """) + Aussagen machen? Dafür musst du ins Büro zurück. """ + ) inventory.append("zeugen") time.sleep(1) visited.append("zeugen") i = userinput("Willst du zurück? (y/n)") - if i == 'y': + if i == "y": return 1 - elif i == 'n': + elif i == "n": print("""Du willst also weitersuchen.""") - i = userinput("Wo willst du hin? Zum Cockpit (c), zum Heck (h) oder zum Flügel (f)? ") + i = userinput( + "Wo willst du hin? Zum Cockpit (c), zum Heck (h) oder zum Flügel (f)? " + ) if i == "c": return 4 if i == "h": @@ -500,15 +572,16 @@ den Absturz gesehen hat. else: print("wrong, retry") return 5 - - + def co(): global stepscount stepscount += 1 if "cockpit" in visited: print("""Du hast das Cockpit bereits untersucht.""") - i = userinput("Wo willst du hin? Zum Heck (h), zum Flügel (f), zum Büro (b) oder willst du Zeugen befragen (z)? ") + i = userinput( + "Wo willst du hin? Zum Heck (h), zum Flügel (f), zum Büro (b) oder willst du Zeugen befragen (z)? " + ) if i == "h": return 3 if i == "b": @@ -521,19 +594,23 @@ def co(): print("wrong, retry") return 4 else: - print(""" + print( + """ Du näherst dich der Nase des Flugzeugs. Vorsichtig läufst du umher. Vor dir liegt ein Sensor. Er scheint defekt zu sein. Du hebst ihn auf und lässt ihn in dein Büro bringen. -Du kannst zurück gehen und ihn untersuchen oder weitersuchen.""") +Du kannst zurück gehen und ihn untersuchen oder weitersuchen.""" + ) inventory.append("anstellwinkelsensor") time.sleep(1) visited.append("cockpit") i = userinput("Willst du zurück? (y/n)") - if i == 'y': + if i == "y": return 1 - elif i == 'n': + elif i == "n": print("""Du willst also weitersuchen.""") - i = userinput("Wo willst du hin? Zum Flügel (f), zum Heck (h) oder willst du Zeugen befragen (z)? ") + i = userinput( + "Wo willst du hin? Zum Flügel (f), zum Heck (h) oder willst du Zeugen befragen (z)? " + ) if i == "f": return 2 if i == "h": @@ -543,8 +620,6 @@ Du kannst zurück gehen und ihn untersuchen oder weitersuchen.""") else: print("wrong, retry") return 4 - - def main(): @@ -574,4 +649,5 @@ def main(): if exit == 1: abspann() -main() \ No newline at end of file + +main()