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
View File
@@ -0,0 +1,5 @@
for zahl in range(1,11,2):
print(zahl)
+7
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
View File
@@ -0,0 +1,5 @@
import math
print(f'Pi ist {math.pi}')
print(f'Pi ist {math.pi:.2f}')
+1
View File
@@ -0,0 +1 @@
print('Homer'.lower().find('home'.lower()))
+12
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
View File
@@ -0,0 +1,5 @@
print('Homer'.find('e'))
print('Homer'.find('n'))
+2
View File
@@ -0,0 +1,2 @@
print('Homer'.find('Home'))
print('Homer'.find('home'))
+6
View File
@@ -0,0 +1,6 @@
a=5
b=10
produkt = a * b
print(f'Das Produkt aus {a} und {b} ist {produkt}')
+7
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
View File
@@ -0,0 +1,3 @@
print('Homer'.lower())
print('Homer'.upper())
print('homer'.capitalize())
+5
View File
@@ -0,0 +1,5 @@
s = 'Homer'
for pos in range(0,len(s)):
print(s[pos])
+3
View File
@@ -0,0 +1,3 @@
s1 = 'Homer'
print(len(s1))
+5
View File
@@ -0,0 +1,5 @@
s= ' mit Leerzeichen '
s = s.strip()
print(f'*{s}*')
+1
View File
@@ -0,0 +1 @@
print('dr. nick riviera'.title())