python 基础命令
print 功能–打印
print 打印输出字符串 要加” 或者“” 例:
print('hello world')
print("hello world 2")
print 字符串叠加 : print('Hello world'+' Hello Hong Kong')
int() 和 float();
当int()一个浮点型数时,int会保留整数部分,比如 int(1.9),会输出1,而不是四舍五入。
变量 variable
自变量命名规则
可以将一个数值,或者字符串串附值给自变量,如apple = 1
中,apple
为自变量的名称,1
为自变量的值。 也可以将字符串赋值给自变量 apple = 'iphone7 plus'
apple=1 #赋值 数字
print(apple)
""""
1
""""
如果需要用多个单词来表示自变量,需要加下划线,如apple_2016='iphone 7 plus'
请看代码
apple_2016='iphone 7 plus and new macbook'
print(apple_2016)
""""
iphone 7 plus and new macbook
""""
一次定义多个自变量 a,b,c=1,2,3
。
a,b,c=11,12,13
print(a,b,c)
""""
11 12 13
""""