USYD悉尼大学INFO1110 详细作业解析Week3 all quizzes

Week 3 all the quizzes

第三周所有的quiz,详细解释,答案供参考。详细


You should take it easy. 详细的解说等我闲一点了再添加上去,【官方解释】的是老师给的解释,大部分都是能看明白的。



Preface

提示:这里可以添加本文要记录的大概内容:
例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。


Lecture: Control flow

Expressions and control flow quiz

question 1

The following code uses int casting. What is the difference between the value calculated with and without the int casting?

print(str(int(float("3.14"))+int(float("5.6"))))

answer : 0.74
讲解: 在代码块里运行的时候,输出结果是8。但是那是错的,正确理解是取浮点数小数点后面的数字相加,就是结果。(待更新更好的解释)

question 2

Do the following two code segments have equivalent outcome (control flow)?

ticket = 240
if speed > 0:
	if speed < 40:
		ticket = 0
	else:
		if speed > 100:
			pass
		else if speed <= 100:
			ticket = 120
		else:
			pass
else:
	pass
ticket = 0 
if speed < 40:
	ticket = 0
else if speed <= 100:
	ticket = 120
if speed 
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值