这是一篇来自美国的关于商业数据通信的Python代写
MIS 543 – Business Data Communications & Networking Lab 2: Get Started with Python
Lab 2: Get Started with Python
In this assignment, you will learn to use the basics in Python Programming. You will apply the basic concepts in Python to write simple programs that will get you started with Python Programming. After this assignment, you should be able to
• Work with conditional statements and loops
• Work with File objects and file methods
• Get started with functions and modules
Part A
In this part, you will develop a simple python program that will accept numbers from user and store them in a file.
What to do
You will turn in a simple python program input_numbers.py that satisfies the following requirements:
1. It should accept an integer from the user.
2. If user inputs any invalid datatypes (other than integer) display error message and prompt for
input again.
3. Write the number to a new line in a file named “numbers.txt” in the same folder as
input_numbers.py.
4. Ask if the user wants to continue- Yes/No.
5. If user inputs ‘Yes’, repeat steps-1 to 4 until user inputs ‘No’.
What to Turn In
For this part, turn in input_numbers.py to D2L. Grading
0.5 pt
Correct Submission
Submitting substantial code that shows a good effort attempting all aspects/functionality of the assignment.
0.5 pt
Handle Invalid datatypes
Your code should accept only integers and prompt for user input if invalid datatypes are entered.
0.5 pt
End the program when user inputs ‘No’
The program should keep accepting numbers from user until ‘No’ is entered.
0.5 pt
Store numbers to file
Your code should store all the input numbers to the file ‘numbers.txt’
MIS 543 – Business Data Communications & Networking Lab 2: Get Started with Python
Part B
In this part, you will develop a python program that can parse a given url to obtain the domain, path and port number, and write them to a file. The starter code url_parse_starter.py is provided for this part. You can modify it and submit the required url_parse.py.
What to do
You will turn in a python program url_parse.py that satisfies the following requirements:
1. The program will take two command line parameters- the url that has to be parsed and the text
filename where the results are stored. Examples of command are:
2. Call a function url_parser() that will do the following:
a. The funtion argument must be the url and filename obtained from command line
arguments
b. Parse the url to obtain the domain name, path and port number. If the port number is
‘None’ then the port number must be recorded as ’80’
c. Write the url, its domain name, path and port number to the file obtained from second
command line argument
python url_parse.py http://www.arizona.edu/index.html url_parse.txt python url_parse.py http://www.eller.arizona.edu/index.html url_parse.txt
python url_parse.py http://www.u.arizona.edu/~weichen/index.html file_url.txt
For example, if the URL is “http://www.eller.arizona.edu:2016/index.html”, the following should be written to the file (a single space between the colon and the value):
url: http://www.eller.arizona.edu:2016/index.html host: www.eller.arizona.edu
path: /index.html
port: 2016
What to Turn In
For this part, turn in url_parse.py to D2L. Grading
0.5 pt
Correct Submission
Submitting substantial code that shows a good effort attempting all aspects/functionality of the assignment- able to parse the url.
1.5 pt
Write to file in given format
Your code should store the url, its domain, path and port to a file in the given format
1 pt
Default port number
If the port number is ‘None’, your code should assign the port number as ’80’.