Einführung in Python für die Softwareentwicklung
Jasmin Ludolf
Senior Data Science Content Developer

# This works
ingredient_name = 'San Marzano tomatoes'
# This also works
ingredient_name = "San Marzano tomatoes"
' = Apostroph = einfaches Anführungszeichen# Single quote string variable containing an apostrophe
ingredient_name = 'Chef's special seasoning'
print(ingredient_name)
SyntaxError: invalid syntax.
# Double quote string variable containing an apostrophe
ingredient_name = "Chef's special seasoning"
print(ingredient_name)
Chef's special seasoning
recipe_step = "Heat olive oil in a large pan and sauté garlic until fragrant"
# Create a string variable over multiple lines
recipe_instructions = """1. Bring a large pot of salted water to boil and cook pasta
2. Heat olive oil in a pan and sauté minced garlic until fragrant
3. Add chopped tomatoes and simmer for 10 minutes
4. Toss cooked pasta with tomato sauce and fresh basil leaves
"""
"""text""": mehrzeilige ZeichenketteMethode = eine Funktion, die nur für einen bestimmten Datentyp verfügbar ist
str-Methoden
# Calling a string method
string_variable.method()
.replace(zu_ersetzender_text, neuer_text)welcome_message = "Welcome to the recipe scaler, George" welcome_message = welcome_message.replace("George", "John")print(welcome_message)
Welcome to the recipe scaler, John
ingredient_name = "Basil Leaves"# Convert to lowercase ingredient_name = ingredient_name.lower() print(ingredient_name)
basil leaves
# Change to uppercase
ingredient_name = ingredient_name.upper()
print(ingredient_name)
BASIL LEAVES
Einführung in Python für die Softwareentwicklung