# python九九乘法表代码 ascii_python编程题

Failure is probably the fortification in your pole

It is like a peek your wallet as the thief when you

are thinking how to spend several hard-won lepta

when you Are wondering whether new money it has laid

background Because of you, then at the heart of the

most lax alert and most low awareness and left it

godsend failed

!!!!!

49

Are

Because

Failure

It

a

and

are

as

at

words=""

whileTrue:

a=input()if a=="!!!!!":breakwords=words+" "+a

words=words.split()

s={}for i inwords:if i ins:

s[i]+=1

else:

s[i]=1s=list(s.items())

s.sort(key=lambda x:x[0])

print(len(s))if len(s)<10:for i inrange(len(s)):

word,count=s[i]

print(word)else:for i in range(10):

word,count=s[i]

print(word)

7-2 jmu-Java&Python-统计文字中的单词数量并按出现次数排序 (25 分)

failure is probably the fortification in your pole

it is like a peek your wallet as the thief when you

are thinking how to spend several hard-won lepta

when you are wondering whether new money it has laid

background because of you then at the heart of the

most lax alert and most low awareness and left it

godsend failed

!!!!!

46

the=4

it=3

you=3

and=2

are=2

is=2

most=2

of=2

when=2

your=2

words=""

whileTrue:

a=input()if a=="!!!!!":breaka=a.lower()for i in "!.,:*?":

a=a.replace(i,' ')

words=words+" "+a

words=words.split()

s={}for i inwords:if i ins:

s[i]+=1

else:

s[i]=1s=list(s.items())

s.sort(key=lambda x:x[0])

s.sort(key=lambda x:x[1],reverse=True)

print(len(s))for i in range(10):

word,count=s[i]

print("{}={}".format(word,count))

7-3 jmu-python-汇率兑换 (10 分)

$5 输出样例2: R30.00 a=""a=input()if a[0]=="R": print("${:.2f}".format(eval(a[1:])/6))else:

print("R{:.2f}".format(eval(a[1:])*6))

7-4 jmu-python-九九乘法表(矩形) (10 分)

1*1=1 1*2=2 1*3=3 1*4=4 1*5=5 1*6=6 1*7=7 1*8=8 1*9=9

2*1=2 2*2=4 2*3=6 2*4=8 2*5=10 2*6=12 2*7=14 2*8=16 2*9=18

3*1=3 3*2=6 3*3=9 3*4=12 3*5=15 3*6=18 3*7=21 3*8=24 3*9=27

4*1=4 4*2=8 4*3=12 4*4=16 4*5=20 4*6=24 4*7=28 4*8=32 4*9=36

5*1=5 5*2=10 5*3=15 5*4=20 5*5=25 5*6=30 5*7=35 5*8=40 5*9=45

6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36 6*7=42 6*8=48 6*9=54

7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49 7*8=56 7*9=63

8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64 8*9=72

9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81

for i in range(1,10):for j in range(1,10):

print("{}*{}={:<4}".format(i,j,i*j),end="")

print()

7-5 jmu-python-回文数判断(5位数字) (10 分)

13531

yes

13531

yes

13530

no

n =input()if n==n[::-1]:

print("yes")else:

print("no")

7-7 jmu-python-输入输出-处理不定行输入 (1 分)

while True:

try:

except:

break

1 2

bcd efg hij

x

2

3

1

whileTrue:

a=input()try:

a=a.split()if(len(a))>0:

print(len(a))

except:break

7-8 jmu-python-分段函数 (10 分)

0.76

f(0.76)=1.20

a=eval(input())if a<3:

print("f({:.2f})=1.20".format(a))

elif a==3:

print("f({:.2f})=10.00".format(a))else:

print("f({:.2f})={:.2f}".format(a,2*a+1))

7-9 jmu-python-判断是否构成三角形 (10 分)

3 4 5

yes

1 2 3

no

s=input().split()

a=int(s[0])

b=int(s[1])

c=int(s[2])

#a,b,c=int(input().split())if aabs(b-c) and babs(a-c) and cabs(a-b):

print("yes")else:

print("no")

7-10 jmu-python-分段函数1 (10 分)

725

f(725.000)=-1.000

import math

a=eval(input())if abs(a)>=300:

print("f({:.3f})=-1.000".format(a))else:

print("f({:.3f})={:.3f}".format(a,a**3/math.log(abs(a)+2.6,10)))

7-11 jmu-python-猜数游戏 (10 分)

N times to got it

4 10

7 times to got it

import random

a,x=map(int,input().split())

random.seed(x)

c=random.randint(1,10)

count=0

whileTrue:

count+=1

if c==a:

print("{} times to got it".format(count))break

else:

c=random.randint(1,10)

7-12 jmu_python_最大公约数&最小公倍数 (10 分)

12,14

GCD:2, LCM:84

import math

a,b=map(int,input().split(','))

print("GCD:{:}, LCM:{:}".format(math.gcd(a,b),int(a*b/math.gcd(a,b))))

7-13 jmu_python_是否是数 (10 分)

-299

yes

a=input()try:

a=eval(a)if type(a)==int or type(a)==float or type(a)==complex:

print("yes")else:

print("no")

except:

print("no")

7-14 jmu-python-输入输出-计算字符串中的数 (10 分)

2.1234 2.1 3 4 5 6

6

22.223

a=input().split()

print(len(a))

sum=0

for i ina:

sum+=eval(i)

print("{:.3f}".format(sum))

7-47 jmu-python-凯撒密码加密算法 (10 分)

Hello World!

3

Khoor Zruog!

s=input()

mod=int(input())

a="abcdefghijklmnopqrstuvwxyz"A="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i ins:if 'a'<=i<='z':

c=a.find(i)

print(a[(c+mod+26)%26],end='')

elif'A'<=i<='Z':

c=A.find(i)

print(A[(c+mod+26)%26],end='')else:

print(i,end="")

7-15 jmu-python-输入输出-格式化输出字符串 (10 分)

3.14159265

10

abc 123

3.14

3.141593e+00 3.141593E+00 314.16%

1010 a

ABC 123

abc 123

******abc 123*******

3.14159265 + 10 = 13.14159265

a=float(input())

b=int(input())

c=input()

print("{:.2f}".format(a))

print("{:e} {:E} {:.2%}".format(a,a,a))

print("{0:b} {0:x}".format(b))

c=c.strip()

print("{}".format(c.upper()))

print("{:>20}".format(c))

print("{:*^20}".format(c))

print("{} + {} = {}".format(a,b,a+b))

7-16 jmu-python-字符串-统计不同字符个数 (5 分)

Hi! 天气不错 二十八度 28℃。

10 3 2 3

a=input()

kong=0zhong=0num=0other=0

for i ina:ifi.isspace():

kong+=1elif i.isdigit():

num+=1elif i.isalpha():

zhong+=1

else:

other+=1print("{} {} {} {}".format(zhong,kong,num,other))

7-17 jmu-python-随机生成密码 (10 分)

n行密码，每行m位。

1

10

8

iK2ZWeqh

FWCEPyYn

gFb51yBM

WXaSCrUZ

oL8g5ubb

bPIa84yR

nBUbHoWC

8FJowoRo

WD8s7bA1

6J7PglOU

import random

importstringa=int(input())

random.seed(a)

n=int(input())

m=int(input())

s=list(string.ascii_letters+string.digits)for i inrange(n):for j inrange(m):

print(random.choice(s),end="")

print()

7-18 jmu-python-重复元素判定 (20 分)

True=包含重复元素的行数， False=不包含重复元素的行数

,后面有空格。

5

1 2 3 4 5

1 3 2 5 4

1 2 3 6 1

1 2 3 2 1

1 1 1 1 1

True=3, False=2

n=int(input())

f=0t=0

for i inrange(n):

s=set()

a=input().split()for j ina:

t+=1

else:

f+=1print("True={}, False={}".format(t,f))

7-19 jmu-python-生日悖论 (15 分)

rate=算出的比率，比率保留2位小数

3 1000

rate=0.54

import random

x,n=map(int,input().split())

random.seed(x)

f=0

for i inrange(n):

s=set()for j in range(23):

c=random.randint(1,365)

f+=1print("rate={:.2f}".format(f/n))

7-20 jmu-python-从列表中删除元素 (15 分)

5

1 1 1 2 1 2 1 1 1

1

1 1 1 2 2 2 1 1 1

2

ab ab ab cd cd de de

ab

1 1 1 1

1

x y x x x z

t

2 2

1 1 1 1 1 1

cd cd de de

x y x x x z

n=int(input())for i inrange(n):

s=[]

s1=[]

s=input().split()

c=input()for j ins:if j!=c:

s1.append(j)

print(' '.join(s1))

7-21 jmu-python-运算符-找钱 (10 分)

x = ?*10 + ?*5 + ?*1

5

109

17

10

3

0

109 = 10*10 + 1*5 + 4*1

17 = 1*10 + 1*5 + 2*1

10 = 1*10 + 0*5 + 0*1

3 = 0*10 + 0*5 + 3*1

0 = 0*10 + 0*5 + 0*1

n=int(input())for i inrange(n):

a=int(input())

a1=a//10

a2=(a-a1*10)//5

a3=(a-a1*10-a2*5)

print("{} = {}*10 + {}*5 + {}*1".format(a,a1,a2,a3))

7-22 jmu-python-异常-学生成绩处理中级版 (15 分)

3

1

2

3

All OK

3

1

#

b

2

3

Error for data #! Reinput

Error for data b! Reinput

n=int(input())

sum=0flag=0temp=nwhile n>0:

a=0a=input()try:

a=int(a)

sum=sum+a

n-=1except:

print("Error for data {}! Reinput".format(a))

flag+=1#n+=1)if flag==0:

print("All OK")

7-23 jmu-python-异常-学生成绩处理专业版 (25 分)

3

1

2

3

Total: 3

OK: 3

Error: 0

5

1

2

a

b 5

3

line 3 error for input " a "

line 4 error for input " b 5"

Total: 5

OK: 3

Error: 2

5

a

2

3

line 1 error for input " a"

end of files

Total: 3

OK: 2

Error: 1

n=int(input())

sum=0flag=0temp=n

count=0count1=0l=[]whileTrue:try:

l.append(input())

except:break

for i inrange(len(l)):

count+=1a=0a=l[i]try:

a=int(a)

sum=sum+a

count1+=1except:

print('line {} error for input "{}"'.format(count,a))

flag+=1

#if flag==0:#print("All OK")if count

print("end of files")

print("Total: {}".format(len(l)))

print("OK: {}".format(count1))

print("Error: {}".format(flag))

7-24 jmu-python-异常-学生成绩处理基本版 (15 分)

3

1

2

3

All OK

Process Completed

3

a b

Error for data " a b"! Break

Process Completed

3

1

a

Error for data "a"! Break

Process Completed

s=int(input())

sum=0count=0c=0

for i inrange(s):

a=input("")

b=a.strip()

flag=0

for j inb:if j not in ['0','1','2','3','4','5','6','7','8','9']:

flag+=1

if flag==0:

sum=sum+eval(b)else:

c=a

count+=1

break

if count==0:

print("All OK")

print("Process Completed")

print("Error for data \"{}\"! Break".format(c))

print("Process Completed")

7-25 jmu-python-逆序输出 (5 分)

a b c e f gh

ghfecba

['a', 'b', 'c', 'e', 'f', 'gh']

gh f e c b a

s=input().split()

print("".join(s[::-1]))

print(s)

print(" ".join(s[::-1]))

7-26 jmu-python-班级人员信息统计 (15 分)

abcdefghijab

1 2 3 4 5 6 7 8 9 10

1 2 3 a b c

1 5 10 a d e f

a

Total: 20

Not in race: ['4', '6', '7', '8', '9', 'g', 'h', 'i', 'j'], num: 9

All racers: ['1', '10', '2', '3', '5', 'a', 'b', 'c', 'd', 'e', 'f'], num: 11

ACM + English: ['1', 'a'], num: 2

Only ACM: ['2', '3', 'b', 'c']

Only English: ['10', '5', 'd', 'e', 'f']

ACM Or English: ['10', '2', '3', '5', 'b', 'c', 'd', 'e', 'f']

['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

ac=input()

bc=input()

acm=input()

eng=input()

zz=input()

as1=set(ac)

bs1=set(bc.split())

acm2=set(acm.split())

eng2=set(eng.split())

print('Total:'+str(len(as1)+len(bs1)))

notrace=list()for i inas1:if i not in acm2 and i not ineng2:

notrace.append(i)for i inbs1:if i not in acm2 and i not ineng2:

notrace.append(i)

print("Not in race:"+str(sorted(notrace))+", num:"+str(len(notrace)))

alltrace=list()for i inas1:if i in acm2 or i ineng2:

alltrace.append(i)for i inbs1:if i in acm2 or i ineng2:

alltrace.append(i)

print("All racers:"+str(sorted(alltrace))+", num:"+str(len(alltrace)))

both=list()for i inas1:if i in acm2 and i ineng2:

both.append(i)for i inbs1:if i in acm2 and i ineng2:

both.append(i)

print("ACM + English:"+str(sorted(both))+", num:"+str(len(both)))

acm3=list()for i inas1:if i in acm2 and i not ineng2:

acm3.append(i)for i inbs1:if i in acm2 and i not ineng2:

acm3.append(i)

print("Only ACM:"+str(sorted(acm3)))

eng3=list()for i inas1:if i not in acm2 and i ineng2:

eng3.append(i)for i inbs1:if i not in acm2 and i ineng2:

eng3.append(i)

print("Only English:"+str(sorted(eng3)))

dd=eng3+acm3

print('ACM Or English:'+str(sorted(dd)))if zz inas1:new=list(as1)new.remove(zz)

print(sorted(new))

elif zzinbs1:new=list(bs1)new.remove(zz)

print(sorted(new))

-27 jmu-python-分段函数&数学函数 (15 分)

3.14

f(3.140)=0.865

import math

a=float(input())

sum=0

if a>=1:

sum=(math.cos(a)+a*a)/(2.5+abs(a+math.log(100,math.e)))

elif a<=-1:

sum=math.e**aelse:

sum=math.sqrt(2-2*a)

print("f({:.3f})={:.3f}".format(a,sum))

7-28 输入列表，求列表元素和(eval输入应用) (10 分)

[3,8,-5]

6

l=[]

sum=0a=eval(input())for i ina:

sum+=i

print(sum)

7-30 列表数字元素加权和(1) (40 分)

[1,2,[3,4,[5,6],7],8]

72

a=input()

b=a

a=a.replace('[','')

a=a.replace(']','')

a=a.split(',')

#print(a)

count=0sum=0j=0

for i inrange(len(b)):if b[i]=='[':

count+=1elif b[i]==']':

count-=1elif b[i]==',':continueelif b[i+1]==','or b[i+1]==']':

sum+=int(a[j])*count

j+=1print(sum)

7-31 删除字符 (30 分)

Bee

E

result: B

n=input().strip()

a=input().strip()

n=n.replace(a.lower(),'')

n=n.replace(a.upper(),'')

print("result: {}".format(n))

7-32 输出10个不重复的英文字母 (30 分)

poemp134

This is a test example

Thisaexmpl

a=input()

a=a.split()

c=''.join(a)

d=list(set(list(c)))

count=0m=0d.sort(key=c.index)for i inrange(len(d)):if 'a'<=d[i]<='z' or 'A'<=d[i]<='Z':

count+=1

if count<10:

m+=1print(d[i],end='')

7-34 图的字典表示 (20 分)

{'O':{'A':2,'B':5,'C':4}}。用eval函数处理输入，eval函数具体用法见第六章内置函数。

4

{'a':{'b':10,'c':6}}

{'b':{'c':2,'d':7}}

{'c':{'d':10}}

{'d':{}}

4 5 35

n=int(input())

num=0sum=0

for i inrange(n):

dic=eval(input())for j indic:

temp=dic[j]for key intemp:

num+=1sum+=temp[key]

print("{} {} {}".format(n,num,sum))

7-35 字典合并 (40 分)

{1:3,2:5}

{1:5,3:7}

{1:8,2:5,3:7}

{"1":3,1:4}

{"a":5,"1":6}

{1:4,"1":9,"a":5}

a=dict(eval(input()))

b=dict(eval(input()))for i inb:if i not ina:

a[i]=b[i]else:

a[i]+=b[i]

print("{",end="")

s1=[i for i in a.keys() if type(i)==type(1)]

s2=[i for i in a.keys() if type(i)==type('a')]

s1.sort()

s2.sort()

c=0n=len(a)for i in s1+s2:

c+=1

if type(i)==type(1):

print("{}:{}".format(i,a[i]),end='')else:

print('"{}":{}'.format(i,a[i]),end='')if c!=n:

print(',',end='')

print("}")

• 0
点赞
• 0
收藏
觉得还不错? 一键收藏
• 0
评论
03-16 557
05-06 9235
03-13 3470
07-25 7460
01-09 1万+
11-01 93
07-27 303
03-13 1193
05-15 338
11-13 2550
07-26 255

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。