CE 392C - Transportation Network AnalysisFall 2023Homework 1Due on Canvas at 11:59 PM, Friday, September 8. Submit two files: a PDF containing your solutions to the textbook problems, and a ZIP file containing your code for the Python problems. More details below on how to submit the Python code. Textbook questionsMake sure you are using version 0.91 of the text. Chapter 2: Exercises 11, 12, 13 Chapter 3: Exercises 1 and 2 Chapter 4: Exercise 4 Python questionsNote: In Python, spacing and indentation is important and code will not run correctly unless a consistent indentation style is used. I use three spaces to indent. Most text editors and IDEs can be set to use this as a default when you press the<TAB> key.
Question 1: MultiplicationDownload and unzip these files to a convenient directory. You will be editing three files in this
assignment: At a command prompt, type Running multiplication test: tests/q1/1-regular.test......not yet attempted Running multiplication test: tests/q1/2-negative.test......not yet attempted Running multiplication test: tests/q1/3-zero.test......not yet attempted Running multiplication test: tests/q1/4-float.test......not yet attempted Running data structures test: tests/q2/1-3students.test......not yet attempted Running data structures test: tests/q2/2-6students.test......not yet attempted Running classes test: tests/q3/1-3students.test......not yet attempted Running classes test: tests/q3/2-6students.test......not yet attempted SCORES: Q1: Multiplication 0/4 Q2: Data structures 0/6 Q3: Classes 0/2 ---------- TOTAL: 0/12 This is an unofficial score, please submit code on Canvas for final scoring. The score is reported as 0, since you have not yet attempted any of the questions. Open def calculateProduct(factor1, factor2): # *** YOUR CODE HERE *** # Replace the following statement with your code for calculating and returning the product of factor1 and factor2 raise utils.NotYetAttemptedException Delete the line Running multiplication test: tests/q1/1-regular.test......pass Running multiplication test: tests/q1/2-negative.test......pass Running multiplication test: tests/q1/3-zero.test......pass Running multiplication test: tests/q1/4-float.test......pass Running data structures test: tests/q2/1-3students.test......not yet attempted Running data structures test: tests/q2/2-6students.test......not yet attempted Running classes test: tests/q3/1-3students.test......not yet attempted Running classes test: tests/q3/2-6students.test......not yet attempted SCORES: Q1: Multiplication 4/4 Q2: Data structures 0/6 Q3: Classes 0/2 ---------- TOTAL: 4/12 This is an unofficial score, please submit code on Canvas for final scoring. Your code passed all of the tests for the multiplication question, so you have a score of 4/4 for the first question. You can examine
the test instances used in the Question 2: Built-in data structuresIn the online Python tutorial, you should have learned about lists, tuples, and dictionaries. These are very useful built-in data structures in Python that we will be using throughout the course. Question 2 involves lists and tuples, and can be solved only using these. If you are not comfortable with dictionaries, you will find it instructive to solve the problem a second time, converting the tuples into a dictionary and operating with the grade records as a dictionary. If done correctly, both implementations will pass the autograding script with a perfect score. Open The Question 3: Python classesIn the online Python tutorial, you should have learned the basics of how Python classes operate. The Open At the bottom of this file is the Submission instructionsYour answers to the textbook questions should be placed in a single PDF file and uploaded to Canvas. Please verify that your file uploaded correctly, that the pages are in the right order, etc. For the Python questions, submit a single ZIP file and upload to Canvas. Please follow these instructions:
unzip hw1.zip diff -bur master/ hw1/ # master is the original version; this shows me your changes cd hw1 cat README.txt python3 grader.py cd .. rm -r hw1 hw1.zip Return to CE 392C. |