Python一学就会系列:02 输出输入及数据类型

系列文章目录

Python一学就会系列:01 开发环境搭建 及 hello world



一、输出

用print()在括号中加上字符串,就可以向屏幕上输出指定的文字

print('hello, world')

结果:hello, world

多个字符逗号隔开

 print('hello', 'world') 

结果:hello world

可以进行简单的表达式计算

print('300 + 200 =', 300 + 200)

结果:300 + 200 = 500

二、输入

Python提供了一个input(),可以让用户输入字符串,并存放到一个变量里

name = input()
print('input: ', name)

命令行输入:‘Hello’ 然后 回车
运行结果:
input Hello

三、数据类型

  1. 数值:跟任意大小的整数、小数等数值
    如:99999 , -10 , 3.1415926等
  2. 字符串:以引号( “” 或 ‘’ )括起来的文本
    如:
a = 'abc'
b = "test"
print(a, b)
  1. 布尔类型:两种值 True和False 注意首字母大写
    如:
# and 且运算
print(True and True)     # True
print(True and False)     # False

# or 或运算
print(True or True)     # True
print(True or False)     # True

# not 非运算
print(not False)     # True
print(not True)     # False


总结

以上就是今天要讲的内容,本文仅仅简单介绍了python的输出输入及数据类型,python更多知识,后续文章,我将带大家慢慢深入了解。

如果觉得有用欢迎 点赞 关注
有问题私信我!!~~

猜你喜欢

转载自blog.csdn.net/u012551928/article/details/128646779