APP下载
首页
>
财会金融
>
宏观经济学选择题
搜索
宏观经济学选择题
题目内容
(
多选题
)
6. (多选题)输入一个正整数,输出小于这个数的所有奇数的和,以下程序结果正确的是:

A、n=int(input())result=0foriinrange(n):ifi%2==1:result=result+iprint(result)

B、n = int(input())result = 0for i in range(1, n):if i % 2 == 1:result = result + iprint(result)

C、n = int(input())result = 0for i in range(n):result = result + iprint(result)

D、n = int(input())print(sum([i for i in range(n) if i % 2 == 1]))

答案:ABD

宏观经济学选择题
71. (单选题)对以上数据,先按照年龄字段降序,若年龄相同再按照身高升序排列正确的语句为(0
https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-458e-c01a-2cf5d6189000.html
点击查看题目
141. (简答题)文件“静夜思.txt”保存在当前文件夹下,其文件的编码为“utf-8”,现在需要打开并读取文件内容,可以获得以下格式的输出的程序代码段:静夜思李白床前明月光,疑似地主霜。举头望明月,低头思故乡。
https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-d03a-c01a-2cf5d6189000.html
点击查看题目
1. (多选题)下面可以输出浮点数3.0 的程序语句有:
https://www.shititong.cn/cha-kan/shiti/000dded1-b61d-a3b1-c01a-2cf5d6189000.html
点击查看题目
158. (判断题)元组是可变数据类型
https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-f174-c01a-2cf5d6189000.html
点击查看题目
163. (判断题)Python字典中的“键”不允许重复,是唯一的
https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-fabc-c01a-2cf5d6189000.html
点击查看题目
137. ( )找一段英文的文本,统计该文本中单词的出现次数。比如:How are you How are you 统计结果是:{“how”:2, “are”:2,”you”:2},再遍历整个字典,将每个单词出现的次数输出
https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-c884-c01a-2cf5d6189000.html
点击查看题目
136. ( )编写一个函数,该函数能比较3个数大小并返回最小数
https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-c6b4-c01a-2cf5d6189000.html
点击查看题目
192. (填空题)( )变量定义在函数外,可以在整个程序范围内访问
https://www.shititong.cn/cha-kan/shiti/000dded1-b61f-3616-c01a-2cf5d6189000.html
点击查看题目
172. (判断题)位置参数必须在关键字参数的后面
https://www.shititong.cn/cha-kan/shiti/000dded1-b61f-0cfe-c01a-2cf5d6189000.html
点击查看题目
12. (多选题)year = 2021下面语句中可以正确输出"2021年"的有:
https://www.shititong.cn/cha-kan/shiti/000dded1-b61d-c951-c01a-2cf5d6189000.html
点击查看题目
首页
>
财会金融
>
宏观经济学选择题
题目内容
(
多选题
)
手机预览
宏观经济学选择题

6. (多选题)输入一个正整数,输出小于这个数的所有奇数的和,以下程序结果正确的是:

A、n=int(input())result=0foriinrange(n):ifi%2==1:result=result+iprint(result)

B、n = int(input())result = 0for i in range(1, n):if i % 2 == 1:result = result + iprint(result)

C、n = int(input())result = 0for i in range(n):result = result + iprint(result)

D、n = int(input())print(sum([i for i in range(n) if i % 2 == 1]))

答案:ABD

分享
宏观经济学选择题
相关题目
71. (单选题)对以上数据,先按照年龄字段降序,若年龄相同再按照身高升序排列正确的语句为(0

A. frame.sortⱣⱤvalues(ascending=['age','height], by=[False,True])

B. frame.sortⱣⱤvalues(by=('age','height), ascending=(False,True))

C. frame.sortⱣⱤvalues(ascending=('age','height), by=(False,True))

D. frame.sortⱣⱤvalues(by=['age','height], ascending=[False,True])

https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-458e-c01a-2cf5d6189000.html
点击查看答案
141. (简答题)文件“静夜思.txt”保存在当前文件夹下,其文件的编码为“utf-8”,现在需要打开并读取文件内容,可以获得以下格式的输出的程序代码段:静夜思李白床前明月光,疑似地主霜。举头望明月,低头思故乡。
https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-d03a-c01a-2cf5d6189000.html
点击查看答案
1. (多选题)下面可以输出浮点数3.0 的程序语句有:

A. print(float('3.0'))

B. print(float(3))

C. print(float(' 3.0\n'))

D. print(float('\t 3.0\n'))

解析:答案解析:float()转浮点数时,可以去除字符串开头和结尾的空白字符

https://www.shititong.cn/cha-kan/shiti/000dded1-b61d-a3b1-c01a-2cf5d6189000.html
点击查看答案
158. (判断题)元组是可变数据类型

A.   对

B.   错

https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-f174-c01a-2cf5d6189000.html
点击查看答案
163. (判断题)Python字典中的“键”不允许重复,是唯一的

A.   对

B.   错

https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-fabc-c01a-2cf5d6189000.html
点击查看答案
137. ( )找一段英文的文本,统计该文本中单词的出现次数。比如:How are you How are you 统计结果是:{“how”:2, “are”:2,”you”:2},再遍历整个字典,将每个单词出现的次数输出
https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-c884-c01a-2cf5d6189000.html
点击查看答案
136. ( )编写一个函数,该函数能比较3个数大小并返回最小数
https://www.shititong.cn/cha-kan/shiti/000dded1-b61e-c6b4-c01a-2cf5d6189000.html
点击查看答案
192. (填空题)( )变量定义在函数外,可以在整个程序范围内访问
https://www.shititong.cn/cha-kan/shiti/000dded1-b61f-3616-c01a-2cf5d6189000.html
点击查看答案
172. (判断题)位置参数必须在关键字参数的后面

A.   对

B.   错

https://www.shititong.cn/cha-kan/shiti/000dded1-b61f-0cfe-c01a-2cf5d6189000.html
点击查看答案
12. (多选题)year = 2021下面语句中可以正确输出"2021年"的有:

A. print(year + '年')

B. print(str(year) + '年')

C. print(f'{year}年')

D. print('{}年'.format(year))

https://www.shititong.cn/cha-kan/shiti/000dded1-b61d-c951-c01a-2cf5d6189000.html
点击查看答案
试题通小程序
试题通app下载