没有合适的资源?快使用搜索试试~ 我知道了~
首页Python3程序设计课后习题参考答案.pdf.pdf
Python3程序设计课后习题参考答案.pdf.pdf
需积分: 50 2.8k 浏览量
更新于2023-05-27
评论 5
收藏 3.29MB PDF 举报
Python 3 程序设计课后习题答案 译作者: 唐永华 刘德山 李玲 出版社:人民邮电出版社
资源详情
资源评论
资源推荐

C C C C D B C
1 Python
Python .py Python .py
.pyc Python (PVM)
2 IDLE 5
Ctrl + [
Ctrl + ]
Alt+3
Alt+4
Alt+/
Alt+P
Alt+N
F1
Python
F5
Ctrl+F6
Shell
3
(Interpreter)
4 IPO
IPO (Input) (Process) (Output)3

1 1-3
# ex0101.py
# s
import math
a=eval(input(" "))
h=eval(input(" "))
s = a*h/2
print(" {:.2f}".format(s))
2 1-6
# ex0102.py
lst=['hi',"program",'school','for','''chinese''']
lst1=[]
for item in lst:
lst1.append(len(item))
p=max(lst1)
for item in lst:
if len(item)==p:
print(item,end=" ")
3
D D D D D A C A
1 Python
● Python _
●
●
●
2
( OB Ob ) ( 0o 0O ) ( Ox
OX )
bin(),hex(),oct()
3 Python
Number Python
4

1
x=eval(input(" A "))
y=eval(input(" B "))
z=eval(input(" C "))
print("3 {} {}".format((x+y+z)/3,x+y+z))
2
# s
import math
a=eval(input(" a "))
b=eval(input(" b "))
c=eval(input(" c "))
p = (a + b + c) / 2
s = math.sqrt(p * (p - a) * (p - b) * (p - c))
print(" {:.2f}".format(s))
B A B B
1 3
Python (
)
2 format()
str.format() str {}
format() str format() 3
{}
{}
format()
format()
3
split(sep, num) sep num num
join(seq) seq ( )

1
sentence='''resident Xi Jinping urged all-out efforts
to achieve the goal of eliminating poverty in China within two
years in his three-day inspection tour of Chongqing, which ended on Wednesday.
'''
sentence=sentence.replace(","," ")
sentence=sentence.replace("."," ")
words=sentence.split()
print(len(words))
2 E
sentence='''residEnt Xi Jinping urgEd all-out Efforts'''
print(sentence.replace("E"," "))
3 18 2001 09 12
xx=input("IDCard Number:")
print(xx[6:10]+" "+xx[10:12]+' '+xx[12:14]+" ")
D A A D A D B D
1 pass
pass pass
2 break continue
break
continue
continue
3 for while
for
range()
3.
1 s c c
c c
s="abc32TT9ac"
t=""
for i in range(len(s)):
if s[i].islower():
t+=s[i].upper()

elif s[i].isupper():
t+=s[i].lower()
else:
t+=s[i]
print(t)
2
num=eval(input(" "))
s=str(num)
print(s[::-1])
3 1
2
-2
2
+3
2
-4
2
+ +97
2
-98
2
+99
2
s=0
flag=1
for i in range(1,100):
s=s+i*i*flag
flag*=-1
print(s)
4 6 1 2 3,
6=1+2+3 6 100
for num in range(1,100):
t=0
s=""
for i in range(1,num//2+1):
if num%i==0:
t+=i
s+=str(i)+" "
if t==num:
print("{} {}".format(t,s))
5 m n
m=eval(input(" m:"))
n=eval(input(" n:"))
if m<n:m,n=n,m
t=m*n
r=m%n
while r!=0:
m=n
n=r
r=m%n
print(" {}".format(n))
print(" {}".format(int(t/n)))
B A D C D C D C D D
剩余25页未读,继续阅读











安全验证
文档复制为VIP权益,开通VIP直接复制

评论0