Skip to content

Commit 030d6f9

Browse files
authored
Merge pull request #73 from braboj/codex/update-headers-in-python-examples
Clarify example headers
2 parents 473f3ee + 617c0d1 commit 030d6f9

14 files changed

Lines changed: 43 additions & 48 deletions
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Hello World example
22
# ----------------------------------------------------------------------------
3-
# This is a simple example to demonstrate the most basic functionality of
4-
# Python. It prints "Hello world!" to the console and performs a simple
5-
# arithmetic operation (1 + 1).
3+
# This simple program prints "Hello world!" and performs a basic
4+
# addition (1 + 1) to highlight Python's core syntax.
65

76
print("Hello world!")
87
print(1 + 1)

examples/02_variables/string_cases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# String case manipulation examples
22
# -----------------------------------------------------------------------------
3-
# This code demonstrates various string case manipulation methods in Python.
3+
# This code applies various string case manipulation methods in Python.
44

55
# Store the string to be manipulated
66
text = "AAAA bbbb"

examples/02_variables/string_concatenation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# String concatenation example
22
# -----------------------------------------------------------------------------
3-
# This code demonstrates how to concatenate (join) strings in Python. The
4-
# `+` operator is used to combine multiple strings into one. This is a common
5-
# operation in Python, especially when constructing messages or combining
6-
# text from different sources.
3+
# This code concatenates (joins) strings using the `+` operator. This
4+
# technique is common when constructing messages or combining text from
5+
# different sources.
76

87

98
string1 = 'Hello'

examples/02_variables/string_escaping.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Escape sequences in Python strings
22
# -----------------------------------------------------------------------------
3-
# This code demonstrates how to use escape sequences in Python strings. Escape
4-
# sequences are special characters that allow you to include characters in a
5-
# string that would otherwise be difficult or impossible to include directly.
3+
# This example uses escape sequences in strings so you can include
4+
# characters that would otherwise be difficult or impossible to type
5+
# directly.
66
#
77
# Special characters:
88
# - `\n` for new line

examples/02_variables/string_indexing.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# String indexing
22
# -----------------------------------------------------------------------------
3-
# This code demonstrates how to access individual characters in a string using
4-
# indexing. In Python, strings are sequences of characters, and you can access
5-
# each character by its index. The index starts at 0 for the first character,
6-
# and you can also use negative indices to access characters from the end
7-
# of the string.
3+
# This code accesses individual characters in a string by index. Strings are
4+
# sequences of characters, so index 0 refers to the first character, and
5+
# negative indices let you read characters from the end of the string.
86

97
string = "Hello, world!"
108

examples/02_variables/string_interpolation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# String interpolation
22
# -----------------------------------------------------------------------------
3-
# This code demonstrates how to use f-strings (formatted string literals) in
4-
# Python to create strings that include variables. F-strings allow you to
5-
# embed expressions inside string literals, using curly braces `{}`.
3+
# This code uses f-strings (formatted string literals) to create strings
4+
# that include variables. Expressions inside curly braces `{}` are
5+
# evaluated in place.
66

77
first_name = "Branimir"
88
last_name = "Georgiev"

examples/02_variables/string_length.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Calculate the length of a string
22
# -----------------------------------------------------------------------------
3-
# This code demonstrates how to calculate the symbol length of a string in
4-
# Python. Bear in mind that this is not the same as the byte length of the
5-
# string, which can be different if the string contains UTF-8 characters that
6-
# are represented by multiple bytes.
3+
# This snippet calculates the number of characters in a string. The
4+
# result differs from the byte length when the string contains UTF-8
5+
# characters that use multiple bytes.
76

87
text = "0123456789"
98
print(len(text))

examples/02_variables/string_slicing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# String slicing
22
# -----------------------------------------------------------------------------
3-
# This code demonstrates how to slice strings in Python. String slicing allows
4-
# you to extract a portion of a string by specifying a start index, an end index,
5-
# and an optional step. The syntax for slicing is `string[start:end:step]`.
3+
# This code slices strings in Python. Slicing extracts a portion of a string
4+
# by specifying a start index, an end index, and an optional step using
5+
# the syntax `string[start:end:step]`.
66
#
77
# The `start` index is inclusive, the `end` index is exclusive, and the `step`
88
# determines the increment between each index in the slice. The default values

examples/02_variables/var_as_container.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Variable as a container
22
# -----------------------------------------------------------------------------
3-
# This code demonstrates how a variable can be used as a container for data.
4-
# In this case, the variable `text` is used to store a string value, which can
5-
# be reused multiple times in the code. The variable is a fundamental concept in
6-
# programming, allowing you to store and manipulate data efficiently.
3+
# This code uses a variable as a container for data. The variable `text`
4+
# stores a string value that can be reused multiple times, illustrating how
5+
# variables allow you to store and manipulate data efficiently.
76

87
text = 'Hello world!'
98
print(text)

examples/02_variables/var_bool_type.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Boolean variables
22
# -----------------------------------------------------------------------------
3-
# This code demonstrates how to use boolean variables in Python. They are
4-
# used to represent truth values, which can be either `True` or `False`. Boolean
5-
# variables are often used in conditional statements and logical operations.
3+
# This example uses boolean variables to represent truth values—either
4+
# `True` or `False`. Such variables are often part of conditional
5+
# statements and logical operations.
66

77
var = False
88
print(var)

0 commit comments

Comments
 (0)