当前位置:网站首页>Lesson 016: sequence | after class test questions and answers
Lesson 016: sequence | after class test questions and answers
2022-06-22 21:35:00 【ChaseTimLee】
Test questions :
0. We follow the list 、 The common characteristics of tuples and strings , Call them three together why ?
Sequence , Because they have the following in common :
1) You can get every element by index
2) The default index value is always from 0 Start ( Of course flexible Python Negative index is also supported )
3) You can get a set of elements in a range by sharding
4) There are many operators in common ( Repeat operator 、 Splicing operators 、 Membership operators )
1. What do you use respectively BIF, You can convert an iteratable object to a list 、 Tuples and strings ?
list([iterable]) Converting an iteratable object to a list
tuple([iterable]) Convert iteratable objects to tuples
str(obj) Convert an object to a string
>>> temp = 'I love FishC.com!'
>>> list(temp)
['I', ' ', 'l', 'o', 'v', 'e', ' ', 'F', 'i', 's', 'h', 'C', '.', 'c', 'o', 'm', '!']
2. You can also retell “ iteration ” The concept of ?
Iteration , It's an activity that repeats the feedback process , Its purpose is usually to approach and reach the desired goal or result . Every repetition of a process is called a “ iteration ”, The result of each iteration will be used as the initial value of the next iteration .
3. You think call max(‘I love FishC.com’) What value will be returned ? Why? ?
Returns the :‘v’, Because the string in the computer is in the form of ASCII In the form of code (ASCII Comparison table :http://bbs.fishc.com/thread-41199-1-1.html), Parameters in ASCII The largest code value is ’v’ Corresponding 118.
4. Ah ah , The little kids are so naughty now , Naughty children in the neighborhood , Draw a pattern of the code that the little turtle just wrote , Please restore the code of fish oil ~~

name = input(' Please enter the user name to be found :')
score = [[' Get lost ', 85], [' Night ', 80], [' Pudding ', 65], [' Froude doll ', 95], [' Yijing ', 90]]
IsFind = False
for each in score:
if name in each:
print(name + ' The score for is :', each[1])
IsFind = True
break
if IsFind == False:
print(' The data found does not exist !')
use one's hands :
0. Guess min() This BIF Implementation process
def min(x):
least = x[0]
for each in x:
if each < least:
least = each
return least
print(min('123456789'))
1. In the video we say sum() This BIF There's a flaw , If there is a string type in the parameter, an error will be reported , Please write a new implementation , Automatically “ ignore ” The string in the parameter and return the correct result
def sum(x):
result = 0
for each in x:
if (type(each) == int) or (type(each) == float):
result += each
else:
continue
return result
print(sum([1, 2.1, 2.3, 'a', '1', True]))
边栏推荐
- How swiftui simulates the animation effect of view illumination increase
- 牛客 52次月赛 C 说谎的机器 (区间赋值操作由O(n^2)转为O(n)的复杂度)
- 2022危险化学品经营单位主要负责人上岗证题库及模拟考试
- [513. find the value in the lower left corner of the tree]
- List of outstanding talents: no crystal vibration, one drag, eight burn and upgrade [chapter]
- 513. 找树左下角的值 / 剑指 Offer II 091. 粉刷房子
- [redis] cluster and common errors
- 85- have you learned any of these SQL tuning tips?
- 杰理之硬件上 DACL 输出,DAC 输出左右声道的声音【篇】
- ACM. HJ45 名字的漂亮度 ●●
猜你喜欢
![[redis]发布与订阅](/img/50/0c2fbbb8f56fccdd3222b77efdd723.png)
[redis]发布与订阅

Fluent system architecture
![[redis] three new data types](/img/ce/8a048bd36b21bfa562143dd2e47131.png)
[redis] three new data types

万字长文 | 使用 RBAC 限制对 Kubernetes 资源的访问

ICML2022 | 利用虚拟节点促进图结构学习
![[206. reverse linked list]](/img/c8/d83655395379a512c8b67a82dc4cae.png)
[206. reverse linked list]

第019讲:函数:我的地盘听我的 | 课后测试题及答案

CVPR2022 | 海德堡大学《深度视觉相似性与度量学习》教程

2022 chemical automation control instrument examination exercises and online simulation examination

分享insert into select遇到的死锁问题(项目实战)
随机推荐
es 按条件查询数据总条数
Apple Objective-C source code
DACL output on Jerry's hardware, DAC output sound of left and right channels [chapter]
win10安装.net3.5.docx
[redis]redis persistence
杰理之使用 DP 和 DM 做 IO 按键检测注意点【篇】
杰理之AUX 模式使用 AUX1或者 AUX2通道时,程序会复位问题【篇】
第020讲:函数:内嵌函数和闭包 | 课后测试题及答案
杰理之列免晶振一拖八烧录升级【篇】
数据库总结:mysql在开发过程中常见的问题及优化
TC397 Flash
84- I am on Internet & lt; 52 SQL statement performance optimization strategies & gt; Some views of
快速排序模板 & 注意事项
杰理之在music模式下提示音使用打断模式无法播放的问题【篇】
2022 question bank and simulated examination for work license of main principals of hazardous chemical business units
第027讲:集合:在我的世界里,你就是唯一 | 课后测试题及答案
第014-15讲:字符串 (见小甲鱼新版27讲-32讲)| 课后测试题及答案
Fegin的解析
74- how to remedy the loss of Oracle to MySQL for this kind of SQL optimization?
[redis]发布与订阅