联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2021-07-08 09:24



A Simple uniq in Python

Due at 10:00pm on Tuesday, 9 July 2019

Write a python script suniq.py that conforms to the following synopsis:

python3 suniq.py [OPTION] … [FILE]

suniq filters adjacent matching lines from FILE (or standard input if a file is not

specified), writing to standard output. It must work exactly like the uniq Linux program

for the functionality they have in common.

With no options, matching lines are merged to the first occurrence.

suniq is to support the following options:

-c prefix lines by the number of occurrences

-d only print duplicate lines, one for each group

-i ignore differences in case when comparing

-u only print unique lines (lines that do not have any adjacent lines that match)

Note that specifying both –u and –d as flags to suniq yields no output, since the

number of lines that match those requirements is the null set. No error message is to be

indicated, the program is simply to return with no output.

If –c is specified, the count is to be written in a field 7 characters wide, followed by a

single space, followed by the line to be printed. You might want to review the

format() method on Python strings to see how you would do this.

1 Starting files

In Canvas, in Files/Projects, you will find a gzipped tar archive named

project2Astart.tgz; this file contains the following files:

input – a file that contains text.

tscript – a bash script file that performs a number of tests of your

suniq.py using input and test*.out; invoking

./tscript

will execute all of the tests using your suniq.py.

test*.out – the correct output files for the tests in tscript.

CIS 212 Project 2A

-2-

2 Checking that your solution works correctly

tscript takes zero or more arguments; if one or more arguments are specified,

tscript will only perform those specific tests; if no arguments are specified, all of the

tests are performed.

The tests that tscript performs are:

a Works correctly with no flags and no filename.

b Works with –i flag and file specified as an argument.

c Works with –d flag and file specified as an argument.

d Works with –u flag and no filename.

e Works with –ci flags and file specified as an argument.

f Works with –cd flags and file specified as an argument.

g Works with –cu flags and file specified as an argument.

h Works with –du flags and file specified as an argument.

i Works with –icd flags and file specified as an argument.

j Works with –icu flags and file specified as an argument.

k Works with –i –c -d flags and file specified as an argument.

l Reports illegal flag on stderr and halts the program.

For each test, tscript prints out “Starting test <letter>”, where

<letter> is one of {a, b, c, d, e, f, g, h, i, j, k, l}; it then prints

a 1-line description of what it is testing; it then prints the actual command line that it is

executing; finally, it prints “Stopping test <letter>”.

If there is any output between the actual command line and the Stopping line for any

test except test l, that test has failed.

3 Submission1

You will email your solutions electronically by attaching a gzipped tar archive2 to an

email addressed to jsventek@uoregon.edu with the Subject line: Project 2A submission.

Your TGZ archive should be named <duckid>-project2A.tgz, where <duckid> is

your “duckid”. It should contain your file suniq.py; it should also contain a file named

report.txt; this file should contain your name, duckid, the names of any classmates

who helped you and the type of help they provided, and the current state of your

solution.


1 A 50% penalty will be assessed if you do not follow these submission instructions.

2 See section 7 of Canvas/Files/Projects/P1Handout.pdf for instructions if you do not remember how to

create a gzipped tar archive. Obviously, the filenames used for this project will be different.

CIS 212 Project 2A

-1-

Grading Rubric

Your submission will be marked on a 50 point scale. Substantial emphasis is placed

upon WORKING submissions, and you will note that a large fraction of the points are

reserved for this aspect. It is to your advantage to ensure that whatever you submit

compiles, links, and runs correctly. The information returned to you will indicate the

number of points awarded for the submission.

You must be sure that your code works correctly on the virtual machine under

VirtualBox, regardless of which platform you use for development and testing. Leave

enough time in your development to fully test on the virtual machine before

submission.

The marking scheme is as follows:

Points Description

5 Your report – honestly describes the state of your submission

Your suniq.py passes test b.

Your suniq.py passes test c.

Your suniq.py passes test d.

Your suniq.py passes test e.

Your suniq.py passes test f.

Your suniq.py passes test g.

Your suniq.py passes test h.

Your suniq.py passes test i.

Your suniq.py passes test j.

Your suniq.py passes test k.

Your suniq.py passes test l.

Appropriate test for __name__

Matching logic disjoint from main()

Appropriate function annotations

Note that:

Your report needs to be honest. Stating that everything works and then finding

that it doesn’t is offensive. The 5 points associated with the report are probably

the easiest 5 points you will ever earn as long as you are honest.



版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp