From 01854a4fb7aa1766e5a7680edaa7082f861b2e84 Mon Sep 17 00:00:00 2001 From: David Gailleton Date: Thu, 18 Dec 2025 15:39:15 +0100 Subject: [PATCH] piscine 00 --- 00/ex0/ft_hello_garden.py | 2 ++ 00/ex1/ft_plot_area.py | 6 ++++++ 00/ex2/ft_harvest_total.py | 8 ++++++++ 00/ex3/ft_plant_age.py | 7 +++++++ 00/ex4/ft_water_reminder.py | 7 +++++++ 00/ex5/ft_count_harvest_iterative.py | 6 ++++++ 00/ex5/ft_count_harvest_recursive.py | 9 +++++++++ 00/ex6/ft_garden_summary.py | 8 ++++++++ 00/ex7/ft_seed_inventory.py | 9 +++++++++ 9 files changed, 62 insertions(+) create mode 100644 00/ex0/ft_hello_garden.py create mode 100644 00/ex1/ft_plot_area.py create mode 100644 00/ex2/ft_harvest_total.py create mode 100644 00/ex3/ft_plant_age.py create mode 100644 00/ex4/ft_water_reminder.py create mode 100644 00/ex5/ft_count_harvest_iterative.py create mode 100644 00/ex5/ft_count_harvest_recursive.py create mode 100644 00/ex6/ft_garden_summary.py create mode 100644 00/ex7/ft_seed_inventory.py diff --git a/00/ex0/ft_hello_garden.py b/00/ex0/ft_hello_garden.py new file mode 100644 index 0000000..9885c07 --- /dev/null +++ b/00/ex0/ft_hello_garden.py @@ -0,0 +1,2 @@ +def ft_hello_garden(): + print("Hello, Garden Community!") diff --git a/00/ex1/ft_plot_area.py b/00/ex1/ft_plot_area.py new file mode 100644 index 0000000..1f876d4 --- /dev/null +++ b/00/ex1/ft_plot_area.py @@ -0,0 +1,6 @@ +def ft_plot_area(): + print("Enter length:", end=" ") + len = int(input()) + print("Enter width:", end=" ") + width = int(input()) + print("Plot area: ", len * width) diff --git a/00/ex2/ft_harvest_total.py b/00/ex2/ft_harvest_total.py new file mode 100644 index 0000000..e650e9f --- /dev/null +++ b/00/ex2/ft_harvest_total.py @@ -0,0 +1,8 @@ +def ft_harvest_total(): + print("Day 1 harvest:", end=" ") + d1 = int(input()) + print("Day 2 harvest:", end=" ") + d2 = int(input()) + print("Day 3 harvest:", end=" ") + d3 = int(input()) + print("Total harvest:", d1 + d2 + d3) diff --git a/00/ex3/ft_plant_age.py b/00/ex3/ft_plant_age.py new file mode 100644 index 0000000..aed79cb --- /dev/null +++ b/00/ex3/ft_plant_age.py @@ -0,0 +1,7 @@ +def ft_plant_age(): + print("Enter plant age in days:", end=" ") + age = int(input()) + if age > 60: + print("Plant is ready to harvest!") + else: + print("Plant needs more time to grow.") diff --git a/00/ex4/ft_water_reminder.py b/00/ex4/ft_water_reminder.py new file mode 100644 index 0000000..7c33587 --- /dev/null +++ b/00/ex4/ft_water_reminder.py @@ -0,0 +1,7 @@ +def ft_water_reminder(): + print("Days since last watering:", end=" ") + x = int(input()) + if x > 2: + print("Water the plants!") + else: + print("Plants are fine") diff --git a/00/ex5/ft_count_harvest_iterative.py b/00/ex5/ft_count_harvest_iterative.py new file mode 100644 index 0000000..d588503 --- /dev/null +++ b/00/ex5/ft_count_harvest_iterative.py @@ -0,0 +1,6 @@ +def ft_count_harvest_iterative(): + print("Days until harvest:", end=" ") + i = range(1, int(input()) + 1) + for n in i: + print("Day", n) + print("Harvest time!") diff --git a/00/ex5/ft_count_harvest_recursive.py b/00/ex5/ft_count_harvest_recursive.py new file mode 100644 index 0000000..b8632e5 --- /dev/null +++ b/00/ex5/ft_count_harvest_recursive.py @@ -0,0 +1,9 @@ +def ft_count_harvest_recursive(x=-1): + if x < 0: + print("Days until harvest:", end=" ") + x = int(input()) + ft_count_harvest_recursive(x) + print("Harvest time!") + elif x > 0: + ft_count_harvest_recursive(x - 1) + print("Day", x) diff --git a/00/ex6/ft_garden_summary.py b/00/ex6/ft_garden_summary.py new file mode 100644 index 0000000..5b1ba72 --- /dev/null +++ b/00/ex6/ft_garden_summary.py @@ -0,0 +1,8 @@ +def ft_garden_summary(): + print("Enter garden name:", end=" ") + g_name = input() + print("Enter number of plants:", end=" ") + nb_plants = input() + print("Garden:", g_name) + print("Plants:", nb_plants) + print("Status: Growing well!") diff --git a/00/ex7/ft_seed_inventory.py b/00/ex7/ft_seed_inventory.py new file mode 100644 index 0000000..2a7382e --- /dev/null +++ b/00/ex7/ft_seed_inventory.py @@ -0,0 +1,9 @@ +def ft_seed_inventory(seed_type: str, quantity: int, unit: str) -> None: + if unit == "packets": + print(seed_type.capitalize(), "seeds:", quantity, unit, "available") + elif unit == "grams": + print(seed_type.capitalize(), "seeds:", quantity, unit, "total") + elif unit == "area": + print(seed_type.capitalize(), "seeds:", "covers", quantity, "square meters") + else: + print("Unknown unit type")