############################# ### 01.Hue Sript DM2 WS24 ### ### by Langmann Sven ### ### for Andreas Gruber ### ############################# ######################### ### Learning by doing ### ###:Sven Langmann ### ### 20241007 ### ######################### """ This is a comment written in more than just one line """ print("Hello, World!") print "hello world" print "hello world" print #this is a comment import sys print "sys version", print sys.version #this is a comment if 5 > 2: print "Five is greater than two" print # x = 5 y = "John" print(x) print(y) x = 4 # x is of type int x = "Sally" # x is now of type str print(x) print ##Assign Multiple Values x, y, z = "Orange", "Banana", "Cherry" print(x) print(y) print(z) # x = y = z = "Orange" print(x) print(y) print(z) print ##Output Variables x = "Python is awesome" print(x) # # x = "Python" y = "is" z = "awesome" print(x, y, z) #Notice the space character after "Python " and "is ", without them the result would be "Pythonisawesome". x = "Python " y = "is " z = "awesome " print(x + y + z) # #Variables that are created outside of a function (as in all of the examples in the previous pages) are known as global variables. #Global variables can be used by everyone, both inside of functions and outside. x = "awesome" def myfunc(): print("Python is " + x) myfunc() #If you create a variable with the same name inside a function, #this variable will be local, and can only be used inside the function. #The global variable with the same name will remain as it was, global and with the original value. x = "awesome" def myfunc(): x = "fantastic" print("Python is " + x) myfunc() print("Python is " + x) print # # #Python Data Types #x = 5 #print(type(x)) x = "hello World (str)" x = "hello World" print x # x = 20 print x # x = 20.5 print x # x = 1j print x # #x = ["apple", "banana", "cherry"] (list) x = ["apple", "banana", "cherry"] print x #x = ("apple", "banana", "cherry") (tuple) #x = range(6) (range) #x = {"name" : "John", "age" : 36} (dict) #x = {"apple", "banana", "cherry"} #x = frozenset({"apple", "banana", "cherry"}) (frozenset) #x = True (bool) #x = b"Hello" (bytes) #x = bytearray(5) (bytearray) #x = memoryview(bytes(5)) (memoryview) #x = None (NoneType) print print ############################# ### 01.Hue Sript DM2 WS24 ### ############################# print "01.Hue Sript DM2 WS24" print #how many meters of spaghetti you consume? #every 2 day consuming nudels #every 2 time I eat nudels I eat spaghettti #ungekocht Spagethi print "how many meters of spagehtti I consum?" print #how many times I consum nudels per week print "how many times I consum nudels per week?" x = 2 y = 7 print x / y, print "days" print ##every 2 time I eat nudels I eat spaghettti print "very 2 time I eat nudels I eat spaghettti" print (y / x)/2, print "days" #how many meters nudels pro portion uncooked? x=10 #Nudels y= 0.25 #1 Nudel hat 0,25m print print "how many meters nudels pro portion uncooked?" print x * y, print "m" print #if I eat every 2 day spagethi, how many meters I consum in 1 week?? print "if I eat every 2 day spagethi, how many meters I consum in 1 week?" a=2 #days b=7 #days c=10 #Nudels d=0.25 #m print a/b * c*d, print "m" print #How many meters Spagehti I consum in 1 month? print "How many meters Spagehti I consum in 1 month?" print a/b * c*d *4, print "m" print #How many meters Spagehti I consum in 1 year? print "How many meters Spagehti I consum in 1 year?" print a/b * c*d*4 *12, print "m" print import datetime x = datetime.datetime(2020,5,17) print(x)