Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-5_DIY1
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
6523013a
authored
May 22, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
6fb0524b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
36 deletions
d少年.py
圆.py
是.py
爱心.py/19.py
玩儿.py
第二题.py
d少年.py
View file @
6523013a
a
=
int
(
input
(
"请输入A:"
))
import
random
a
=
int
(
input
(
"请输入A:"
))
b
=
int
(
input
(
"请输入B:"
))
c
=
int
(
input
(
"请输入C:"
))
D
=
(
a
+
b
)
*
c
print
(
D
)
import
random
a
=
[]
for
i
in
range
(
10
):
a
.
append
(
random
.
randint
(
1
,
99
))
print
(
a
)
print
(
max
(
a
))
\ No newline at end of file
圆.py
View file @
6523013a
-- "a/\345\234\206.py"
c
=
input
(
"请输入一个字符:"
)
身份
c
=
input
(
"请输入一个字符:"
)
身份
f
=
int
(
input
(
"请输入金额:"
))
e
=
0
if
c
==
"d"
:
e
=
f
*
0.7
elif
c
==
"g"
:
e
=
f
*
0.8
elif
c
==
"h"
:
e
=
f
*
0.9
elif
c
==
"i"
:
e
=
f
*
0.95
print
(
e
)
是.py
View file @
6523013a
def
hello
(
name
):
class
Hero
:
def
hello
(
name
):
content
=
"你好!"
+
name
return
content
result
=
hello
(
"小依"
)
print
(
result
)
\ No newline at end of file
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
1
self
.
name
=
name
self
.
hp
=
hp
self
.
attack
=
attack
yase
=
Hero
(
"亚瑟"
,
300
,
20
)
houyi
=
Hero
(
"后羿"
,
240
,
27
)
print
(
"亚瑟的血量为:"
,
yase
.
hp
)
print
(
"后羿的血量为:"
,
houyi
.
hp
)
def
upgrade
():
yase
.
level
=
yase
.
level
+
1
yase
.
hp
=
yase
.
hp
+
50
yase
.
attack
=
yase
.
attack
+
5
lubu
=
Hero
(
"吕布"
,
320
,
20
)
print
(
"吕布的血量为:"
,
lubu
.
hp
)
\ No newline at end of file
爱心.py/19.py
View file @
6523013a
A
=
int
(
input
(
"a"
))
with
open
(
r"C:\Users\lenovo\Desktop\Yui.txt"
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
A
=
int
(
input
(
"a"
))
if
A
>
0
:
print
(
"positive"
)
if
A
=
0
:
print
(
"zero"
)
if
A
<
0
:
print
(
"negative"
)
\ No newline at end of file
with
open
(
r"C:\Users\lenovo\Desktop\Yui.txt"
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
a
=
file
.
readlines
()
final_sum
=
[]
for
i
in
a
:
data
=
i
.
split
()
sum
=
0
for
sales
in
data
[
1
:]:
sum
=
sum
+
int
(
sales
)
result
=
data
[
0
]
+
str
(
sum
)
+
'
\n
'
final_sum
.
append
(
result
)
with
open
(
r"C:\Users\lenovo\Desktop\Yui.txt"
,
'w'
,
encoding
=
'utf-8'
)
as
file
:
file
.
writelines
(
final_sum
)
玩儿.py
View file @
6523013a
new_date
=
''
new_data
=
''
new_date
=
''
filel
=
open
(
r"C:\Users\lenovo\Desktop\xxxx.txt"
,
'w'
,
encoding
=
'utf-8'
)
filel
.
write
(
'小强:10本
\n
'
)
filel
.
write
(
'李明:15本
\n
'
)
filel
.
write
(
'小兰:12本
\n
'
)
for
date
in
filel
:
if
'小强:10本'
in
a
:
date
=
date
.
replace
(
'小强:10本'
,
'小强:11本'
)
print
(
"在文件中"
)
filel
.
close
()
new_data
=
''
with
open
(
r"C:\Users\lenovo\Desktop\xxxx1.txt"
,
'w'
,
encoding
=
'utf-8'
)
as
file1
:
file1
.
write
(
'小强:10本'
)
with
open
(
r"C:\Users\lenovo\Desktop\xxxx1.txt"
,
'r'
,
encoding
=
'utf-8'
)
as
file1
:
for
data
in
file1
:
if
'小强:10本'
in
data
:
data
=
data
.
replace
(
'小强:10本'
,
'小强:11本'
)
new_data
+=
data
with
open
(
r"C:\Users\lenovo\Desktop\xxxx1.txt"
,
'w'
,
encoding
=
'utf-8'
)
as
file1
:
file1
.
write
(
new_data
)
#with open(r"C:\Users\lenovo\Desktop\xxxx.txt",'a',encoding='utf-8') as file:
#file.write('小兰:12本\n')
...
...
第二题.py
View file @
6523013a
for
i
in
range
(
4
):
for
i
in
range
(
4
):
...
...
@@ -4,4 +4,5 @@ for i in range(4):
for
k
in
range
(
4
-
i
,
4
):
print
(
"x"
,
end
=
" "
)
print
(
""
)
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