0% found this document useful (0 votes)
4K views2 pages

From Docx Import Document - Py

The document is a Python programming showcase submitted by Wasik Khurshid for the 4th semester. It includes an index table of various programs related to lists, tuples, and loops in Python, along with detailed descriptions and source code for each program. The document is intended for submission to Dr. Manmeet Singh.

Uploaded by

teamxtwasik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4K views2 pages

From Docx Import Document - Py

The document is a Python programming showcase submitted by Wasik Khurshid for the 4th semester. It includes an index table of various programs related to lists, tuples, and loops in Python, along with detailed descriptions and source code for each program. The document is intended for submission to Dr. Manmeet Singh.

Uploaded by

teamxtwasik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

from docx import Document

from docx.shared import Inches

# Create a new document


doc = Document()

# Add a title
doc.add_heading('Python Programming Showcase - Best Among All Students', 0)

# Add student details


doc.add_paragraph('Submitted By: Wasik Khurshid')
doc.add_paragraph('Semester: 4th')
doc.add_paragraph('Roll No: 28-CSE-2023')
doc.add_paragraph('Course Code: PCC-CSE-431')
doc.add_paragraph('Submitted to: Dr. Manmeet Singh')

# Add an index table


doc.add_heading('INDEX', level=1)
table = doc.add_table(rows=1, cols=3)
table.style = 'Table Grid'
hdr_cells = table.rows[0].cells
hdr_cells[0].text = 'S.No'
hdr_cells[1].text = 'Program'
hdr_cells[2].text = 'Date'

# Add rows to the table


rows = [
('06', 'Write a program to create, append, and remove lists in Python.',
'19/02/2025'),
('07', 'Write a program to demonstrate working with tuples in Python.',
'19/02/2025'),
('08', 'Write a program to demonstrate working with dictionaries in Python.',
'19/02/2025'),
('09', 'Write a program to check whether a number is even or odd using `if`
condition.', '19/02/2025'),
('10', 'Write a program to demonstrate `for` loop.', '19/02/2025'),
('11', 'Write a program to demonstrate `while` loop.', '19/02/2025'),
('12', 'Write a program to display prime numbers between 50 to 60.',
'19/02/2025'),
]

for row in rows:


row_cells = table.add_row().cells
row_cells[0].text = row[0]
row_cells[1].text = row[1]
row_cells[2].text = row[2]

# Add program details


programs = [
{
'title': 'Program 06: Create, Append, and Remove Lists',
'description': 'This program demonstrates how to create, modify, and
manipulate lists in Python.',
'code': '''
# Creating a list with fruit names
fruits = ["Apple", "Orange", "Banana"]
print("Original List:", fruits)

# Appending a new fruit to the list


fruits.append("Pineapple")
print("After Appending Pineapple:", fruits)

# Inserting a new fruit at a specific position


fruits.insert(1, "Mango")
print("After Inserting Mango at Position 1:", fruits)

# Removing a fruit by value


fruits.remove("Orange")
print("After Removing Orange:", fruits)

# Removing a fruit by index


del fruits[1]
print("After Removing the Second Fruit:", fruits)
'''
},
# Add other programs similarly...
]

for program in programs:


doc.add_heading(program['title'], level=2)
doc.add_paragraph(program['description'])
doc.add_paragraph('Source Code:')
doc.add_paragraph(program['code'])

# Save the document


doc.save('pp1902_wasik.docx')
print("DOCX file generated successfully!")

You might also like