# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
'\nSpyder Editor\n\nThis is a temporary script file.\n'
# Ganze Zahlen (engl. integer)
type(1)
a=1
type(a)
int
b= 1.
print("Typ von b",type(b))
1.3
1.34e-12
type(1.3)
Typ von b <class 'float'>
float
True
False
None
print(print("a"))
a
None
s = "Hallo"
type(s)
ms = """
Mehr-
zeiliger
Text
"""
print(ms)
ms
Mehr-
zeiliger
Text
' \nMehr-\nzeiliger\nText\n'
liste = [1, 2, "Paul", 1.2, 1+2j, 2]
print(liste)
[1, 2, 'Paul', 1.2, (1+2j), 2]
tupel = (1,2,"Hallo",1)
print(tupel)
tupel = 1, 2, "Hallo", 1 # die runden Klammern sind optional
print(tupel)
(1, 2, 'Hallo', 1)
(1, 2, 'Hallo', 1)
menge = {1,2,1,2,"ahh"}
print(menge)
{'ahh', 1, 2}
1+1
1+1j
1j*1j
4j*2.1j
5-2.3
6/5 # "normale" Division
6//5 # Ganzzahlige Division
15 % 2 # Modulo
1
2*3+1
2*(3+1)
2+2*2**2
10
True and True, True and False, False and True, False and False
True or True, True or False, False or True, False or False
True ^ True, True ^ False, False ^ True, False ^ False
# Vergleiche
1==2, 1> 2, 1<2
1==2, 1> 2, 1<2
(False, False, True)
import numpy as np
np.sin(1)
np.sqrt(25)
np.pi
np.e
np.exp(1)
np.log(1)
np.abs(-5)
np.log10(1000)
np.linspace(0,1)
np.linspace(0,1,num=4)
array([ 0. , 0.33333333, 0.66666667, 1. ])
# Ctrl + I vor Befehl
a = 1
print(a)
a = 2
print(a)
a = 17.3
print(a)
a = "Hallo Welt"
print(a)
# Achtung!
a = 17,1;
print(a);
a = 17.1;
a=a+1
1
2
17.3
Hallo Welt
(17, 1)
f = lambda x : 1/(1+x**2)
print(f(0),f(1),f(-1.1))
1.0 0.5 0.45248868778280543
import numpy as np
np.cos(1)
0.54030230586813977