Hello World!

Olivier
10.12.2025 · 3 min read

My first week with Python

Key takeaways:

Lists []

Use [] for Lists that can be modified.
Create a list: fruit_inventory = ["Apples", "Strawberries", "Orange"]
Retrieve a value: fruit_inventory[1]
Add a value: fruit_inventory.append("Bananas")
Delete a specific value: fruit_inventory.remove("Apples")
Sort alphabetically: fruit_inventory.sort()

Tuples ()

Use () for tuples that cannot be modified
Create a tuple: fruit_inventory = ("Apples", "Strawberries", "Orange")
Merging tuples: total_inventory = fruit_inventory + mean_inventory
Loop through tuples converted in a list using list(tuple):
for pdt, rev in tuple:
print(f"{pdt} has total revenue of ${rev}")

Dictionaries {}

Use {} for dictionaries with a combination of Key & Value.
Create a dictionary: stock_level = {"Apples": 28, "Cheese": 12, "Orange Juice": 36}
Update a value: stock_level["Apples"] = 31 or stock_level.update({"Apples": 31})
Retrieve a value: stock_level.get("Apples")
Add or merge dictionaries: stock_level.update(2nd_dictionary)
Delete a specific entry: stock_level.pop("Apples")
Clear the entire dictionary: stock_Level.clear()

Loops

We can use either for or while.
for loop is used to iterate over a sequence (such as a list, tuple, string, or range) or other iterable objects.
while loop repeatedly executes a block of code as long as a specified condition is true.

Built-in fonctions

print() allows you to display a message: print("Hello Python!")
len() returns the number of elements in an object such as a list, string, tuple, dictionary: len(list_a)
range(start, stop, step) returns a sequence of integers: range(2, 8, 2)
type() returns the type of the specified object: type(variable_1)
sum() sums up all elements from an iterable object: sum(list_a)
max() and min() returns the highest and smallest numbers from an iterable object: max(list_a)
float() converts a number or string into a float
int() converts a number or string into an integer
sorted() sorts an iterable object without changing the order in the object like the sort() method does: sorted(list_a)
zip() combines two or more iterable objects into on iterable object of tuples: zip(list_a, list_b, list_c)
copy() create a shallow copy of a list. This means that the method creates a new list containing the same elements as the original list but maintains its own identity in memory.
list() function creates a list object from a tuple for example.
abs() returns the absolute value, for example abs(-5) will return 5.
round() will round the float. round takes two arguments: param 1 (mandatory) is the value that you want to round and param2 (optional) is the number of decimals.
The map() function executes a specified function for each item in an iterable. The item is sent to the function as a parameter. For example map(round, [1.2354, 2.654, 3.5487]).

Custom fonctions

def is used to create a function
A function always return a value (if no value is returned, then the function will return None)
Parameters can be passed to the function with a default value like def apply_discount(price, discount=0.10):



Conclusions

After a week of learning Python, I can simply say that this is a very intuitive language and easy to learn. List, Tuples and Dictionaries seem to be real good objects to store and extract data.

Next, I will follow an introduction on Pandas.