Question
PYTHON language 1 Introduction This assignment explores parsing strings and working with files in Python. Students shall work individually to create a program that scans
PYTHON language
1 Introduction This assignment explores parsing strings and working with files in Python. Students shall work individually to create a program that scans a Java source file for unbalanced parentheses, brackets, and braces. After completing this exercise, students will:
Know how to interact with the terminal window and gain familiarity with essential Unix commands we will use throughout the semester
Create text files and folders on a remote file system through text commands and output redirection
Develop a Python 3 application in a Unix environment
Transfer the completed Python script to a remote server through a secure shell
Demonstrate competence opening and saving files on a file system through source code
2 Requirements
Each student shall generate a single Python source file named balanced.py. This Python script shall open the Java source file specified in the command line argument provided at run-time, strip it of comments and save the comment-free version in a new file. The Python program shall then verify the Java source file meets the rudimentary syntax requirements for balanced parentheses, brackets, and braces. That is, every opening punctuation requires matching closing punctuation. A left curly-bracket requires a right curly-bracket for balance. For this assignment, the symbols that require balancing are: {, (, and [
// Student Name:
// CS320 Programming Languages
public class Driver {
Driver(String [] args){
if( args.length > 0 )
System.out.println(args[0]);
}
public static void main(String [] args){
// Ignore the { in the comment
new Driver(args);
System.out.println("Complete.({[");
}
}
Figure 1: A valid, balanced Java input file.
// Student Name:
// CS320 Programming Languages
public class Driver {
Driver(String [] args){
if( args.length > 0 )
System.out.println(args[0]);
}
Figure 2: An unbalanced Java input file, for it misses a closing curly-bracket
2.1 Comments The delivered solution shall ignore the symbols if they appear in a comment. Recall that you may comment out a line of code by either using the // symbol sequence or by starting a older, c-style multi-line comment using /* and */. Before balancing the source file, the students Python script shall strip the specified input Java file of all its comments. It shall then save the comment-free version of the input file using the same name as the input file but with .nocom as the file extension.
2.2 Quotations Developers frequently use these symbols in strings to display to the user. For purposes of balancing, the students solution must ignore opening and closing symbols if they appear inside a string quotation.
2.3 Data Structures The Stack abstract data type helps solve these type of balancing problems. Python lists support key stack operations, and they are built-in to the language. Students should use the list based stack in their solution. Students may use any other built-in data structures they require in their design.
2.4 File System Each student shall connect to the edoras university server using the class account information provided by the class instructor. Students must use the exact class account assigned to them for this class. Other courses issue edoras accounts, but those accounts remain inaccessible to the instructor of this class. Students may connect to this server through the ssh program or any other shell interface (i.e. XWin-32 or PuTTy). Students will need to transfer any local work to this server during the turn-in process, so understanding the difference between a secure shell and the secure copy operation will become significant. Shell scripts developed directly on the Edoras server may skip the secure copy process. Once connected to the university server, students must create the appropriate directories and data files used by the program. Using the appropriate Unix commands, create a new directory named assign in the accounts home directory. Recall Unix folder names are case-sensitive. Then, inside this new directory, create a sub-directory named lab1.
3 Delivery
After the delivery time listed on this prompt, an automated script will collect and copy the contents of every students assign/lab1 directory to a private folder for test and grading. Consequently, all required files must exist in the specified location. The directory and file names must precisely match those in the requirements. In addition to the electronic submission, students must submit a physical printout of their source code at the start of class on the due date. Students may freely develop the application on their personal computer or other machines, but they must copy their work to the Edoras server prior to delivery. Additionally, the script must run on the remote server. Testing remains vital.
4 Grading
Students earn points on this assignment for meeting performance requirements. The following table identifies the major point categories and their associated values, but note that the grading team may add additional points to an assignment for exceptional work. Conversely, grading personnel may elect to deduct additional points for other errors not specified on this prompt.
| Point Value | Requirement File System: balanced.py exists on the Edoras server in the correct location with valid student name information Python Application: Reads in the command- line argument when launched Python Application: Strips comments from source file and saves in .nocom Python Application: Ignores symbols inside a string literal Python Application: Correctly identifies bal- anced source files and displays the result to the user Python Application: Coding style (e.g., variable names, flow, use of globals, no magic numbers, etc ...) Figure 3: The Grading Rubric | Point Value | Requirement File System: balanced.py exists on the Edoras server in the correct location with valid student name information Python Application: Reads in the command- line argument when launched Python Application: Strips comments from source file and saves in .nocom Python Application: Ignores symbols inside a string literal Python Application: Correctly identifies bal- anced source files and displays the result to the user Python Application: Coding style (e.g., variable names, flow, use of globals, no magic numbers, etc ...) Figure 3: The Grading Rubric
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started