Practice 7 30424 ENG
Practice 7 30424 ENG
2018-2019
To carry out each exercise, use the Python modules specified in the text.
1) Create a new Excel file – saving it on a disk – to manage the grades of the first semester
Create a program in Python (to be saved with the name Exercise_1.py), which performs the
following actions, making use of the objects available in the openpyxl and os modules. More
specifically the program will have to:
Create a new Excel file, saving it in an existing folder named “Excel exercise”. The folder
should be previously created (by you) in a path of your choice on your computer (e.g.
C:\Excel exercise). The name to be assigned to the file must be requested to the user
during the creation phase (without specifying the extension .xlsx, which must be added
during the execution of the program).
Create as many worksheets as the user wants to insert, assigning to each of them the
name that the user should be prompted to specify.
In the active worksheet (that is, by default, the first among those just created), insert the
labels "Exam" and "Score", respectively in cells A1 and B1.
A tuple must be defined, containing the following names: "Economics", "Mathematics",
"History" and "Law".
The program will have to let the user enter – one by one (by column) – the scores of
each exam, starting from row 2. In particular, column A will have to show the names of
the courses and column B will have to host the correspondent scores entered by the
user.
In the first row below the name of the last course (column A), insert the label “Average”.
In the corresponding cell on the right (column B) enter the average value of the scores,
calculated using the appropriate function available in Excel.
Remember to make sure that any changes made to the Excel file just edited are saved
before the execution of the program ends.
To close the procedure of creation of the Excel file, show to the user the message: "The
creation of the file FileName.xlsx has been completed. Thank you!”.
To verify the correct functioning of the code, create an Excel file (with name and as you like),
containing at least three worksheets.
Using the objects available in the webbrowser library, create a program with Python (to be
saved with the name Exercise_2 - Wikipedia.py) that shows in the default web browser the
Wikipedia page for a city chosen by the user. Before proceeding, perform some research on
Wikipedia to analyze the way in which the URL of the results pages is formed.