导航:首页 > 编程语言 > python编程教师考察试题

python编程教师考察试题

发布时间:2022-07-23 07:28:50

python编程题,求教!!

代码如下

"""
学生成绩表
姓名语文数学英语总分
王敏95.598
利用字典显示上表内容
"""

header=['姓名','语文','数学','英语','总分','平均分']
score=[
{
'name':'王敏',
'Chinese':95.5,
'Math':98,
'English':97,
},
{
'name':'刘志坚',
'Chinese':96,
'Math':92,
'English':82,
},
{
'name':'谢塞科',
'Chinese':91,
'Math':100,
'English':90,
},
{
'name':'肖江秋',
'Chinese':88,
'Math':93,
'English':99,
}
]

#输出表格

print('学生成绩表')
blank=' '
little_blank=' '
Chinese_max={'name':'','sorce':0}#语文
Math_max={'name':'','sorce':0}#数学
English_max={'name':'','sorce':0}#英语

forvinheader:
print(v,end=blank)

forvinscore:
print()

ifChinese_max['sorce']==0:
Chinese_max['sorce']=v['Chinese']
else:
#对比分数
ifChinese_max['sorce']<v['Chinese']:
Chinese_max['sorce']=v['Chinese']
Chinese_max['name']=v['name']
ifChinese_max['name']=='':
Chinese_max['name']=v['name']

ifMath_max['sorce']==0:
Math_max['sorce']=v['Math']
else:
#对比分数
ifMath_max['sorce']<v['Math']:
Math_max['sorce']=v['Math']
Math_max['name']=v['name']
ifMath_max['name']=='':
Math_max['name']=v['name']

ifEnglish_max['sorce']==0:
English_max['sorce']=v['English']
else:
#对比分数
ifEnglish_max['sorce']<v['English']:
English_max['sorce']=v['English']
English_max['name']=v['name']
ifEnglish_max['name']=='':
English_max['name']=v['name']

print(v['name'],end='')
iflen(v['name'])>2:
print(end=little_blank)
else:
print(end=blank)

print(v['Chinese'],end='')
if'.'instr(v['Chinese']):
print(end=little_blank)
else:
print(end=blank)

print(v['Math'],end='')
if'.'instr(v['Math']):
print(end=little_blank)
else:
print(end=blank)

print(v['English'],end='')
if'.'instr(v['English']):
print(end=little_blank)
else:
print(end=blank)

total=v['Chinese']+v['Math']+v['English']
print(total,end='')
if'.'instr(total):
print(end=little_blank)
else:
print(end=blank)

print(round(total/3),end='')#平均分

#每科最高分

print(' 最高分')
print('语文 '+Chinese_max['name']+' '+str(Chinese_max['sorce']))
print('数学 '+Math_max['name']+' '+str(Math_max['sorce']))
print('英语 '+English_max['name']+' '+str(English_max['sorce']))

输出如下

学生成绩表
姓名 语文 数学 英语 总分 平均分
王敏 95.5 98 97 290.5 97
刘志坚 96 92 82 270 90
谢塞科 91 100 90 281 94
肖江秋 88 93 99 280 93

最高分
语文 刘志坚 96
数学 谢塞科 100
英语 肖江秋 99

输出截图

⑵ 关于python程序设计题的题库

1、average_sum函数的功能为求一批数中大于平均值

sum=0
k=0
for i in range(n):
sum=sum+a[i]
average=sum/n
for i in range:
if(a[i]>average):
k=k+a[i]
return k

2、编写函数fun求一个不多于五位数的正整数的位数

if(m>9999):
place=5
elif(m>999):
place=4
elif(m>99):
place=3
elif(m>9):
place=2
else:
place=1
return place

3、请编fun函数,求4*4整形数组的主对角线元素的和

sum=0.0
for i in range(4):
sum+=a[i][i]
return sum

4、已知:一元钱一瓶汽水,喝完后两个空瓶换一瓶汽水。问:请输入钱数(大于1的正整数),则根据钱数最多可以喝到几瓶汽水。

s=0
k=0
while m>0:
m=m-1
s=s+1
k=k+1
while k>=2:
k=k-2
s=s+1
k=k+1
return s

5、编写函数fun(x,y),函数的功能是若x、y为奇数,求x到y之间的奇数和;若x、y为偶数,则求x到y之间的偶数和。要求必须使用for结构。
主函数的功能是分别计算如下的值:
(1+3+5+……+777)+(2+4+6+……+888)=???
(1+3+5+……+1111)+(2+4+6+……+2222)=???
(1+3+5+……+1999)+(2+4+6+……+1998)=???

s=0
for i in range(x,y+1,2):
s=s+i
return s

6、编写函数main 求3!+6!+9!+12!+15!+18!+21!
s=0
for i in range(3,22,3):
r=1
for j in range(1,i+1):
r*=j
s+=r
print(s)

⑶ 求助python编程的题目

def count(val, seq):
"""
>>> count(5, (1, 5, 3, 7, 5, 8, 5))
3
>>> count('s', 'Mississippi')
4
>>> count((1, 2), [1, 5, (1, 2), 7, (1, 2), 8, 5])
2
"""
return list(seq).count(val)

def reverse(seq):
"""
>>> reverse([1, 2, 3, 4, 5])
[5, 4, 3, 2, 1]
>>> reverse(('shoe', 'my', 'buckle', 2, 1))
(1, 2, 'buckle', 'my', 'shoe')
>>> reverse('Python')
'nohtyP'
"""
return seq[::-1]

def sort_sequence(seq):
"""
>>> sort_sequence([3, 4, 6, 7, 8, 2])
[2, 3, 4, 6, 7, 8]
>>> sort_sequence((3, 4, 6, 7, 8, 2))
(2, 3, 4, 6, 7, 8)
>>> sort_sequence("nothappy")
'ahnoppty'
"""
if type(seq) == str:
return ''.join(sorted(seq))
else:
return type(seq)(sorted(seq))

def recursive_min(nested_num_list):
"""
>>> recursive_min([2, 9, [1, 13], 8, 6])
1
>>> recursive_min([2, [[100, 1], 90], [10, 13], 8, 6])
1
>>> recursive_min([2, [[13, -7], 90], [1, 100], 8, 6])
-7
>>> recursive_min([[[-13, 7], 90], 2, [1, 100], 8, 6])
-13
"""
smallest = nested_num_list[0]
while type(smallest) == type([]):
smallest = smallest[0]

for element in nested_num_list:
if type(element) == type([]):
min_of_elem = recursive_min(element)
if smallest > min_of_elem:
smallest = min_of_elem
else: # element is not a list
if smallest > element:
smallest = element
return smallest

def recursive_count(target, nested_num_list):
"""
>>> recursive_count(2, [2, 9, [2, 1, 13, 2], 8, [2, 6]])
4
>>> recursive_count(7, [[9, [7, 1, 13, 2], 8], [7, 6]])
2
>>> recursive_count(15, [[9, [7, 1, 13, 2], 8], [2, 6]])
0
>>> recursive_count(5, [[5, [5, [1, 5], 5], 5], [5, 6]])
6
"""
count = 0
for element in nested_num_list:
if type(element) == type([]):
count += recursive_count(target, element)
else: # element is not a list
if element == target:
count += 1
return count

def flatten(nested_num_list):
"""
>>> flatten([2, 9, [2, 1, 13, 2], 8, [2, 6]])
[2, 9, 2, 1, 13, 2, 8, 2, 6]
>>> flatten([[9, [7, 1, 13, 2], 8], [7, 6]])
[9, 7, 1, 13, 2, 8, 7, 6]
>>> flatten([[9, [7, 1, 13, 2], 8], [2, 6]])
[9, 7, 1, 13, 2, 8, 2, 6]
>>> flatten([[5, [5, [1, 5], 5], 5], [5, 6]])
[5, 5, 1, 5, 5, 5, 5, 6]
"""
flat_list = []
for element in nested_num_list:
if type(element) == type([]):
flat_list += flatten(element)
else: # element is not a list
flat_list.append(element)
return flat_list

if __name__ == "__main__":
import doctest
doctest.testmod()

----------------------------------
6 items passed all tests:
3 tests in __main__.count
4 tests in __main__.flatten
4 tests in __main__.recursive_count
4 tests in __main__.recursive_min
3 tests in __main__.reverse
3 tests in __main__.sort_sequence
21 tests in 7 items.
21 passed and 0 failed.
Test passed.
-----------------------------------------

LZ在自学这个把
http://www.openbookproject.net/thinkCSpy/
确实是好书

⑷ 求教两道python编程题

defcount_words(input_str):
returnlen(input_str.split(''))
defcount_substr(input_str,sub_str):
returninput_str.count(sub_str)

使用系统函数就可以

⑸ 求助Python程序设计编程题!

按照题目要求编写的Python程序如下


s=input("请输入只包含字母的字符串:")

s=s.lower()

result={}

for i in s:

if i in result.keys():

result[i]+=1

else:

result[i]=1

print(result)


源代码(注意源代码的缩进)

⑹ Python面向对象编程题

classTime:
def__init__(self,hours,minutes,seconds):
self.__hours=hours
self.__minutes=minutes
self.__seconds=seconds

defhours(self):
returnself.__hours

defminutes(self):
returnself.__minutes

defseconds(self):
returnself.__seconds

def__add__(self,other):#定义加法行为
pass

def__sub__(self,other):#定义减法行为
pass

def__eq__(self,other):#定义等于号行为
pass

def__lt__(self,other):#定义小于号行为
pass

写出大致框架,自行完善后面的四个魔法方法

⑺ 一道简单的python编程题

这个是典型的递归函数例子,你们老师给这个题目,一般是在讲解递归函数之后。所以最好使用递归函数解题。

⑻ Python编程题

defcount(s):
res={
'Upper':0,#数字
'Lower':0,#大写
'Digit':0,#小写
'Other':0#其他
}
forcins:
ifc.isdigit():
res['Digit']+=1
elifc.islower():
res['Lower']+=1
elifc.isupper():
res['Upper']+=1
else:
res['Other']+=1
returnres

####e.g.
count('vdCde123D3*&1')

>>>{'Digit':5,'Lower':4,'Other':2,'Upper':2}

⑼ Python编程笔试题,求大神解答


这就可以了

阅读全文

与python编程教师考察试题相关的资料

热点内容
静脉压缩袜和打底裤的区别 浏览:345
劲舞服务器中断是什么原因 浏览:630
40岁北漂程序员 浏览:55
下载钉钉app是什么 浏览:222
什么服务器支持云播放 浏览:835
什么app进货牛排比较好 浏览:107
为什么鸿蒙用安卓app 浏览:82
手相面相pdf 浏览:376
军犬不听命令追出大门 浏览:915
程序员必背97件事 浏览:941
云服务器python怎么读取 浏览:33
哪里买云服务器划算 浏览:238
四川日报pdf 浏览:967
按摩解压助眠小姐姐 浏览:411
风冷压缩机水冷却器 浏览:879
服务器播放器如何打开方式 浏览:790
phppython快 浏览:367
pdf转换word免费版 浏览:37
二手的有什么APP 浏览:329
服务器的应用镜像是什么 浏览:153