Introduction à Python pour les développeurs
Jasmin Ludolf
Senior Data Science Content Developer

# This works
ingredient_name = 'San Marzano tomatoes'
# This also works
ingredient_name = "San Marzano tomatoes"
' = apostrophe = guillemet simple# 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""" : Chaînes multilignesMéthode = une fonction qui n'est disponible que pour un type de données spécifique
Méthodes str
# Calling a string method
string_variable.method()
.replace(text_to_be_replaced, text_to_change_it_to)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
Introduction à Python pour les développeurs