From 25dcde2f53a53c165174709cd2f4ce1234d91337 Mon Sep 17 00:00:00 2001 From: QuestMasterIke Date: Thu, 1 Jun 2023 11:25:24 +0200 Subject: [PATCH 1/8] Update helloworld_start.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Erste Übung --- Ch2 - Basics/helloworld_start.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Ch2 - Basics/helloworld_start.py b/Ch2 - Basics/helloworld_start.py index 7d6b753..53a1842 100644 --- a/Ch2 - Basics/helloworld_start.py +++ b/Ch2 - Basics/helloworld_start.py @@ -3,4 +3,12 @@ # LinkedIn Learning Python course by Joe Marini # +def main(): + print("Hello World") + name = input("Wie ist dein Name?") + print("Schön dich kennenzulernen,",name) + + +if __name__ == "__main__": + main() \ No newline at end of file From 1ec6ec11d2aef560dd46264a3f6f7c1c45515c4d Mon Sep 17 00:00:00 2001 From: QuestMasterIke Date: Thu, 1 Jun 2023 11:51:40 +0200 Subject: [PATCH 2/8] Update variables_start.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Übung 2 --- Ch2 - Basics/variables_start.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Ch2 - Basics/variables_start.py b/Ch2 - Basics/variables_start.py index b2756cc..6ce76e5 100644 --- a/Ch2 - Basics/variables_start.py +++ b/Ch2 - Basics/variables_start.py @@ -22,16 +22,27 @@ print(mydict) # re-declaring a variable works - +myint = "abc" +print(myint) # to access a member of a sequence type, use [] +print(mylist[3]) +print(mytuple[0]) # use slices to get parts of a sequence +print(mylist[0::2]) +print(mylist[1:3]) -# you can use slices to reverse a sequence +# you can use slices to reverse a sequence +print(mytuple[::-1]) # dictionaries are accessed via keys - +print(mydict["two"]) # ERROR: variables of different types cannot be combined - +print("String"+str(123)) # Global vs. local variables in functions +def function(): + mystr = "functionwert" + print(mystr) +function() +print(mystr) From 0d437b13158da5f009eaac91991eaa16fb747d53 Mon Sep 17 00:00:00 2001 From: QuestMasterIke Date: Fri, 2 Jun 2023 11:21:42 +0200 Subject: [PATCH 3/8] Test push --- Ch2 - Basics/variables_start.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Ch2 - Basics/variables_start.py b/Ch2 - Basics/variables_start.py index 6ce76e5..150c24e 100644 --- a/Ch2 - Basics/variables_start.py +++ b/Ch2 - Basics/variables_start.py @@ -46,3 +46,4 @@ def function(): function() print(mystr) +Test From 39653c59811439668e84a2b49bc8ae3246914939 Mon Sep 17 00:00:00 2001 From: QuestMasterIke Date: Fri, 2 Jun 2023 12:55:25 +0200 Subject: [PATCH 4/8] Functions learned --- Ch2 - Basics/functions_start.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Ch2 - Basics/functions_start.py b/Ch2 - Basics/functions_start.py index 56cb247..72f4dbd 100644 --- a/Ch2 - Basics/functions_start.py +++ b/Ch2 - Basics/functions_start.py @@ -5,17 +5,39 @@ # TODO: define a basic function - +def function(): + print("Hello from function ") + +function() # TODO: function that takes arguments +def function2(zahl,z2): + print(zahl+z2) +function2(4,5) # TODO: function that returns a value +def cube(x): + return x*x*x +print(cube(3)) # TODO: function with default value for an argument +def power(num,x=1): + result=1 + for i in range(x): + result=result*num + return result - +print(power(3)) # TODO: function with variable number of arguments +def multi_add(*args): + result=0 + for x in args: + result+=x + return result + + +print(multi_add(2,6,9,5)) From 1e3c547a9d7d8d200d8127ef71da0bba1ff5c826 Mon Sep 17 00:00:00 2001 From: QuestMasterIke Date: Fri, 2 Jun 2023 13:04:23 +0200 Subject: [PATCH 5/8] Conditionals learned --- Ch2 - Basics/conditionals_start.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Ch2 - Basics/conditionals_start.py b/Ch2 - Basics/conditionals_start.py index f6b58d6..e3648e6 100644 --- a/Ch2 - Basics/conditionals_start.py +++ b/Ch2 - Basics/conditionals_start.py @@ -6,14 +6,31 @@ def main(): - x, y = 10, 100 + x, y = 100, 100 # conditional flow uses if, elif, else + if x Date: Fri, 2 Jun 2023 13:18:26 +0200 Subject: [PATCH 6/8] Loops gelernt --- Ch2 - Basics/loops_start.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Ch2 - Basics/loops_start.py b/Ch2 - Basics/loops_start.py index f7d2e75..29580d1 100644 --- a/Ch2 - Basics/loops_start.py +++ b/Ch2 - Basics/loops_start.py @@ -8,20 +8,30 @@ def main(): x = 0 # TODO: define a while loop - - + while(x<5): + print(x) + x+=1 # TODO: define a for loop - + for x in range(5,10): + print(x) # TODO: use a for loop over a collection days = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"] - + for x in days: + print(x) # TODO: use the break and continue statements - - - # TODO: using the enumerate() function to get index + for x in days: + + if x=="Sat": + continue + print(x) + # TODO: using the enumerate() function to get index + days = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"] + for i,d in enumerate(days): + + print(i,d) if __name__ == "__main__": main() From 1c73a23f5b346c16be099760e33ef0664474d4a6 Mon Sep 17 00:00:00 2001 From: QuestMasterIke Date: Tue, 6 Jun 2023 11:37:50 +0200 Subject: [PATCH 7/8] Chalange completed --- Ch2 - Basics/challange_start.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Ch2 - Basics/challange_start.py diff --git a/Ch2 - Basics/challange_start.py b/Ch2 - Basics/challange_start.py new file mode 100644 index 0000000..86d8a18 --- /dev/null +++ b/Ch2 - Basics/challange_start.py @@ -0,0 +1,32 @@ + +text="" + +def polidromtest(text): + y="" + + for x in text: + if x.isalnum(): + y=y+x + test=True + rev=y[::-1] + for i,b in enumerate(y): + + if rev[i]!=b: + print("Is palindrom:",False) + test=False + break + + if test: + print("Polindrom!") + + + + +while text != "exit": + + text =input ("Enter palindrome or 'exit':") + text=text.lower() + if text=="exit": + break + else: + polidromtest(text) From 7a55441eb05749dc3362c41f1e393e6084e12e5b Mon Sep 17 00:00:00 2001 From: QuestMasterIke Date: Tue, 6 Jun 2023 15:21:55 +0200 Subject: [PATCH 8/8] Files gelernt --- Ch2 - Basics/variables_start.py | 2 +- Ch3 - Files/files_start.py | 18 ++++++++---- Test.txt | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 Test.txt diff --git a/Ch2 - Basics/variables_start.py b/Ch2 - Basics/variables_start.py index 150c24e..eea0c4d 100644 --- a/Ch2 - Basics/variables_start.py +++ b/Ch2 - Basics/variables_start.py @@ -46,4 +46,4 @@ def function(): function() print(mystr) -Test + diff --git a/Ch3 - Files/files_start.py b/Ch3 - Files/files_start.py index fb026bb..501240d 100644 --- a/Ch3 - Files/files_start.py +++ b/Ch3 - Files/files_start.py @@ -6,19 +6,25 @@ def main(): # Open a file for writing and create it if it doesn't exist - - + #myfile = open("Test.txt","w+") + # Open the file for appending text to the end - + myfile = open("Test.txt","a+") # write some lines of data to the file - + for i in range(10): + myfile.write("Some new text\n") # close the file when done - + myfile.close() # Open the file back up and read the contents - + myfile=open("test.txt","r") + if myfile.mode =="r": + + rl= myfile.readlines() + for line in rl: + print(line) if __name__ == "__main__": main() diff --git a/Test.txt b/Test.txt new file mode 100644 index 0000000..8547e56 --- /dev/null +++ b/Test.txt @@ -0,0 +1,50 @@ +Some text +Some text +Some text +Some text +Some text +Some text +Some text +Some text +Some text +Some text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text +Some new text