自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 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 1896

原创 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 766

原创 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 969

原创 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 128

原创 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 979

原创 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 450

原创 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 393

原创 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 232

原创 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 399

原创 coursesa课程 Python 3 programming course_2_assessment_3 字典练习题

asds

2020-04-07 17:25:59 1190

原创 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 186

原创 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 216

原创 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 173

原创 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 222

原创 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 295

原创 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 492

原创 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 380

原创 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 531

原创 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 129

原创 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 164

原创 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 340

原创 Python 倒序输出字符串

##题目: A palindrome is a phrase that, if reversed, would read the exact same. Write code that checks if p_phrase is a palindrome by reversing it and then checking if the reversed version is equal to th...

2020-04-04 19:37:48 627

原创 if sent was the string “height and ewok wonder” then the resulting acronym should be “HE. EW. WO”

题目:Write code that uses the string stored in sent and creates an acronym which is assigned to the variable acro. The first two letters of each word should be used, each letter in the acronym should be...

2020-04-04 19:29:31 660

原创 uses the string stored in org and creates an acronym which is assigned to the variable acro

题目: Write code that uses the string stored in org and creates an acronym which is assigned to the variable acro. Only the first letter of each word should be used, each letter in the acronym should be...

2020-04-04 19:09:48 647

原创 course_1_assessment_12

course_1_assessment_12题目:Below are a set of scores that students have received in the past semester. Write code to determine how many are 90 or above and assign that result to the value a_scores.sco...

2020-04-04 19:06:18 433

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除