姓名: 学号:
请注意以下几点:
请将你的程序调试完成后,复制粘贴到对应题目的对话框里面,然后点击末尾的生成作业文件按钮,会自动生成作业文件。请记得填写姓名和学号,生成的文件名会包含你的学号。
请使用这些浏览器来打开作业并生成作业文件:Chrome,Firefox,任何其他的Chrome内核浏览器(如QQ浏览器,360安全浏览器,搜狗浏览器,百度浏览器等等)。Microsoft Edge和Mac笔记本的Safari也支持。请注意:老版IE浏览器不支持。 如果你不能成功生成作业文件,请换一个浏览器尝试。
最后请将生成的作业文件上传到上财教学网的Canvas对应的作业提交。请注意每次作业的截止日期时间,逾期无法提交,迟交的作业扣一半的分数。
如果你想修改你的作业,请不要修改生成的txt文件。请重新填写表单然后重新生成txt文件。不要对生成的txt文件做任何操作(修改内容,修改学号,修改姓名)。
Write a program to operate a sentence below.
11My email address is wang.lu@mail.shufe.edu.cn It was created on 1st Sept. 2017 Fridaycount the number of letter e in this sentence.
show the host of the email address mail.shufe.edu.cn by using find()
show the time in a list ['1st', 'Sept.', '2017', 'Friday'] by using find() and split()
Write a program to create a dictionary that contains the following information.
| Name | Favorite Language | Age |
|---|---|---|
| Mike | Java | 20 |
| Tracy | C++ | 21 |
| Jack | Python | 19 |
Use for to print the information such that the names are in alphabetical order. The following shows an execution of the program.
31Jack Python 192Mike Java 203Tracy C++ 21Write a program to show the complete multiplication table (九九乘法表). The following shows an execution of the program. (Hint: please use nested for .)
911*1=1 22*1=2 2*2=4 33*1=3 3*2=6 3*3=9 44*1=4 4*2=8 4*3=12 4*4=16 55*1=5 5*2=10 5*3=15 5*4=20 5*5=25 66*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36 77*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49 88*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64 99*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81Write a program that creates a function fib(n) to show the Fibonacci sequence. The length of the sequence is n. Fibonacci sequence is a sequence such that every number after the first two is the sum of the two preceding ones. For example,
21>>>fib(8)21 1 2 3 5 8 13 21(Hint: you can start with the following incomplete program. )
141def fib(n):2 if n==1:3 print(1)4 elif n==2:5 print(1,1)6 elif n>2:7 print(1,1,end=" ")8 count = 09 n1 = 110 n2 = 111 while count < n-2:12 nth = n1 + n213 print(nth,end=" ")14 # add your program here to complete itDesign a function noDuplicates(x) to receive a string and return a new string in which there is no duplicates. The following shows the execution of the function.
41x="aaaaaaaaaa"2print(noDuplicates(x))3#output4a41x="abbcdcefedcba"2print(noDuplicates(x))3#output4abcdefGiven an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. The following shows an execution of the function. (Hint: create two functions: one is for finding all the triplets giving the sum of zero, and the other is for deleting duplicates.)
41y=[-1,0,1,2,-1,-4,6,-2]2print(threeSum(y))3#output4[[-1, 0, 1], [-1, -1, 2], [-2, 0, 2], [-4, -2, 6]]