
coursesa (Python 3 programming)
sheeplil
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
coursesa课程 Python 3 programming course_2_assessment_8 sorted练习题
Given the same dictionary, medals, now sort by the medal count. Save the three countries with the highest medal count to the list, top_three.medals = {'Japan':41, 'Russia':56, 'South Korea':21, 'Un...原创 2020-04-12 20:39:20 · 1966 阅读 · 0 评论 -
coursesa课程 Python 3 programming 排序函数sorted的可选参数
sorted(iterable[, key][, reverse])从 iterable 中的项目返回新的排序列表。有两个可选参数,必须指定为关键字参数。key 指定一个参数的函数,用于从每个列表元素中提取比较键:key=str.lower。默认值为 None (直接比较元素)。reverse 是一个布尔值。如果设置为 True,那么列表元素将按照每个比较反转进行排序。You w...原创 2020-04-11 21:00:28 · 833 阅读 · 0 评论 -
coursesa课程 Python 3 programming course_2_assessment_7 多参数函数练习题
Write a function called checkingIfIn that takes three parameters. The first is a required parameter, which should be a string. The second is an optional parameter called direction with a default valu...原创 2020-04-10 22:49:53 · 1052 阅读 · 0 评论 -
coursesa课程 Python 3 programming Anonymous functions with lambda expressions lambda表达式
def f(x): return x - 1print(f)print(type(f))print(f(3))print(lambda x: x-2)print(type(lambda x: x-2))print((lambda x: x-2)(6))原创 2020-04-10 20:22:34 · 175 阅读 · 0 评论 -
course_2_assessment_6
1.Write a function, sublist, that takes in a list of numbers as the parameter. In the function, use a while loop to return a sublist of the input list. The sublist should contain the same values of t...原创 2020-04-09 23:52:40 · 1043 阅读 · 0 评论 -
coursesa课程 Python 3 programming The while Statement
1、Write a while loop that is initialized at 0 and stops at 15. If the counter is an even number, append the counter to a list called eve_numsn = 0eve_nums = list()while n <= 15: if n % 2 =...原创 2020-04-09 14:25:11 · 518 阅读 · 0 评论 -
coursesa课程 Python 3 programming Tuple Assignment with Unpacking
If you remember, the .items() dictionary method produces a sequence of tuples. Keeping this in mind, we have provided you a dictionary called pokemon. For every key value pair, append the key to the ...原创 2020-04-08 21:39:37 · 439 阅读 · 0 评论 -
coursesa课程 Python 3 programming Functions can call other functions 函数调用另一个函数
Write two functions, one called addit and one called mult. addit takes one number as an input and adds 5. mult takes one number as an input, and multiplies that input by whatever is returned by addi...原创 2020-04-08 18:51:03 · 285 阅读 · 0 评论 -
Returning a value from a function
Write a function called decision that takes a string as input, and then checks the number of characters. If it has over 17 characters, return “This is a long string”, if it is shorter or has 17 char...原创 2020-04-07 19:18:11 · 446 阅读 · 0 评论 -
coursesa课程 Python 3 programming course_2_assessment_3 字典练习题
asds原创 2020-04-07 17:25:59 · 1269 阅读 · 0 评论 -
coursesa课程 Python 3 programming When to use a dictionary 什么时候使用字典
When a piece of data consists of a set of properties of a singleitem, a dictionary is often better. You could try to keep trackmentally that the zip code property is at index 2 in a list, butyour...原创 2020-04-07 13:24:14 · 229 阅读 · 0 评论 -
coursesa课程 Python 3 programming Accumulating the Best Key 求字典的最大值和最小值
Create a dictionary called d that keeps track of all the characters in the string placement and notes how many times each character was seen. Then, find the key with the lowest value in this dictiona...原创 2020-04-07 13:18:55 · 275 阅读 · 0 评论 -
coursesa课程 Python 3 programming Accumulating Multiple Results In a Dictionary 统计文件的字母数量
f = open('scarlet.txt', 'r')txt = f.read()# now txt is one long string containing all the charactersx = {} # start with an empty dictionaryfor c in txt: if c not in x: # we have not se...原创 2020-04-06 21:13:02 · 221 阅读 · 0 评论 -
coursesa课程 Python 3 programming Dictionary methods 字典的方法
NoteTechnically, .keys(), .values(), and .items() don’t return actual lists. Like the range function described previously, in python 3 they return objects that produce the items one at a time, rathe...原创 2020-04-06 19:17:05 · 266 阅读 · 0 评论 -
coursesa课程 Python 3 programming 文件中如果单词包含‘p’,就输出那个单词
Challenge: Using the file school_prompt.txt, if the character ‘p’ is in a word, then add the word to a list called p_words.school_prompt = open('school_prompt.txt','r')chars = school_prompt.read()w...原创 2020-04-05 17:34:20 · 338 阅读 · 0 评论 -
coursesa课程 Python 3 programming 输出每一行句子的第三个单词
题目:Using the file school_prompt.txt, assign the third word of every line to a list called threeschool_prompt = open('school_prompt.txt','r')chars = school_prompt.readlines()three = list()for word ...原创 2020-04-05 17:24:16 · 539 阅读 · 0 评论 -
coursesa课程 Python 3 programming 统计文件有多少单词
题目:We have provided a file called emotion_words.txt that contains lines of words that describe emotions. Find the total number of words in the file and assign this value to the variable num_words.emo...原创 2020-04-05 17:11:38 · 426 阅读 · 0 评论 -
coursera课程 python 3 programming/ format的使用
题目:Provided is a list of data about a store’s inventory where each item in the list represents the name of an item, how much is in stock, and how much it costs. Print out each item in the list with th...原创 2020-04-04 20:01:20 · 405 阅读 · 0 评论 -
coursesa Python 3 Reading and Processing a File ,文件的处理和读写
#1. Open the file using with and open.#2. Use .readlines() to get a list of the lines of text in the file.#3. Use a for loop to iterate through the strings in the list, each being one line from the ...原创 2020-04-05 12:43:59 · 205 阅读 · 0 评论 -
coursesa python 3 Writing data to a CSV File,将数据写入CSV格式的文件
First, using .format() makes it really clear what we’re doing when we create the variable row_string. We are making a comma separated set of values; the {} curly braces indicated where to substitute i...原创 2020-04-05 16:28:21 · 174 阅读 · 0 评论 -
coursesa课程 Python 3 programming course_2_assessment_1
题目:The textfile, travel_plans.txt, contains the summer travel plans for someone with some commentary. Find the total number of characters in the file and save to the variable num.travel_plans = open(...原创 2020-04-05 17:05:22 · 591 阅读 · 0 评论