mwfd.net
当前位置:首页 >> python编程题目 >>

python编程题目

#第一题dicf={"chen":48,"li":72,"zhang":60,"jiang":92}for item,value in dicf.items(): if value==max(dicf.values()): print item,"\t",value#第二题lista=[3,5,7,9]print "initial list:",lista #打印初始值lista.insert(2,6) #插入操作print "after insert:

在mirosoft visual c++环境下编译链接通过: #include #include main() { int count=0; double x1,x2,f,d; printf("input x2:-1\n(请输入-1 按回车键)\n"); printf("count\tx1\t\tx2\n\n"); scanf("%lf",&x2); do { x1=x2; f=(2*x1-4)*(2*x1-4); d=4*(2*x1-4)

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(('

123456789101112131415161718192021 defmenu(gnum): print'I guess '+str(gnum) returninput('Am I too high(1),too low(2),or right on?(3)\n')defplayGame(): startnum=1 endnum=1000 midnum=(startnum+endnum)/2 ch=menu(midnum) whilech!=3

打开一个文本吧,创建是空白的.读每行好像是readlines吧,我记得会创建一个列表,遍历列表元素长度.做个大小判断应该就行了吧

a=input("输入长")b=input("宽")j=a*bprint(面积为+j)变量格式要不要强转自己试一下.

def score(numbers): return sum(sorted(numbers)[1:-1]) / float(len(numbers) - 2)

#!/usr/bin/env python#-*- coding: utf-8 -*-from __future__ import with_statementimport revalues = {}lines = []txt_file = 'data.txt'out_file = 'result.txt'data_re = re.compile(ur'^(\w)\^(\w)\s+.+?\s+(.+?)\s*$')with open(txt_file, 'rU') as f: for line in f: if '^' in line:

逆序切片-2,-4,-6

网站首页 | 网站地图
All rights reserved Powered by www.mwfd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com