14、关于a,b的描述错误的是( )。 a、若a=true ,b=true,则 a or b ==true b、若a=true, b=false, 则 a or b ==true c、若a=true,b=true,则 a or b ==false d、若a=false,b=false,则 a or b ==false
2、n=p=0 while p!=100 and n<3: p=int(input()) n =1 while循环结束的条件是( )。 a、p的值不等于100并且n的值小于3 b、p的值等于100并且n的值大于等于3 c、p的值不等于100或者n的值小于3 d、p的值等于100或者n的值大于等于3
3、以下for语句中,不能完成1~10的累加功能的是( )。 a、for i in range(10,0): sum =i b、for i in range(1,11): sum =i c、for i in range(10,-1,-1): sum =i d、for i in(10,9,8,7,6,5,4,3,2,1): sum =i
6、以下关于循环结构的描述,错误的是( )。 a、遍历循环使用for 循环变量 in 循环结构 语句,其中循环结构不能是文件 b、使用range()函数可以指定for循环的次数 c、for i in range(5)表示循环5次,i的值是从0到4 d、用字符串做循环结构的时候,循环的次数是字符串的长度
7、for i in range(0,2): print (i,end=' ') 的输出结果是( )。 a、0 1 2 b、1 2 c、0 1 d、1
1、运行以下程序,输出结果的是( )。 print(" love ".join(["everyday","yourself","python"])) a、everyday love yourself b、everyday love python c、love yourself love python d、everyday love yourself love python
7、关于python序列类型的通用操作符和函数,以下选项中描述错误的是( )。 a、如果x不是s的元素,x not in s返回true b、如果s是一个序列,s=[1,"kate",true],s[3]返回true c、如果s是一个序列,s=[1,"kate",true],s[–1]返回true d、如果x是s的元素,x in s返回true
13、用if语句统计符合报名条件的人数,条件是男性年龄大于20岁小于30岁,下列正确的语句是( ) 。 a、if sex=='男' or age<30 and age>20: n =1 b、if sex=='男' and age<30 or age>20: n =1 c、if sex=='男' and (age<30 and age>20): n =1 d、if sex=='男' or (age<30 or age>20): n =1
15、闰年的判定条件是能被400整除,或者能被4整除但不能被100整除,正确的python表达式为( )。 a、([email protected]==0) or (year%4==0 and year % 100!=0) b、[email protected]==0 and year%4==0 and year % 100!=0 c、(year//400==0) or (year//4==0 and year//100!=0) d、year//400==0 or year//4==0 and year//100!=0
17、表达式1 if 3>2 else(4 if 5>6 else 7)的值为( )。 a、1 b、2 c、3 d、4
18、下面代码for i in "china":换行 print(i,end=" ")的输出结果是( )。 a、c,h,i,n,a, b、c h i n a c、china d、c h i n a
19、以下for语句中,不能完成1~10的累加功能的是( )。 a、for i in range(10,0): sum =i b、for i in(10,9,8,7,6,5,4,3,2,1): sum =i c、for i in range(10,-1,-1): sum =i d、for i in range(1,11): sum =i
30、关于python序列类型的通用操作符和函数,以下选项中描述错误的是( )。 a、如果x不是s的元素,x not in s返回true b、如果s是一个序列,s=[1,"kate",true],s[–1]返回true c、如果s是一个序列,s=[1,"kate",true],s[3]返回true d、如果x是s的元素,x in s返回true
49、设a.txt的内容是: a,b,c,d 以下代码执行结果是( )。 with open('a.txt','r') as f: print(f.read().split(',')) a、['a', 'b', 'c', 'd'] b、[a, b, c, d] c、'a', 'b', 'c', 'd' d、a, b, c, d
50、执行以下代码,output.txt文件中的内容是( )。 aaa =[8, 5, 2, 2] with open('output.txt', 'w') as f: for aa in aaa: f.write(';'.join(str(aa))) a、8522 b、8;5;2;2 c、8,5,2,2 d、8 5 2 2
106、填写横线处代码,完成程序,程序运行结果如下图所示。 for i in range(1,_____): print(" "*(30-i),end='') for j in range(1,2*i): if j_____2==1: print("*",end='') else: print(" ",end='') print() 注意:两个填空答案用一个空格隔开,且只能用一个空格隔开。
107、下面为画n变形的程序,填写横线处代码,完成程序。 import turtle n=eval(input("n:")) turtle.pensize(4) turtle.________('blue','green') turtle.________() turtle.setheading(90) for i in range(n): turtle.forward(1000/n) turtle.right(360/n) turtle.end_fill() 注意:两个填空答案用一个空格隔开,且只能用一个空格隔开。
108、完成rot13的加解密代码: origin='abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' cipher='nopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm' olist=list(origin) clist=list(cipher) ocdist=dict(____(olist,clist)) strstr=input('请输入原文:') destlist=[] for c in strstr: destlist.append( ocdist.get(c,c)) print("密文:",''.____(destlist)) 注意:两个答案用一个空格隔开。
109、下面程序判断成绩的等级并打印结果,填写横线处代码,完成程序。 def analyze(grade): if 100>=grade>=60: res='及格' _____ 0<=grade<60: res='不及格' else: res='成绩非法' return(res) m=[15,78,25,64,92] for i in m: print(i,______(i)) 注意:两个填空答案用一个空格隔开,且只能用一个空格隔开。
110、完成代码,下面代码中单击按钮,则新建一个顶级窗口。 import tkinter as tk w = tk.tk() w.geometry('300x200') s=0 def add(): # 创建顶级窗口 t1 = tk.toplevel() t1.title("新窗口") global s s=s 1 tk.label(________, text='我是第' str(s) '个子窗口',height=4).pack() b1=tk.button(w, text='新建窗口', ______=add).pack() w.mainloop() 注意:两个答案用一个空格隔开。
111、已知c:\data.txt的内容如下: 490,339,736,699,286,873,16,361 下面代码求736开始连续三个数的和,填写横线处代码,完成程序。 with open('c:\\data.txt','r') as fr: list_num=______.read().split(',') sum=0 for i in range(______,5): sum=sum int(list_num[i]) print(sum) 注意:两个填空答案用一个空格隔开,且只能用一个空格隔开。