zzy
12-python作业

12-python作业


        

Release

  • Setup
  • 安装包下载的文件默认在桌面上.

        

暂略

我的作业:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#-- codeing=utf-8 --
#@Time:2024-5-17
#@Author:zzy
#@File:12.py
#@Software:vscode

# 6-6
from math import pi

def circle6(r):
s = pi * r**2
c = 2*pi
return s, c
circle6(6)

# 6-1
def sayHello():
print('Hello World!')

# main
sayHello()

# 6-2
def say(s):
print(s)
say('Hello!')
say('How are you!')

# 6-3
def f(n):
s = 1
if n == 0:
pass
elif n > 0 and int(n) == n:
for i in range(1,n+1):
s *= i
else:
return '输入有误'
return f'{n}!={s}'

print(f(6))
print(f(16))
print(f(26))
for i in range(5,1,-1):
print(i)

# 12-2
def sushu(n):
for i in range(2,int(n/2)):
if n % i == 0:
print('不是素数')
return 0
print('是素数')
return 1
sushu(int(input()))

# 12-3
for i in range(100,1000):
s = 0
for j in str(i):
s += int(j)**3
if s == i:
print(i)
本文作者:zzy
本文链接:http://周梓煜.com/2024/05/21/school-hhw-12-python/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可