from docx import Document from docx.shared import Inches, Pt from docx.enum.text import WD_ALIGN_PARAGRAPH def create_exam_document(output_filename): document = Document() # Set default font and size style = document.styles['Normal'] font = style.font font.name = 'Times New Roman' font.size = Pt(12) # Header header_text = [ ("الجمهورية اليمنية", WD_ALIGN_PARAGRAPH.RIGHT), ("جامعة تعز", WD_ALIGN_PARAGRAPH.RIGHT), ("كلية الهندسة", WD_ALIGN_PARAGRAPH.RIGHT), ("قسم برمجيات + تقنية المعلومات + ذكاء اصطناعي / مستوى أول", WD_ALIGN_PARAGRAPH.RIGHT), ("", WD_ALIGN_PARAGRAPH.CENTER), ("اسم المقرر: رياضيات متقطعة", WD_ALIGN_PARAGRAPH.RIGHT), ("مدرس المقرر: د/ اسكندر أمير", WD_ALIGN_PARAGRAPH.RIGHT), ("الزمن: ساعتان", WD_ALIGN_PARAGRAPH.RIGHT), ("التاريخ: / 2026", WD_ALIGN_PARAGRAPH.RIGHT), ("", WD_ALIGN_PARAGRAPH.CENTER), ("اختبار نهاية الفصل الدراسي الثاني 2025/2026", WD_ALIGN_PARAGRAPH.CENTER), ("", WD_ALIGN_PARAGRAPH.CENTER), ("أجب عن جميع الأسئلة التالية", WD_ALIGN_PARAGRAPH.RIGHT), ("", WD_ALIGN_PARAGRAPH.CENTER), ] for text, alignment in header_text: p = document.add_paragraph(text) p.alignment = alignment if "اختبار نهاية الفصل الدراسي الثاني" in text: p.runs[0].bold = True p.runs[0].font.size = Pt(14) # Question 1 document.add_heading('السؤال الأول', level=1).alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('(أ) عرف كلا مما يلي:', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('1. الجبر البولي.', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('2. الدالة البوابية.', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('3. علاقة التكافؤ.', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('4. الرسم البسيط.', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('(ب) اعتبر:', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('U = {1,2,3,4,5,6,7,8,9,10}', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('A = {1,3,5,7}', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('B = {2,4,5,6,9}', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('C = {1,2,4,5}', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('D = {1,3,5,10}', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('أوجد:', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('1. A ∩ (B ∪ C)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('2. (A − C) − D', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('3. A − D', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT # Question 2 document.add_heading('السؤال الثاني', level=1).alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('(أ)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('باستخدام جدول الصواب أثبت أن:', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('p ⊕ q ≡ (p → ¬q) ∧ (¬q → p)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('(ب)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('لتكن A ،B ،C ثلاث مجموعات، برهن أن:', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('A − (B − C) = (A − B) ∪ (A ∩ C)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT # Question 3 document.add_heading('السؤال الثالث', level=1).alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('(أ)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('بسط الدالة البوابية (واكتبها على شكل MSP):', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('f(x,y,z,w) = xyz′w′ + xy′z′w′ + xy′z′w + xyz′w', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('(ب)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('اكتب الدالة:', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('f(x,y,z) = xz′ + y′z', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('على هيئة CSP.', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT # Question 4 document.add_heading('السؤال الرابع', level=1).alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('لتكن لدينا الرسم (المخطط):', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('G = (V,E)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('حيث:', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('V = {a,b,c,d,g,h}', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('E = {e₁,e₂,e₃,e₄,e₅,e₆,e₇}', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT # Table for Question 4 table = document.add_table(rows=2, cols=8) table.alignment = WD_ALIGN_PARAGRAPH.CENTER hdr_cells = table.rows[0].cells hdr_cells[0].text = 'E' hdr_cells[1].text = 'e₁' hdr_cells[2].text = 'e₂' hdr_cells[3].text = 'e₃' hdr_cells[4].text = 'e₄' hdr_cells[5].text = 'e₅' hdr_cells[6].text = 'e₆' hdr_cells[7].text = 'e₇' row_cells = table.rows[1].cells row_cells[0].text = 'F(e)' row_cells[1].text = '[a,a]' row_cells[2].text = '[a,b]' row_cells[3].text = '[a,c]' row_cells[4].text = '[b,d]' row_cells[5].text = '[c,d]' row_cells[6].text = '[d,b]' row_cells[7].text = '[c,h]' document.add_paragraph('المطلوب:', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('1. جد تمثيلاً للرسم G (ارسم مخطط هذا الجدول).', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('2. احسب درجات الرؤوس.', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('3. عين الرؤوس الفردية، والرؤوس الزوجية، والرؤوس المعزولة، والرؤوس المعلقة، والأضلاع المكررة، والعروات.', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('4. هل الرسم (المخطط) بسيط أم لا؟ (علل).', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT # Question 5 document.add_heading('السؤال الخامس', level=1).alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('(أ)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('لتكن R علاقة معرفة على Z⁺ (الأعداد الصحيحة الموجبة) كالآتي:', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('aRb ⇔ a | b ، ∀a,b ∈ Z⁺', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('بيّن ما إذا كانت R علاقة ترتيب جزئي، وعلاقة ترتيب كلي.', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('(ب)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('أثبت أن العبارة التقريبية:', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('[(p → q) ∧ (q → r)] → (p → r)', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT document.add_paragraph('صحيحة منطقيًا.', style='List Number').alignment = WD_ALIGN_PARAGRAPH.RIGHT # Footer p = document.add_paragraph("انتهت الأسئلة") p.alignment = WD_ALIGN_PARAGRAPH.CENTER p = document.add_paragraph("بالتوفيق والنجاح") p.alignment = WD_ALIGN_PARAGRAPH.CENTER document.save(output_filename) if __name__ == '__main__': create_exam_document('اختبار_رياضيات_متقطعة.docx')
تعليقات
إرسال تعليق