From 52146ff04a8fe60bdaca5c115168d9b7df044d38 Mon Sep 17 00:00:00 2001 From: inhale-dir Date: Tue, 29 Apr 2025 17:38:46 +0200 Subject: [PATCH] init commit --- beschreibmich.txt | 11 +++++++++++ einundausgabe.py | 20 ++++++++++++++++++++ fileread.py | 11 +++++++++++ forloop.py | 10 ++++++++++ functions.py | 9 +++++++++ ifelse.py | 27 +++++++++++++++++++++++++++ while.py | 13 +++++++++++++ 7 files changed, 101 insertions(+) create mode 100644 beschreibmich.txt create mode 100644 einundausgabe.py create mode 100644 fileread.py create mode 100644 forloop.py create mode 100644 functions.py create mode 100644 ifelse.py create mode 100644 while.py diff --git a/beschreibmich.txt b/beschreibmich.txt new file mode 100644 index 0000000..802ef5a --- /dev/null +++ b/beschreibmich.txt @@ -0,0 +1,11 @@ +meganega +meganega +meganega +meganega +meganega +meganega +meganega +meganega +meganega +meganega +meganega diff --git a/einundausgabe.py b/einundausgabe.py new file mode 100644 index 0000000..9eebbdd --- /dev/null +++ b/einundausgabe.py @@ -0,0 +1,20 @@ +# Variable füllen +str_auto = "porsche" +int_reifen = 275 +float_ps = 512.5 + +# String einlesen +string_produktionsort = input("Produktionsort: ") + +# Diesen String ausgeben +print(string_produktionsort) + +# Nur eine Zahl eingeben +int_winterreifen = int(input("Anzahl der benötigten Winterreifen: ")) + +# Diesen INT ausgeben +print(int_winterreifen) + +# cout << "Gebe das und das ein" +# cin >> int_winterreifen +# input("Aufforderung was eingegeben werden muss (ausgabe): ") \ No newline at end of file diff --git a/fileread.py b/fileread.py new file mode 100644 index 0000000..2b6501d --- /dev/null +++ b/fileread.py @@ -0,0 +1,11 @@ +# Open file and write +# with open("beschreibmich.txt", "a") as f: +# f.write("meganega\n") +# f.close() + +# Open file and read content +with open("beschreibmich.txt", "r") as hs: + # print(hs.read()) + file_content = hs.read() + hs.close() + print(file_content) \ No newline at end of file diff --git a/forloop.py b/forloop.py new file mode 100644 index 0000000..00ef7ae --- /dev/null +++ b/forloop.py @@ -0,0 +1,10 @@ +# car_brands = [2, 8, 7, 3] + +# for x in car_brands: +# print(x) + +zahl1 = 8 + +for x in range(3, 10): + zahl1 += 5 + print(zahl1) \ No newline at end of file diff --git a/functions.py b/functions.py new file mode 100644 index 0000000..859f336 --- /dev/null +++ b/functions.py @@ -0,0 +1,9 @@ +# Eine Funktion in Python heißt Definition + +def funktion(zahl1, zahl2): + if zahl1 > zahl2: + print("True") + else: + print("False") + +funktion(1, 6) \ No newline at end of file diff --git a/ifelse.py b/ifelse.py new file mode 100644 index 0000000..247c0e3 --- /dev/null +++ b/ifelse.py @@ -0,0 +1,27 @@ +# Deklaration von 2 Variablen +int_zahl1 = 5 +int_zahl2 = 3 + +# If/Elif/Else +if int_zahl1 < int_zahl2: + print("Zahl 2 größer als Zahl 1") + +elif int_zahl1 > int_zahl2: + print("Zahl 1 größer als Zahl 2") + +else: + print("Error") + +# Error handling +try: + if int_zahl1 < int_zahl2: + print("Zahl 2 größer als Zahl 1") + + elif int_zahl1 > int_zahl2: + print("Zahl 1 größer als Zahl 2") + + else: + print("Error") + +except: + print("Programm hat fehler") \ No newline at end of file diff --git a/while.py b/while.py new file mode 100644 index 0000000..fc8c3d3 --- /dev/null +++ b/while.py @@ -0,0 +1,13 @@ +# While Loop + +zahl1 = 9 +zahl2 = 1 + +# while statement & statement +while zahl1 > zahl2: + zahl2+=1 + print(zahl2) + +# while true +while True: + print("oki") \ No newline at end of file