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
86e78e9a
authored
Feb 09, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
e21ed867
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
9 deletions
2.py
3.py
4.py
func.py
x.py
2.py
0 → 100644
View file @
86e78e9a
try
:
age
=
int
(
input
(
"你今年几岁了"
))
except
:
print
(
"要输入整数啊"
)
else
print
(
"程序结束"
)
\ No newline at end of file
3.py
0 → 100644
View file @
86e78e9a
try
:
age
=
int
(
input
(
"你今年几岁了"
))
except
:
print
(
"要输入整数啊"
)
else
:
if
age
<
18
:
print
(
"不可以喝酒哦"
)
print
(
"程序结束"
)
\ No newline at end of file
4.py
0 → 100644
View file @
86e78e9a
def
new_input
():
#新建一个函数
total
=
[]
#建立一个空价格列表
while
True
:
unit
=
input
(
"请输入(q退出):"
)
#输入内容的提示
if
unit
==
"q"
:
#如果输入q
break
#终止程序
else
:
#否则
try
:
unit
=
int
(
unit
)
#输入一个整数
except
:
print
(
"请输入一个数字"
)
#如果我输入的不是整数的提示
else
:
total
.
append
(
unit
)
#如果我输入的是整数的话就把这个整数添加到total中
print
(
"-"
*
30
)
#一个分界线
print
(
total
)
#输出现在的价格
new_input
()
#调用函数
\ No newline at end of file
func.py
View file @
86e78e9a
total
=
[]
while
True
:
unit
=
input
(
"请输入:"
)
if
unit
==
'q'
:
break
else
:
total
.
append
(
unit
)
print
(
total
)
\ No newline at end of file
dict_hero
=
{
'猴三'
:
10
,
'猴一'
:
21
,
'猴五'
:
22
,
'猴队长'
:
30
}
print
(
dict_hero
)
\ No newline at end of file
x.py
0 → 100644
View file @
86e78e9a
list_hero
=
[
'赵一'
,
30
,
'丁二'
,
37
,
'孙五'
,
52
,
'王猛'
,
89
,
'周亮'
,
98
]
dict_hero
=
{
'赵一'
:
30
,
'丁二'
:
37
,
'孙五'
:
52
,
'王猛'
:
89
,
'周亮'
:
98
}
print
(
len
(
list_hero
))
print
(
len
(
dict_hero
))
\ 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