Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson1_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
de350b88
authored
Feb 24, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
3191609e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
0 deletions
1.py
2.py
1.py
0 → 100644
View file @
de350b88
"""
print("hello world!")
#输入 食物名称
#input_food = input("今晚要吃什么:")
#输出 要吃的食物
#print("今晚我要吃_",input_food)
#整型变量
connter = 100
#浮点型变量
miles = 100.0
#字符串型变量
name = "bellcode"
#查看变量类型
print(type(connter))
print(type(miles))
print(type(name))
#连续赋值相同的值
a = b = c = 1
print(a)
print(b)
print(c)
#连续赋值相同的值
a,b,c = 1,2,3
print(a)
print(b)
print(c)
#算数运算符
x = 21
y = 8
#加运算
print("x+y=",x+y)
#减运算
print("x-y=",x-y)
#乘运算
print("x*y=",x*y)
#除运算
print("x/y=",x/y)
#取整除运算
print("x//y=",x//y)
#取余运算
print("x
%
y=",x
%
y)
#幂次方运算
print("x**y=",x**y)
width = int(input("三角形的底:"))
height = int(input("三角形的高:"))
print(type(width))
print(type(height))
print("三角形的面积为:",width*height/2)
#int(x)将x转换为一个整数
x = 2.7
#向下取整
print(int(x))
x = "2"
print(int(x))
#将x装换为一个浮点数
x = 2
print(float(x))
x = "9"
print(float(x))
#complex(x,y)
x = 2
y = 3
print(complex(x))
print(complex(y))
x = 21
#查看x的类型
print("第一次查看:",type(x))
#将整型装换成浮点型
x = float(x)
print("第二次查看:",type(x))
x = 21
y = 8
z = complex(x,y)
print(z)
print(type(z))
str1 = 'hahaha'
str2 = "lalala"
str3 = '''aaa'''
print(str1,str2,str3)
string = "Hello world!"
# 01234567891011
# -12-11-10-9-8-7-6-5-4-3-2-1
print("string[0]=",string[0])
print("string[-1]=",string[-1])
print("string[1:8]=",string[1:8]) #[1,8] 前闭后开
print("string[1:-3]=",string[1:-3]) #[1,-3] 前闭后开
#[::2]
print(string[::2])
#[1::2]
print(string[1::2])
#[::-1]
print(sting[::-1])
#[10::-3]
print(string[10::-2])
#[-10:-4:6]
print(string[-10:-4:6])
"""
#题目:截取"llo w"
string
=
"Hello world"
print
(
string
[
2
:
7
])
print
(
string
[
2
:
-
5
])
print
(
string
[
-
10
:
7
])
print
(
string
[
-
10
:
-
5
])
print
(
"string[2:7]="
,
string
[
2
:
7
])
print
(
"string[2:-5]="
,
string
[
2
:
-
5
])
print
(
"string[-10:7]="
,
string
[
-
10
:
7
])
print
(
"string[-10:-5]="
,
string
[
-
10
:
-
5
])
2.py
0 → 100644
View file @
de350b88
#输入 食物名称
input_food
=
input
(
"今晚要吃什么:"
)
#输出 要吃的食物
prin
(
"今晚我要吃_"
,
input_food
)
\ 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