Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_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
5b50be17
authored
Aug 20, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
c7dcd746
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
19 deletions
tt1.py
tt2.py
tt1.py
View file @
5b50be17
def
new_input
():
totol
=
[]
while
True
:
unit
=
input
(
'请输入单价(q退出)'
)
if
unit
==
'q'
:
break
else
:
try
:
unit
=
int
(
unit
)
except
:
print
(
"输入一个数字"
)
else
:
totol
.
append
(
unit
)
finally
:
print
(
"-"
*
30
)
print
(
totol
)
new_input
()
\ No newline at end of file
tt2.py
View file @
5b50be17
...
@@ -5,6 +5,7 @@ except:
...
@@ -5,6 +5,7 @@ except:
print
(
"结束啦"
)
print
(
"结束啦"
)
total
=
[]
total
=
[]
def
csy
():
def
csy
():
while
True
:
while
True
:
...
@@ -14,6 +15,10 @@ def csy():
...
@@ -14,6 +15,10 @@ def csy():
else
:
else
:
total
.
append
(
unit
)
total
.
append
(
unit
)
csy
()
csy
()
print
(
total
)
print
(
total
)
...
@@ -36,3 +41,55 @@ def new_input():
...
@@ -36,3 +41,55 @@ def new_input():
print
(
totol
)
print
(
totol
)
new_input
()
new_input
()
def
new_input
():
totol
=
[]
while
True
:
unit
=
input
(
'请输入单价(q退出)'
)
if
unit
==
'q'
:
break
else
:
try
:
unit
=
int
(
unit
)
except
:
print
(
"输入一个数字"
)
else
:
totol
.
append
(
unit
)
finally
:
print
(
"-"
*
30
)
return
totol
abc
=
new_input
()
print
(
abc
[
1
])
def
new_input
():
totol
=
[]
while
True
:
unit
=
input
(
'请输入单价(q退出)'
)
if
unit
==
'q'
:
break
else
:
try
:
unit
=
int
(
unit
)
except
:
print
(
"输入一个数字"
)
else
:
totol
.
append
(
unit
)
finally
:
print
(
"-"
*
30
)
return
totol
abc
=
new_input
()
sum_a
=
0
for
i
in
abc
:
sum_a
=
sum_a
+
i
print
(
sum_a
)
\ No newline at end of file
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