Everyone:
Next week, we will have Exam 02, which will cover scripting in Python with a focus on: data structures, functional programming, and concurrency and parallelism. This reading assignment is meant to prepare you for this exam and is based on the items in Checklist 02.
Because of the exam on Friday, March 8, there will be no homework for the upcoming week.
The focus of this reading is to allow you to review for Exam 02.
The readings for this week are:
This week, the reading is split into two sections: the first part is a short
dredd quiz, while the second part involves four short Python scripts:
translate1.py
, translate2.py
, translate3.py
, and translate4.py
.
To test these scripts, you will need to download the Makefile and test scripts:
$ git checkout master # Make sure we are in master branch $ git pull --rebase # Make sure we are up-to-date with GitLab $ git checkout -b reading07 # Create reading07 branch and check it out $ cd reading07 # Go into reading07 folder # Download Reading 07 Makefile $ curl -LOk https://gitlab.com/nd-cse-20289-sp19/cse-20289-sp19-assignments/raw/master/reading07/Makefile # Download and execute scripts $ make
Record the answers to the following Reading 07 Quiz questions in your
reading07
branch:
Given the following Unix pipelines, write Python scripts (ie.
translateX.py
) that accomplishes the same task.
translate1.py
: grep -Po '9\d*9' /etc/passwd | wc -l
translate2.py
: cat /etc/passwd | cut -d : -f 5 | grep -Po '[Uu]ser' | wc -l
translate3.py
: curl -sLk http://yld.me/raw/Hk1 | cut -d , -f 2 | grep -Eo '^B.*' | sort
translate4.py
: /bin/ls -l /etc | awk '{print $2}' | sort | uniq -c
No credit will be given for simply calling os.system
on the given
pipeline.
Use functional programming, list comprehensions, or [generator expressions] whenever possible.
You do not need to do a literal translation (that is you don't have to replicate each portion of the pipeline); you just need to accomplish the same overall task and emit the same output.
Most of the scripts should only be 5
- 10
lines long.
To submit you work, follow the same process outlined in Reading 01:
$ git checkout master # Make sure we are in master branch $ git pull --rebase # Make sure we are up-to-date with GitLab $ git checkout -b reading07 # Create reading07 branch and check it out $ cd reading07 # Go into reading07 folder $ $EDITOR answers.json # Edit your answers.json file $ ../.scripts/submit.py # Check reading07 quiz Submitting reading07 assignment ... Submitting reading07 quiz ... Q01 0.20 Q02 0.20 Q03 0.20 Q04 0.20 Q05 0.20 Q06 0.20 Q07 0.20 Q08 0.20 Q09 0.20 Q10 0.20 Score 2.00 $ git add answers.json # Add answers.json to staging area $ git commit -m "Reading 07: Quiz" # Commit work $ $EDITOR translate1.py # Edit your translate1.py file $ $EDITOR translate2.py # Edit your translate2.py file $ $EDITOR translate3.py # Edit your translate3.py file $ $EDITOR translate4.py # Edit your translate4.py file $ make # Test all scripts Testing translations ... translate1.py ... Success translate2.py ... Success translate3.py ... Success translate4.py ... Success Score 2.00 $ git add Makefile # Add Makefile to staging area $ git add translate1.py # Add translate1.py to staging area $ git add translate2.py # Add translate2.py to staging area $ git add translate3.py # Add translate3.py to staging area $ git add translate4.py # Add translate4.py to staging area $ git commit -m "Reading 07: Scripts" # Commit work $ git push -u origin reading07 # Push branch to GitLab
Remember to create a merge request and assign the appropriate TA from the Reading 07 TA List.