USYD悉尼大学INFO1110 Oral Exam口语考试复习资料

INFO1110 Oral Exam考试复习资料


前言

(可能打开出现404或者其他非正常界面。每次更新更改博客内容,系统会自动审查文章,最多30分钟就好)
下面内容来自ED,Week12。以笔记的方式去讲解,如有错误及时联系我及时更正。蓝色字体是扩展链接,对应的资料讲解。标注ed的部分需要登录Unikey打开,如有失效链接可以留言。
祝大家考试加油!


Review :

1. Iterator vs Iterable

iterator: stream of data
iterable: sequence that you can iterate through
讲解: iterator中文意思为迭代器,表示数据流的对象。iterable中文意识是可迭代,一个能够一次返回其成员的对象

资料链接1: iterator 和 iterable的关系
资料链接2: iterator 和 iterable的解释


2.True or False: local variables only exist within the scope of a function

def function():
    a = 5 #local variable 
print(a) #NameError

Answer: True

讲解: 标题意思为局部变量仅存在于函数范围内,判断是否正确。首先我们要了解什么是Local variable.中文意思为局部变量,在函数体内或局部范围内声明的变量称为局部变量。
上面程序中的a=5就是local variable,在自定义函数范围内运行,如果跳出函数,运行时就会报错为’NameError: name ‘a’ is not defined‘。

local variable 解释: local variable 讲解


3.What is a pure function (week 5 lab sheet)

function with no side effect

讲解: 问什么是pure function,中文意思为纯函数,一个纯粹的功能不会产生副作用。

pure function解释: pure function 的解释
解释2: pure function


4.What are side effects of a function( week 5 lab sheet)

modifying data that are passed in or global variables (use global)

a = 5
def function():
    print(a) #can read global variable 
    
    #modify global variable
    global a
    a += 1

解释: 问题问功能的副作用是什么(没必要记住中文什么意思,中文只是辅助记忆,主要还得是英文)?修改传入的数据或全局变量(使用全局)

很细致的讲解side effects of a function: side effects链接
Side Effects讲解: Side Effects
Side Effects in Python: Side Effects in Python
ED课件讲解: week5lab_5.0_part4 (登录ed后能看见)


5.What is initializing

assigning value to a variable

解释: 什么是初始化,给变量赋值。(可能__init__就是初始化,下面链接里有详细资料)。

Initializing variable in python: Initializing


6.What is declaring a variable

creating the variable

a = True
b = False

a and b -> True and False -> False
a or b -> True or False -> True
a and b or a -> True and False or True -> False or True -> True
a or b or c -> True or False or ? -> True or ? -> True because of short circuit
a and b or c -> False or c -> NameError
a and b and c -> False and c ->  False because of short circuit
  1. ()
  2. not
  3. and
  4. or

解释: 什么是变量声明,就是创建变量。a为True,b为False。 如果有and表示都正确,运行,遇到false整个条件判断为false。or 就是两者有一个为true就可以运行。

declearing variable: Python Variable
python variable declaration: variable


7.What is the difference between == and is

is : always compare the memory address
== : values unless you’re dealing with object
"hello" == "hello"

解释: 问==和is在程序里的区别。is是判断两者是否引用同一个对象(引用地址),==是判断两者的值是否相等。

is ==用法: 两者用法链接
difference: 不同用处


8.What are the advantages of using if-elif-else rather than a bunch of if statements

if a == 5:
    do something
if a == 6:
    do something
if a == 7:
    do something
if a == 5:
    do something
elif a == 6:
    do something
elif a == 7:
    do something

this one is faster

解释: 问用if-elif-else而不用if-if-if的好处。因为程序运行的更快捷,第一段程序if-if-if要检查每一个if模块,带二段程序if-elif-else直接条件判断速度更快,详细解释在第二个链接。(还可能取决于不同的需求)

if-elif-else用法: 菜鸟教程的用法-中文
if-else的区别: 知乎解释,很生动
用法教程: Programiz的用法-英文


9.What is a flow chart

chart describing flow / structure of the code
contains diamonds (decisions) and rectangles

解释: 问什么是flow chart,描述代码流程或者结构的图。在ed里week3,Lecture第一个PDF文件的第18页。

FLowChart: python_flow_chart
ED的PDF文件: ed-week3-lecture


10.What is a desk check

keep track of how variables changes throughout program
use it for debugging
make sure you have a column for every variable and one for output

解释: 问什么是desk check?看着变量在程序中的变化,调试出来确保每个变量都能有输出。

desk check: how to desk check?


11.What datatype is mutable in python

list, class, dictionary

解释: 问什么数据类型是可变的? 列表,class 和字典。
扩展知识:
不可变数据类型: 当该数据类型的对应变量的值发生了改变,那么它对应的内存地址也会发生改变,对于这种数据类型,就称不可变数据类型。
可变数据类型 :当该数据类型的对应变量的值发生了改变,那么它对应的内存地址不发生改变,对于这种数据类型,就称可变数据类型。

数据类型: 可变和不可变的数据类型


12.What datatype is iterable in python

list, dictionary, iterators

dict = {"key":[], "key2":"value"}

解释: 问什么数据类型是可迭代的(iterable)?列表,字典,迭代器。
在第一个问题讲过什么是iterable。

lterable: what datatype?


13.What is the difference between []*5 vs [0]*5

length of []*5: 0
length of [0]*5: 5

解释: 问这两个输出后有什么不同?长度不同。[]*5输出为[]空白,[0]*5输出为[0,0,0,0,0]五个长度。不做多解释。


14.What does a store at the end of this code snippet?

a = [1,2, 3, 4, 5, 6]
for i in a:
    i += 1

no. for loops are read only

a = [1,2, 3, 4, 5, 6]
for i in range(len(a)):
    a[i] += 1

解释: 问变量a,在结尾的代码段里存储了什么?第一个代码不会存储,只会报错。
for循环不能循环列表,代码块里也不能添加列表。在第二行加入len(a),循环a的长度,在第三行加入a[i],循环列表里的每一项。不做多解释。


15.Describe the differences between black box testing and white box testing

white box: sees code
end to end is black box?

解释: 黑盒测试和白盒测试的不同。一种软件测试的方法,白盒能看见代码,黑盒反之。

Different: black and white box


16.What is a module? (lecture 14 slide 4)

sys, math, random
predefined code / program that allows you to do …
import the modules so you can use the functionalities inside

解释: 什么是模块?平时用的sys(系统),math(数学),random(随机)这些都是Python的内置模块,通过import导入模块可以使用对应的功能。

Python模块: 菜鸟教程-中文
Python 模块2: pythonmodule-英文
Python 内置函数汇总: built_in_module


17.How do you modify a global variable in Python

global

解释: 问如何修改全局变量?如果是int或者str需要声明一个global,如果为list或者dict就可以直接修改。

修改global variable: 修改全局变量
什么是全局变量: what is grobal variable?


18.True or False, you always have to close a file after reading or writing them. If not, when can you get away with it?

f = open("text.txt")
df = f.readlines()

file isn’t closed, file could be corrupted

with open("text.txt") as f:
    df = f.readlines()

Python close automatically

解释: 问那种打开文件的方式需要手动关闭文件?第一种变量=open(文件)没办法自动关闭,with open的方法可以自动关闭文件,不会对文件造成损失。

什么是with open: what is with open?


19.What is sys.stdout?

sys.stdout == print

解释: 问sys.stdout是什么? sys模块的一个函数,和print函数一样

python学习之 sys.stdout和print sys.stdout


20.True or False: Tuples are mutable

False

f = (1, 2, 3)
f = (2, 3, 4)

this one is actually pointing to a different address entirely

解释: 问元组是可变的?不是。两个f变量指向不同的存储地址。

Python列表和元组之间有什么区别?:different and mutable?


21.How do you do x^4 in Python without importing Math module?

x**4

解释: 问怎么在Python语言里写出x的4次方?**两个星号代表乘方。

平方和平方根:python 三种常用方法


22.True or False: A function does not have to return anything

False because a function always returns None when user doesn’t define a return

解释: 判断题,function可以不用返回任何东西,错误。因为function会返回一个None的值,如果不去定义这个return。

def函数:返回类型讲解


23.True or False: A tuple can vary in size

a = (1, 2, 3)
a = (1, 2, 3, 4) #works 
a.append(5) #this won't work because tuples are immutable

No a tupe cannot vary in size unless change memory location

解释: 判断元组是否可以变换大小,不可以。因为元组是不可变的,除非改变元组的存储地址。

list and tupes: difference
python tuples: tuples


24.Describe the differences in lists and arrays

lists : separately but they contain address of the next element , can vary in datatype, can change in size (use append)
arrays : stored together, can only have one datatype, can’t change size, can jump from one element to another

解释: 描述列表和数组的区别。
[列表]:单独存储但有下一个元素的地址,可以改变数据类型,可以改变大小(用append函数)
[元组]:存储在一起,只有一个数据类型,不可以改变大小,可以从一个元素跳到另一个。

不同点: difference between list and array
列表元组的区别: 两者区别


25.What happens when you try to create an object from a class that doesn’t have a pre-defined constructor?

a blank constructor is generated in background

解释: 问当您尝试从没有预定义构造函数的类中创建对象时会发生什么?后台会生成一个空白构造的函数。(不是很了解这个题,下面链接仅供参考)

Python init 构造函数生成对象时调用关系


26.By default, what gets printed when you print an object?

if didn’t write __str__() : <datatype, memory>
after writing __str__(): prints out the output you define

解释: 在默认情况下,如果输出object,会得到什么。如果没有 __str__(),会得到<数据类型,和存储空间>,当写了 __str__()会打印定义输出。

在Python中打印: 功能打印类的对象
Python–str–方法:菜鸟教程


27.By default, what does Python compare when you compare two objects?

if didn’t write __eq__(): compares memory address
if you did write __eq__() : this one compares the variables that you define

解释: 问比较两个类(object)的时候,Python在对比什么? 如果没有写__eq__(),对比的两个存储地址,如果写了__eq__() 对比定义的变量。

链接1: python 中的对比
链接2: 两个实例是否相等


28.What is the difference between static, class and instance methods?

instance : self, referring to the instance
class : cls, refers to the whole class, one change can change it for every instance of the class
static : doesn’t take in anything in parameter,

解释: 问静态,类和实例方法的不同。
[静态的(static)]:不接受任何参数,这种类型的方法既不带参数self也不带cls参数(但是可以自由接受任意数量的其他参数)。
[类(class)]:可以针对该类的每一个实例进行改变。
[实例(instance)]:用self,引用实例。

链接1: Python’s Instance, Class, and Static
URL2: 三种方法和应用场景
URL3: 三种方法的作用和区别


29.True or False: A function can have multiple returns

True

def function(a): #a is a boolean
    if a:
        return True
    else:
        return False

解释: 判断一个函数可以有多个return结果,对的。上面方程判断结构返回多个return。

URL 1: Multiple return


30.Why is testing important?

to make sure your code is running as it should
types of testing : end to end, unit testing, integration testing
black box, white box

解释: 为什么测试代码很重要?因为确保程序预期运行

URL 2: Python testing


31.What is integration testing?

checking whether connection of two or more systems are working

解释: 什么是集成测试?检查两个或多个系统是否连接正常。

URL: integration testing


32.How do you perform end-to-end testing?

diff ____ ____

解释: 如何执行端到端测试?用diff。(没看明白端到端什么意思,以下链接仅供参考)

URL: Difference between System Testing and End-to-end Testing


33.What is regression testing?

testing every test cases (previous and current phases) as you progress through the solution.

解释: 什么是回归测试?在解决方案中逐步测试每个测试用例(先前阶段和当前阶段)

URL: Regression tests package for Python


列表(list),元组(tuple),数组(array),字典(dict) 之间的关系和对比

1. 列表(list)和元组(tuple)的区别

解释: 元组和列表最大的区别就是,列表中的元素可以进行任意修改,就好比是用铅笔在纸上写的字,写错了还可以擦除重写;而元组中的元素无法修改,除非将元组整体替换掉,就好比是用圆珠笔写的字,写了就擦不掉了,除非换一张纸。
可以理解为,tuple 元组是一个只读版本的 list 列表。

URL1: Python元组和列表的区别
URL2: 列表和元组的区别
URL3:python 元组(tuple)和列表(list)区别


2.列表(list)和数组(array )的区别

解释: python中的list是python的内置数据类型,list中的数据类不必相同的,而array的中的类型必须全部相同。

URL:python数组和列表区别

2.1 数组(Array)和列表(ArrayList)的区别

解释: Array 数组可以包含基本类型和对象类型, ArrayList 却只能包含对象类型。 Array 数组在存放的时候一定是同种类型的元素

URL: 什么时候应该使用Array而不是ArrayList?


3.列表(list)和字典(dict)的区别

解释 Python中的字典底层是通过散列表(哈希表)来实现的, “哈希表是根据关键码值(Key value)而直接进行访问的数据结构。也就是说,它通过把关键码值映射到表中一个位置来访问记录,以加快查找的速度。这个映射函数叫做散列函数,存放记录的数组叫做散列表。”

URL1: Python 列表和字典的本质区别
URL2: Python中列表和字典有什么区别,分别适用于什么场景?


总结

Oral考试加油!希望这篇博客可以有帮助。

  • 32
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 31
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 31
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值