# ================================================================== # Quanzetta — أساسيات بايثون (Python Foundation) # Session 7 · Lesson 7: Formatting Output with f-Strings # الجلسة 7: دوال النصوص و f-strings — الدرس 7: تنسيق المخرجات بـ f-strings # # طريقة الاستخدام في Google Colab: # انسخ كل جزء (CELL) في خلية كود منفصلة، وشغّلها بـ Shift + Enter. # أو انسخ الملف كله في خلية واحدة وشغّله مرة واحدة. # الخلايا اللي فيها input() هتستنى تكتب قيمة وتضغط Enter. # ================================================================== # ---------- CELL 1: الطريقة العادية بالفواصل ---------- wolf_id = "1386F" pack = "Lamar Canyon" method = "GPS" print("Wolf ID", wolf_id, "in pack", pack, "with method", method) # ---------- CELL 2: نفس التقرير بـ f-string ---------- wolf_id = "1386F" pack = "Lamar Canyon" method = "GPS" print(f"Wolf {wolf_id} | Pack: {pack} | Method: {method}") # ---------- CELL 3: رقم جوه النص ---------- wolf_id = "1386F" observations = 7 print(f"Wolf {wolf_id} has {observations} recorded observations.") # ---------- CELL 4: تنسيق رقم عشري: رقمين بعد العلامة ---------- distance_km = 12.6784 print(f"Recorded distance: {distance_km} km") print(f"Recorded distance: {distance_km:.2f} km") # 12.68 # ---------- CELL 5: جرّب مع فِكرو — حل مقترح ---------- wolf_id = "2042M" method = "VHF" observations = 5 print(f"Wolf {wolf_id} was tracked by {method} with {observations} observations.")