Info8025 – IT Automation
Project
Requirements
The project consists of Task 1 and Task 2. Each Task is to be completed in a separate script.
For each task you can choose to complete it using either PowerShell or Python.
General notes: Variables for the program should be named according to the data they
represent. Comments need to be entered so that anyone who looks at the code can
understand what is happening – what the script as a whole accomplishes, and what individual
lines/sections of the code address. Remember to keep the program as simple as possible, and
add complexity if desired only after the core program works.
TASK 1: Merging content from multiple files into one file
Write a script named Project_yourStudentNum_Task1, that merges content from a number
of text files into a new text file named mergedContent.txt.
Download text-files.zip from eConestoga, from the Project module. The example text files to
merge are in this folder.
Your code is to:
• Define an array or a list with names of the text files to be merged.
• Iterate (loop) through the list, read the data from the files and append it to
mergedContent.txt file. The mergedContent.txt file is to be created by your code (ie. it
is not a pre-existing file).
• When appending the content from each file it should start on a new line.
• Make sure to close all the files at the end (if applicable, depending on which language
you choose to use).
TASK 2: Creating a simple calculator
Write a script named Project_yourStudentNum_Task2, that asks user to provide two
numbers and to choose what he/she wants to do with them: add, subtract, multiply or divide
them, and then displays the result of the operation on the screen. See the screen shots below
in regards to the required program output.
Your script is to:
• Define functions add(), subtract(), multiply() and divide(). Each function is to:
o
o
o
o
Accept two parameters: two numbers
Do its respective calculation with the two numbers passed in
Round the result to 2 decimal places
Return the result of the calculation
• The main section of the script is to:
o Ask the user to choose an operation (out of the 4 covered by the functions).
Values 1, 2, 3, or 4 are valid. If any other input is given, “Invalid Input” message
is displayed, and the loop continues until user selects a valid option.
o After user enters a valid input for an operation, prompt him/her to enter two
numbers.
▪ Both integer and decimal numbers are valid input here.
▪ Cast user’s input for the numbers to the appropriate number data type
▪ Add a try…except block to handle the exception raised in case the user
enters a string instead of a number (in which case the attempt to cast the
input to a number data type will result in an error).
The exception should be handled as follows:
• Display a message to the user that the program expects numerical
values and
• Exit the program (hint: use break statement).
o Execute the selected calculation by calling the respective function; use an if...elif
block for this part.
o Display the result, as per the example program output.
•
To see how the program should work when executed refer to the examples of the
program output, below.
Figure 1: “Invalid Value” message is displayed after the user entered ‘hi’ as operation choice, and the
same question (“Enter your choice…”) is printed again – until a valid input is provided. After entering a
correct choice, user is asked to enter two numbers. When an invalid value is provided for the 2nd
number, a message is displayed that informs the user that the program expects numerical values, and
after that the program ends.
Figure 2: The user selected one of the four operations and provided two numbers as instructed by the
program, and the program displayed the result.
Submission
You are required to submit the following to the Project Dropbox on eConestoga:
1. Your 2 script files:
▪ Project_yourStudentNum_Task1
▪ Project_yourStudentNum_Task2
2. A URL to a screen recording of you doing a walk-thru on your code by reflecting what
each of the scripts does and what individual lines and sections of the code are
accomplishing.
Notes re: the recording:
▪ Create a single, up to 10 minutes long video.
▪ Upload the recording to YouTube.
▪ Make sure the video is made public so that I can view it.
▪ Submit the URL to your video to the Assignment 4 Dropbox on eConestoga.
Assessment
•
•
•
•
•
You will be graded by the rubric found on eConestoga, under Course Tools -> Rubrics.
This is an independent work assignment. You may not work with others while working
on this assignment or collaborate or share your answers, code or anything else.
You may use the book, and the course material found on eConestoga.
You may use the web, for generalized Python coding practices research.
You may not use code copied from other people, the web or any other source.