ein paar Lern-Skripte hinzugefügt..

This commit is contained in:
Daniel Schick 2022-01-17 07:07:20 +01:00
parent e717002606
commit a584827133
5 changed files with 113 additions and 0 deletions

View File

@ -5,6 +5,7 @@ ___
## Installation ## Installation
`pip install plotly` `pip install plotly`
`pip install pandas`
## Dokumentation ## Dokumentation

36
misc/simple_1.py Normal file
View File

@ -0,0 +1,36 @@
# Kommentar
# Strings
bla = 'das ist ein schöner Schdring\n \
nächste Zeile'
print(bla)
print(bla[2:10]) # Substring
print(bla[:3] + bla[-6:]) # erstes und letztes Wort
# List
werte = [ 3, 6, 23, 34, 56.3, 35.6]
print(werte)
werte.append(23) # returns none
print(werte)
werte[2] = 4 # mutable, with index
print(werte)
# Fibonacci
a, b = 0, 1 # multiple assignment
while a < 10:
print(a, end=':') # Schleifenbody ist eingerückt
a, b = b, a + b
print("\n -- Primzahlensuche:")
# Primzahlensuche mit for .. else!
for n in range(2, 10):
for x in range(2, n):
if n % x == 0:
print(n, "equals", x, "*", n//x)
break
else:
# keinen Faktor gefunden (innere Schleife)
print(n, "ist Primzahl")

34
misc/simple_2.py Normal file
View File

@ -0,0 +1,34 @@
point = (3, 0)
match point:
case (0,0):
print("Origin")
case (0, y):
print(f"Y={y}")
case (x, 0):
print(f"X={x}")
case (x, y):
print(f"X={x}, Y={y}")
case _:
raise ValueError("no point")
def fib(n):
"""Print a fibonacci series up to n.""" # this is the doc string
result = []
a, b = 0, 1
while a < n:
result.append(a)
a, b = b, a + b
return result
print(fib(2000))
def Collector(a, L=[]): # L wird hier nur einmal initialisiert!
L.append(a)
return L
print(Collector(2))
print(Collector(58))
print(Collector("Gurkensalat"))

31
misc/werkzeug_test.py Normal file
View File

@ -0,0 +1,31 @@
from contextlib import nullcontext
import imp
import os
from venv import create
from werkzeug.test import create_environ
from werkzeug.serving import run_simple
from werkzeug.urls import url_parse
from werkzeug.wrappers import Request, Response
from werkzeug.routing import Map, Rule
from werkzeug.exceptions import HTTPException, NotFound
from werkzeug.middleware.shared_data import SharedDataMiddleware
from werkzeug.utils import redirect
#environ = create_environ('/bla', 'http://localhost:8999')
#environ['PATH_INFO']
class Device(object):
def __init__(self, config):
pass
def dispatch_request(self, request):
return Response('got it')
app = Device(nullcontext)
run_simple('heupferd', 8999, app, use_reloader=True)

11
misc/wifi.py Normal file
View File

@ -0,0 +1,11 @@
#https://www.geeksforgeeks.org/how-to-find-available-wifi-networks-using-python/
import subprocess
devices = subprocess.check_output(['netsh', 'wlan', 'show', 'network'])
devices = devices.decode('ascii')
devices = devices.replace("\r", "")
print(devices)