Python 编程基础测试题:数据库、数组、GUI 和 面向对象
///'1.//t以下哪个Python代码片段正确地执行了一个SQL查询并获取了所有结果?( )//n//n//nA.//t//tresults = cursor.execute//(/'SELECT * FROM students///'//).fetchone()//n//n//n//nB.//t//tcursor.execute//(/'SELECT * FROM students///'//)//n//nresults = cursor.scroll()//n//n//n//nC.//t//tcursor.begin//(/'SELECT * FROM students///'//)//n//nresults = cursor.fetchmany()//n//n//n//nD.//t//tcursor.execute//(/'SELECT * FROM students///'//)//n//nresults = cursor.fetchall()//n//n2.//t//n//nimport numpy as np //n//n//nnp.arange(16).reshape(4,4),求点(3,2)的值是?( )//n//n//n//nA.//t//t14//n//n//n//nB.//t//t9//n//n//n//nC.//t//t10//n//n//n//nD.//t//t6//n//n3.//t//n//n有如下Python程序段,执行程序后,输出的结果是?( )//n//n//nimport csv//n//nwith open//('123.csv', 'w',newline=''//) as f://n//t//tw=csv.writer(f)//n//t//tw.writerows([//('hello','world'//), //('I','love','you'//)])//n//nwith open//('123.csv', 'r'//) as f://n//t//tsp= csv.reader(f)//n//t//tfor row in sp://n//t//t//tprint(row[0],end=',')//n//n//n//nA.//t//tI,you//n//n//n//nB.//t//thello,world//n//n//n//nC.//t//thello,I,//n//n//n//nD.//t//t程序有误//n//n4.//t已知文件1.txt内容为:abcdefghijklmnopqrstuvwxyz,文件1.txt与程序文件保存在同一个目录,运行以下程序,输出结果是?( )//n//nwith open//(/'1.txt/',/'r/'//) as f://n//t//tf.seek(10)//n//t//tprint(f.read(1))//n//n//n//nA.//t//ta//n//n//n//nB.//t//tk//n//n//n//nC.//t//tj//n//n//n//nD.//t//tl//n//n5.//t//n//n运行以下Python代码,结果是?(//t//t)//n//nclass Person()://n//n//t//tdef init(self, name, age)://n//t//t//t//tself.name = name//n//t//t//t//tself.age = age//n//t//tdef say_hello(self)://n//n//t//t//t//tprint(f///'Hello, my name is {self.name}. I am {self.age} years old.///'//)//n//n//nperson1 = Person//(/'Alice///', 25//)//n//nperson2 = Person//(/'Bob///', 30//)//n//nperson1.say_hello() //n//n//n//nA.//t//tHello, my name is Alice. I am 30 years old.//n//n//n//nB.//t//tHello, my name is Bob. I am 25 years old.//n//n//n//nC.//t//tHello, my name is Bob. I am 30 years old.//n//n//n//nD.//t//tHello, my name is Alice. I am 25 years old.//n//n6.//t利用Python列表创建一个二维数组,不正确的方法是?( )//n//n//nA.//t//ta=[[1,1,3],[2,6,7],[4,7,1]]//n//n//n//nB.//t//tb=[[0 for i in range(3)] for j in range(2)]//n//n//n//nC.//t//tc=[0]44//n//n//n//nD.//t//td=[[0]*3,[9]*3,[4]*3]//n//n7.//t在一个Python表示的二维数组b=[[3,5,9,4],[5,1,6,11],[2,1,6,6]]的第三列位置插入一列新的数据后,能够实现访问该数组中数据11的语句是?( )//n//n//nA.//t//tb[2][3]//n//n//n//nB.//t//tb[1][3]//n//n//n//nC.//t//tb[2][1]//n//n//n//nD.//t//tb[1][4]//n//n8.//t//n//n编写一个程序,如下图所示,用于计算输入两个数的和,并通过窗口输出计算结果。空白处应补充的代码是?( )//n//n//n//nimport tkinter as tk//n//nimport tkinter.messagebox//n//nwin=tk.Tk()//n//na=tk.IntVar()//n//nb=tk.IntVar()//n//ndef jia()://n//t//ta1=a.get()//n//t//tb1=b.get()//n//t//ttk.messagebox.showinfo(message=str(a1)+'+'+str(b1) +'=' + str(a1+b1))//n//nc=tk.Entry(win,textvariable=a)//n//nd=tk.Entry(win,textvariable=b)//n//nok=tk.Button(win,text='+',command=_______)//n//nc.place(x=10,y=10,width=80,height=20)//n//nd.place(x=10,y=40,width=80,height=20)//n//nok.place(x=10,y=80,width=50,height=20)//n//nwin.mainloop()//n//n//n//nA.//t//tadd//n//n//n//nB.//t//tjia//n//n//n//nC.//t//tjia()//n//n//n//nD.//t//tplus//n//n9.//t以下选项中,不是tkinter变量类型的是?( )//n//n//nA.//t//tIntVar()//n//n//n//nB.//t//tStringVar()//n//n//n//nC.//t//tDoubleVar()//n//n//n//nD.//t//tFloatVar()//n//n10.//t假设有一个名为///'Person///'的类,如何创建一个名为///'john///'的类的实例?( )//n//n//nA.//t//tjohn = person.Person()//n//n//n//nB.//t//tjohn = Person()//n//n//n//nC.//t//tperson = john.Person()//n//n//n//nD.//t//tperson = Person()//n//n11.//t假设你正在开发一个电子商务网站,你需要存储用户订单信息。需要创建一个名为 orders 的表,下面哪个 SQL 语句最合适?( )//n//n//nA.//t//tCREATE TABLE orders (id INTEGER PRIMARY KEY, user_id INTEGER, product_name TEXT)//n//n//n//nB.//t//tCREATE TABLE orders (user_id INTEGER, product_name TEXT, quantity INTEGER, price REAL)//n//n//n//nC.//t//tCREATE TABLE orders (id INTEGER, user_id INTEGER, product_name TEXT, quantity INTEGER, price REAL)//n//n//n//nD.//t//tCREATE TABLE orders (id INTEGER PRIMARY KEY, user_id INTEGER, product_name TEXT, quantity INTEGER, price REAL)//n//n12.//t在使用SQLite数据库时,游标的主要作用是?( )//n//n//nA.//t//t储存数据库的表结构//n//n//n//nB.//t//t用于数据库的备份和恢复//n//n//n//nC.//t//t管理数据库连接//n//n//n//nD.//t//t执行SQL查询并获取结果//n//n13.//t以下程序中,a= Spinbox(win1,from=10,to=100)的作用是?( )//n//nfrom tkinter import *//n//nwin1= Tk()//n//na= Spinbox(win1,from=10,to=100)//n//na.pack()//n//nmainloop()//n//n//n//nA.//t//t限制输入范围是10-100之间,包含10和100//n//n//n//nB.//t//t设置窗口尺寸为10x100//n//n//n//nC.//t//t只能选择10或者100//n//n//n//nD.//t//t生成10-100之间的随机数//n//n14.//t//n//n运行以下Python代码,结果是?(//t//t)//n//nclass Parent()://n//n//t//tdef init(self, name)://n//t//t//t//tself.name = name//n//t//tdef greetings(self)://n//t//t//t//tprint//(/'Parent: Hi, I'm///', self.name//)//n//t//t//n//nclass Child(Parent)://n//t//tdef greetings(self)://n//t//t//t//tsuper().greetings() //n//t//t//t//tprint//(/'Child: Hello!///'//)//n//n//nparent = Parent//(/'Alice///'//)//n//nchild = Child//(/'Bob///'//)//n//nchild.greetings()//n//n//n//nA.//t//tParent: Hi, I'm Bob.//n//nChild: Hello!//n//n//n//nB.//t//t//n//nChild: Hello!//n//n//n//nC.//t//t//n//nParent: Hi, I'm Alice//n//n//nChild: Hello!//n//n//n//nD.//t//t//n//nParent: Hi, I'm Bob//n//n//n内容:Child: Hello!///
原文地址: https://www.cveoy.top/t/topic/nRld 著作权归作者所有。请勿转载和采集!