帮做Data Focused Python作业、Python语言程序代写、代写代做Python编程留学生作业
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了帮做Data Focused Python作业、Python语言程序代写、代写代做Python编程留学生作业,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4230字,纯文字阅读大概需要7分钟。
内容图文
![帮做Data Focused Python作业、Python语言程序代写、代写代做Python编程留学生作业](/upload/InfoBanner/zyjiaocheng/857/0a6725ea31f54193974bb1fd14dea582.jpg)
Data Focused Python, 2018 K1
Homework 5
Due At 11:59 pm Monday, Oct. 1
1.(100 points) Regular Expressions
The expenses.txt file provides good examples for regular expression matching.
a.Create a Python script file named expense_regex.py. In this script, define an empty list named records, then read the lines from expenses.txt and append each line (excluding its terminating newline character) to the records list.
Add this code for displaying lines from records that match a trivial regular expression:
import re
# 1a
pat = r'D'
for line in records:
if re.search(pat, line) != None:
print(line)
Confirm that the output is lines from records that contain a D somewhere.
b.Comment out the pattern for part 1a, and add a new pattern for part 1b, like this:
# 1a
# pat = r'D'
# 1b
pat = r'\''
Confirm that the output is lines from records that contain a single quote (') character
somewhere.
c.Comment out the pattern for part 1b, and add a new pattern for part 1c that will display lines from records that contain a double quote (") character somewhere. Run the module to test.
d.Continue in this manner of commenting out the previous part’s pattern and adding a new pattern. Add a pattern that will display lines that begin with 7; run the module to test.
e.Add a pattern that will display lines that end with an r or a t; test.
f.Add a pattern that will display lines that contain a literal period (.) character; test.
g.Display lines that contain an r followed later by a g. (The r and the g do not need to be consecutive characters.)
h.Display lines that contain two consecutive uppercase letters (for example, AA, DF, LM, YW, …).
i.Display lines that contain a comma (,) character.
j.Display lines that contain three or more comma characters (not necessarily consecutive).
k.Display lines that do not contain any v, w, x, y, or z characters.
l.Display lines that contain money amounts between 10.00 and 99.99. Hint: What must the first character be? What must the second character be? What must the third character be? And so forth. The pattern '[10.00-99.99]' will not work, because one pair of square brackets only matches a single character, not a range of multiple characters. For example, '[aaaaaaa]' matches one a, not a sequence of seven a characters. The pattern '[abcabcabcaaabbbaaaccccccc]' matches the same thing as the pattern '[abc]' or the pattern '[acb]' or '[bac]' and so forth: that is, either an a or a b or a c. The regular expression pattern '[AA-ZZ]' matches either an A, or a character in the range from A through Z, or a Z; that is, the pattern is equivalent to '[A-Z]'.
m.Display lines that contain exactly three commas.
n.Display lines that contain a ( character (that is, an open parenthesis character).
o.Display lines that describe meals costing at least 100.00.
p.Display lines that have an expense category that is exactly four characters wide (your pattern should work even if more lines are added to the file, with new categories that have not yet been defined).
q.Display lines for expenses that occurred in March.
r.Display lines that contain an a, followed by a b, followed by a c (perhaps with other characters between the a and the b and the c).
s.Display lines that contain some sequence of two characters, followed later by that same sequence of two characters, followed later by that same sequence of two characters again. That is, each matched line should contain at least one sequence of two characters at least three times.
http://www.daixie0.com/contents/3/1745.html
t.Display lines in which the expense description contains a both a lowercase a and a decimal digit character between 0 and 9, in either order. That is, the a might appear before the digit, or the a might appear after the digit.
u.Display lines that contain no uppercase letters.
v.Display lines that contain a d character, possibly followed by one optional character, followed by an i character. (Matches would include words like diver, doily, drip, diplomat, etc.)
REMEMBER to put both authors’ names into your source code file. Put your expense_regex.py file into a .zip archive and upload to the course web site.
因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
微信:codinghelp
内容总结
以上是互联网集市为您收集整理的帮做Data Focused Python作业、Python语言程序代写、代写代做Python编程留学生作业全部内容,希望文章能够帮你解决帮做Data Focused Python作业、Python语言程序代写、代写代做Python编程留学生作业所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。