1.定义7种基本类型的变量,并输出类型和id
int_var = 1
float_var = 1.1
complex_var = 7+7j
str_var = 123
bytes_var = bytes
bool_var = True
none_var = None
print(type(int_var))
print(type(float_var))
print(type(complex_var))
print(type(str_var))
print(type(bytes_var))
print(type(bool_var))
print(type(none_var))
print(id(int_var))
print(id(float_var))
print(id(complex_var))
print(id(str_var))
print(id(bytes_var))
print(id(bool_var))
print(id(none_var))
运行结果:
<class 'int'>
<class 'float'>
<class 'complex'>
<class 'int'>
<class 'type'>
<class 'bool'>
<class 'NoneType'>
2381660711216
2381667140880
2381668800240
2381660903600
140719310069840
140719310067816
140719310118104
2.使用四种形式定义字符串
one_var = "123"
two_var = '123'
three_var = '''123'''
four_var = """"123"""
print(type(one_var))
print(type(two_var))
print(type(three_var))
print(type(four_var))
运行截图:
<class 'str'>
<class 'str'>
<class 'str'>
<class 'str'>
打印 I'm a good boy/girl
print("I'm a good boy")
I'm a good boy
打印 "666"
print('666')
666
且将两次要print的内容输出在同一行
print("I'm a good boy", end="")
print(' 666', sep=" ")
3.画出序列:存储的是1234567890,画出对应的正向下标和负向下标