Sources von Teil 3

This commit is contained in:
2023-02-19 09:54:34 +01:00
parent bad8696d67
commit c21159f36f
14 changed files with 67 additions and 0 deletions

5
teil2/range.py Normal file
View File

@@ -0,0 +1,5 @@
for zahl in range(1,11,2):
print(zahl)

7
teil3/beispielstrings.py Normal file
View File

@@ -0,0 +1,7 @@
# coding = 'utf-8'
s1 = 'Homer'
s2 = '1969'
s3 = 'Dies ist ein ganzer Satz.'
s4 = 'Auf den Alkohol - Der Beginn und die Lösung sämtlicher Lebenprobleme. (Homer Simpson)'

5
teil3/f-string-format.py Normal file
View File

@@ -0,0 +1,5 @@
import math
print(f'Pi ist {math.pi}')
print(f'Pi ist {math.pi:.2f}')

View File

@@ -0,0 +1 @@
print('Homer'.lower().find('home'.lower()))

12
teil3/find_eigen.py Normal file
View File

@@ -0,0 +1,12 @@
def find_in_string(s, c):
for pos in range(0,len(s)):
if(s[pos] == c):
return pos
return -1
print(find_in_string('Homer','e'))
print(find_in_string('Homer','n'))

5
teil3/find_intern.py Normal file
View File

@@ -0,0 +1,5 @@
print('Homer'.find('e'))
print('Homer'.find('n'))

2
teil3/find_string.py Normal file
View File

@@ -0,0 +1,2 @@
print('Homer'.find('Home'))
print('Homer'.find('home'))

6
teil3/fstring.py Normal file
View File

@@ -0,0 +1,6 @@
a=5
b=10
produkt = a * b
print(f'Das Produkt aus {a} und {b} ist {produkt}')

7
teil3/split.py Normal file
View File

@@ -0,0 +1,7 @@
s = 'Dies ist ein ganzer Satz.'
print(f'zerlegt= {s.split()}')
werte = '1,2,3,4,5,6,7,8,9'
print(f'werteliste = {werte.split(",")}')

3
teil3/str_upp_lower.py Normal file
View File

@@ -0,0 +1,3 @@
print('Homer'.lower())
print('Homer'.upper())
print('homer'.capitalize())

5
teil3/string_iter.py Normal file
View File

@@ -0,0 +1,5 @@
s = 'Homer'
for pos in range(0,len(s)):
print(s[pos])

3
teil3/stringlaenge.py Normal file
View File

@@ -0,0 +1,3 @@
s1 = 'Homer'
print(len(s1))

5
teil3/strip.py Normal file
View File

@@ -0,0 +1,5 @@
s= ' mit Leerzeichen '
s = s.strip()
print(f'*{s}*')

1
teil3/title.py Normal file
View File

@@ -0,0 +1 @@
print('dr. nick riviera'.title())