diff --git a/README.md b/README.md index 7179190..67a5893 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,21 @@ -# 30-DAYS-OF-PYTHON +### Structure du projet -Welcome to the **30 Days of Python** challenge. This is a self-paced learning program designed to help you strengthen your understanding of Python. Over the next 30 days, you'll go from the basics of the language to building a small project. This initiative is organized by the [Python Togo Community](https://pytogo.org). +- constantes.py : les tarifs et plages horaires +- calculateur.py : fonction de conversion et calcule +- interface.py : interface avec l'utilisateur +- main.py : point d'entrée et boucle principale -## Objectives +### Utilisation -- Learn Python syntax and scripting -- Build problem-solving and logical thinking skills -- Understand core programming concepts -- Practice data structures and algorithms (DSA) -- Build a small Python project by the end of the challenge +- cloner le projet: +- git clone https://github.com/Abou-fatima/30-Days-Of-Python -## Projet Final - Édition 2026 +Exigence: +- avoir installé python +- Lancer dans le terminal du projet +python main.py -> ⚠️ **Le projet final change chaque année.** Pour l'édition en cours [PyCon Togo 2026](https://pycon.pytogo.org), consulte impérativement le fichier dédié ci-dessous - ne te base pas sur les anciens projets des éditions précédentes. -📄 **Brief complet du projet 2026 : [`Projects.md`](./Projects.md)** +## 🧪 Résultats des tests -Résumé : -- **Projet 1 (obligatoire, tous niveaux) :** Calculateur de Trajet Zemidjan/Taxi -- **Projet 2 (optionnel, intermédiaire/avancé) :** Simulateur de Change FCFA/Devises -- Aucune utilisation d'IA générative autorisée -- On ne triche pas son prochain - travail strictement personnel -- **Deadline : 20 août 2026, 23h59 (heure de Lomé)** - seul le dernier commit avant cette date/heure est pris en compte - - -Pour le projet final 2026, suis plutôt les instructions de [SUBMISSION.md](./SUBMISSION.md) -> [Demo Video]( Bientôt disponible) - -## License - -This project is licensed under the Apache 2.0 License. - ---- - -Happy learning! If you get stuck, don't hesitate to ask questions or share your progress in the [Python Togo Community](https://pytogo.org/discord). +![Test du calculateur](resultat.png) diff --git a/SUBMISSION.md b/SUBMISSION.md index 3956974..7e486c5 100644 --- a/SUBMISSION.md +++ b/SUBMISSION.md @@ -57,4 +57,4 @@ Ajoute ta ligne dans le tableau ci-dessous en respectant exactement ce format : | Prénom | Username Fata | Lien GitHub du projet | Projet 2 (optionnel) | |---|---|---|---| -| Geoffrey|jeffreyGordon | https://github.com/geoffreylgv/projetPyContogo2026-vtc | https://github.com/geoffreylgv/projetPyContogo2026-exchangeSimulator| \ No newline at end of file +| Alpha Ousmane| alphadev | https://github.com/Abou-fatima/30-Days-Of-Python |-| diff --git a/calculateur.py b/calculateur.py new file mode 100644 index 0000000..c0d7bbc --- /dev/null +++ b/calculateur.py @@ -0,0 +1,60 @@ +from constantes import ZEMIDJAN , TAXI, HEURE_POINTE + + +# La fonction pour convertir l'heure saisie + +def convertir_heure(heure_str): + + parties = heure_str.split(":") + heures = int(parties[0]) + minutes = int(parties[1]) + + return heures + (minutes / 60) + + + + +# La fonction qui permet de verifier si l'heure saisie correspond à l'heure de pointe + +def est_heure_pointe(heure_str): + + heure_decimale = convertir_heure(heure_str) + for debut, fin in HEURE_POINTE: + if debut <= heure_decimale <= fin: + return True + else: + return False + + + + +def calculer_prix(transport, distance, heure): + + if transport == "zemidjan": + tarifs = ZEMIDJAN + else: + tarifs = TAXI + + prix_de_base = tarifs["tarif_de_base"] + (tarifs["prix_au_km"] * distance) + + if est_heure_pointe(heure): + prix_final = prix_de_base * tarifs["majoration"] + else: + prix_final = prix_de_base + return prix_final + + + + +def arrondir_prix(prix): + return round(prix / 25) * 25 + + + + + + + + + + diff --git a/constantes.py b/constantes.py new file mode 100644 index 0000000..1d4ed5c --- /dev/null +++ b/constantes.py @@ -0,0 +1,26 @@ + +# Les tarifs pour le zemidjan + +ZEMIDJAN = { + "tarif_de_base": 150, + "prix_au_km": 75, + "majoration": 1.15 +} + + +# Les tarifs pour le taxi +TAXI = { + "tarif_de_base": 200, + "prix_au_km": 100, + "majoration": 1.25 +} + +# Les heures de pointe + +HEURE_POINTE = [ + (7.0, 8.75), + (11.75, 13.0), + (17.0, 19.0) +] + + diff --git a/interface.py b/interface.py new file mode 100644 index 0000000..d650b32 --- /dev/null +++ b/interface.py @@ -0,0 +1,61 @@ +from calculateur import est_heure_pointe, arrondir_prix + + +def choisir_transport(): + + while True: + choix = input('Choisissez votre transport (z pour zemidjan, t pour taxi) : ') + choix = choix.lower().strip() + if choix == "z": + return "zemidjan" + elif choix == "t": + return "taxi" + else: + print("Choix invalide. Veuillez saisir 'z' ou 't'.") + + + +def demander_distance(): + + while True: + try: + distance = float(input("Entrez la distance en km : ")) + if distance <= 0: + print("La distance doit être positive") + else: + return distance + except: + print("Veuillez entrer un nombre valide (ex: 5, 15, 3.5).") + +def demander_heure(): + + while True: + heure = input("Entrez l'heure (format HH:MM) : ") + if ":" not in heure: + print("Format invalide ! utilisez HH:MM (ex: 07:30).") + continue + + try: + parties = heure.split(":") + heures = int(parties[0]) + minutes = int(parties[1]) + + if 0 <= heures <= 23 and 0 <= minutes <= 59: + return heure + else: + print("Heure invalide ! Heures: 0-23, Minutes: 0-59.") + except ValueError: + print("Veuillez entrez des nombres valides pour l'heure et les minutes.") + + +def afficher_resultat(transport, distance, heure, prix): + pointe = "OUI" if est_heure_pointe(heure) else "NON" + prix_arrondi = arrondir_prix(prix) + + print(" 🚗------ RESULTAT DE VOTRE TRAJET ------- 🚗") + + print(f" Transport : {transport.capitalize()}") + print(f" Distance : {distance:.1f} km") + print(f" Heure : {heure} (pointe : {pointe})") + print(f" Prix : {prix_arrondi} FCFA") + diff --git a/main.py b/main.py new file mode 100644 index 0000000..d87309f --- /dev/null +++ b/main.py @@ -0,0 +1,36 @@ +from interface import choisir_transport, demander_distance, demander_heure, afficher_resultat +from calculateur import calculer_prix + +def main(): + + print(" ------ BIENVENUE DANS LE CALCULATEUR DE TRAJET ------- ") + print(" Zemidjan / Taxi - Lomé") + + while True: + transport = choisir_transport() + distance = demander_distance() + heure = demander_heure() + + prix = calculer_prix(transport, distance, heure) + + afficher_resultat(transport, distance, heure, prix) + + while True: + reponse = input("Voulez-vous calculer un autre trajet ? (o/n) : ") + reponse = reponse.lower().strip() + if reponse in ["o", "n"]: + break + print(" Repondez par 'o' ou 'n' .") + + if reponse == "n": + print(' Merci d\'avoir utilisé le calculateur de trajet !') + print(" A Bientôt sur la route ") + break + + +if __name__ == "__main__": + main() + + + + \ No newline at end of file diff --git a/resultat.png b/resultat.png new file mode 100644 index 0000000..ec2024e Binary files /dev/null and b/resultat.png differ