mirror of
https://github.com/DavidGailleton/42-Piscine_Python.git
synced 2026-01-26 16:51:58 +00:00
piscine 00
This commit is contained in:
2
00/ex0/ft_hello_garden.py
Normal file
2
00/ex0/ft_hello_garden.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def ft_hello_garden():
|
||||
print("Hello, Garden Community!")
|
||||
6
00/ex1/ft_plot_area.py
Normal file
6
00/ex1/ft_plot_area.py
Normal file
@@ -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)
|
||||
8
00/ex2/ft_harvest_total.py
Normal file
8
00/ex2/ft_harvest_total.py
Normal file
@@ -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)
|
||||
7
00/ex3/ft_plant_age.py
Normal file
7
00/ex3/ft_plant_age.py
Normal file
@@ -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.")
|
||||
7
00/ex4/ft_water_reminder.py
Normal file
7
00/ex4/ft_water_reminder.py
Normal file
@@ -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")
|
||||
6
00/ex5/ft_count_harvest_iterative.py
Normal file
6
00/ex5/ft_count_harvest_iterative.py
Normal file
@@ -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!")
|
||||
9
00/ex5/ft_count_harvest_recursive.py
Normal file
9
00/ex5/ft_count_harvest_recursive.py
Normal file
@@ -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)
|
||||
8
00/ex6/ft_garden_summary.py
Normal file
8
00/ex6/ft_garden_summary.py
Normal file
@@ -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!")
|
||||
9
00/ex7/ft_seed_inventory.py
Normal file
9
00/ex7/ft_seed_inventory.py
Normal file
@@ -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")
|
||||
Reference in New Issue
Block a user