Python学习必备基础知识100问及答案,Python高清PDF电子版下载

云课堂学Python 2024-11-23 22:27:18

(图中方式获取Python学习必备基础知识100问及答案PDF电子完整版文件下载链接)

1.三元运算

age = 10ticket = "儿童票" if age < 12 _______ "成人票"print(ticket)

A. ? B. else:C. thenD. else

2.输入函数

trafficLight = ______("请输入信号灯颜色 red, green or yellow:")if trafficLight == "red": print("信号灯颜色是:" + trafficLight)elif trafficLight == "green": print("信号灯颜色是:" + trafficLight)else: print("信号灯颜色是:" + trafficLight)

A. user_inputB. inputC. user_enterD. enter

3.自定义函数返回值

import mathr = float(input("请输入圆的半径:"))def circleArea(): ______ math.pi*pow(r, 2)print("圆的面积是:", circleArea())

A. back B. sendC. returnD. param

4.成员运算符

color = {0:"red", 1:"yellow", 2:"green", 3:"white"}v = color.values()for c ______ v: print(c)

A. inB. atC. onD. by

5.检测字符串是否只由字母组成

name = input("请输入你的英文昵称:") isLetter = name.______ if isLetter: print("有效的昵称!")else: print("无效的昵称!")

A. isCharacter()B. isChar()C. isLetter() D. isalpha()

6.文件操作

f = ______("tryFile. txt", "w") f.write("I am learning Python programming ! ")f.closef = ______("tryFile. txt", "r") print(f.read())f.close

A. unwrapB. unlockC. untie D. open

7.导入模块

# program001.pydef red(): print("This flower is red")def yellow(): print("This flower is yellow")def green(): print("This flower is green")# program002.py______ program001# 导入模块program001.red()program001.yellow()program001.green()

A. get B. importC. obtain D. acquire

8.类参数

class Flower: def __init__( ______, name, color ): self.name = name self.color = color f = Flower("rose", "red")print("The flower's name is " + f.name)print("The flower's color is " + f.color)

A. thisB. whichC. selfD. object

(图中方式获取Python学习必备基础知识100问及答案PDF电子完整版文件下载链接)

0 阅读:0