Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
afc503cc
authored
Feb 17, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
5a18a3a1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
3 deletions
erji.py
erji.py
View file @
afc503cc
...
...
@@ -101,7 +101,7 @@ while True:
提示用户输入两个正整数,编程求出介于这两个数之间的所有质数并打印输出。
显示格式为"*数是质数。"
'''
'''
a = int(input("请输入开始值:"))
b = int(input("请输入结束值:"))
c = min(a,b)
...
...
@@ -110,13 +110,12 @@ d = max(a,b)
for n in range(c+1,d):
f = "质数"
for i in range(2,n):
# print(n,"/",i)
if n
%
i==0:
f = "不是质数"
break
if f == "质数":
print(str(n)+"数是质数")
'''
...
...
@@ -155,6 +154,64 @@ while True:
'''
'''
所谓"水仙花数"是指一个三位数,这个三位数各个数位上数字的立方和等于该数本身。
例如:153是一个"水仙花数",因为153=13+5+33。编写程序,计算200到500之间的水仙花数共有多少个。
'''
'''
s = 0
for i in range(200,501):
a = i//100
b = (i-a*100)//10
c = (i-a*100-b*10)
if a**3 + b**3 + c**3 == i:
s+=1
print(s)
'''
# for num in set(1236):
# print(num)
# n = (1,2,3,4)
# n.append(8)
# print(n)
# a=input("请输入字母或数字")
# if ord('a')<=ord(a)<=ord('z') or ord('A')<=ord(a)<=ord('Z'):
# print('字母')
# else:
# print('数字')
# from time import time as tim
# print(tim.time())
class
shopping
:
def
__init__
(
self
,
name
,
money
):
self
.
name
=
name
self
.
money
=
money
self
.
pen
=
0
def
buy
(
self
):
while
self
.
money
>
10
:
self
.
money
=
self
.
money
-
7
self
.
pen
=
self
.
pen
+
1
return
self
.
money
n
=
int
(
input
())
a
=
shopping
(
'Xiaoming'
,
n
)
print
(
a
.
buy
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment