Professor Kriste Krstovski Fall编程作业代写、代做Python code程序作业、代写Python code程序设计作业

Professor Kriste Krstovski Fall编程作业代写、代做Python code程序作业、代写Python code程序设计作业
Professor Kriste Krstovski Fall 2018
B9122 Computing for Business Research
Homework Assignment #1
Due: 11:59 pm, September 24th (Monday), 2018
? Upload your solutions to the Canvas system before the deadline (email Aion [email protected]
or Selim [email protected] if that does not work). If you are uploading your solutions in
separate files please package them into a single zip file (e.g., using Winzip) and name it:
b9122_hw1_sol_first_last_name.zip where you replace “first_last_name” with your full name.
? Homework assignments are to be done individually, and without the use of anyone else’s solutions.
You may obtain tips/tutorials from the internet, but soliciting help from others online or in person
is not permitted. Cheating will strictly not be tolerated.
Question 1 (10 points)
Consider a Python string named word. Write a python code to replace all occurrences of character ‘a’
with character ‘i’ in word. As an example, here is one possible declaration of word:
word = ‘aeiou’
Question 2 (20 points)
Write a Python code which takes a number as an input, e.g., ‘n’, and prints the following result, e.g.,
1*1=1
1*2=2
1*3=3
2*1=2
2*2=4
2*3=6
3*1=3
3*2=6
3*3=9
The code should work on any positive integer (i.e. n>1).
Question 3 (25 points)
Write a Python code which takes a sentence as an input, e.g.,
sentence = ‘this is a long sentence’,
and returns the list of words, sorted in the order by word length, e.g.,
[(1, ‘a’), (2, ‘is’), (4, ‘long’), (4, ‘this’), (8, ‘sentence’)].
You may use list.sort() or sorted() functions for sorting.
Instructor: Dan Mechanic Fall 2017
B9122 Computing for Business Research
Homework Assignment #6
Due: 8 pm, Wednesday, November 29, 2017.
? Commit and push iterative changes to your web crawler screen.py program in your git repository,
in place. Also upload your web crawler screen.py program to canvas by the deadline.
? Homework assignments are to be done individually.
? Run a git pull to get all the latest code from your git repository.
Formatted Printing in Python
Just a short note about format.
Using the format:
{:0.1f}
...means a minimum of zero padding and a maximum of 1 number after the decimal point:
print('{:0.1f}'.format(4.1315))
4.1
print('{:0.4f}'.format(4.1315))
4.1315
print('{:10.1f}'.format(4.1315))
4.1
print('{:10.4f}'.format(4.1315))
4.1315
...which can also be written as:
print('%0.1f' % 4.1315)
4.1
print('%0.4f' % 4.1315)
4.1315
print('%10.1f' % 4.1315)
4.1
print('%10.4f' % 4.1315)
4.1315
See https://docs.python.org/3.5/library/string.html#formatexamples for more information on formatting
strings.
Python Dictionaries
Observe:
1
Question 4 (25 points)
Write a Python code which takes a file as an input, e.g.,
fh = open(‘question4.txt’)
txt = fh.read(),
You may assume that the file contains only words separated by a single space. Convert all letters in
‘question4.txt’ to lowercase, count the number of occurrences for each word, and sort the list of
words by decreasing order of the number of occurrences. Output the top 5 most frequent words, e.g.:
9 the
7 i
7 and
6 my
5 of
Run your code on the provided file (question4.txt). Hint: Use dictionary structure to efficiently count
the number of occurrences of words.
Question 5 (20 points)
a) Write a regular expression that matches dates written in the following format:
yyyy-mm-dd.
b) Write a regular expression that matches either five or nine-digit zip codes in the following format:
xxxxx or xxxxxx-xxxx
where x represents any number between 0 and 9.
c) Write a regular expression that matches an email address in the following format:
[email protected]
Question 6 [Optional] (10 points)
Write a Python code that would print the indices of the elements in two numpy arrays that have the same
value, e.g., for the following two arrays:
a=np.array([1, 2, 3, 2]) and b=np.array([2,2,2,2]),
the code would return [1,3].
http://www.6daixie.com/contents/3/1792.html

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/javahelp89/p/9690933.html