Python基础学习-2

版权声明:文章版权归本博客所以未经许可不能转载 https://blog.csdn.net/u011738045/article/details/82423843

变量的定义使用

score = 100#定义了一个变量,这个变量的名字叫做score,它里面存储了一个数值 100
high = 180#单位是cm

applePrice = 3.5 #苹果的价格 元/斤
weight = 7.5 #购买的苹果的重量 斤

money = applePrice * weight#如果money=xxxx是第一次的话,那么就表示定义了一个变量

money = money - 10#如果 money=xxxx不是第一次出现,那么就不是定义变量,而是给这个已经存在的变量赋上一个新的值

input输入

high = input("请输入你的身高:")

print打印

print("hello world")

age = 18
print("age变量里的值是%d"%age)

name = "东哥"
print("名字是:%s"%name)

其中%s代表占位符

%s代表stinrg类型,%d代表数值类型

python2中用的raw_input来使用,Python3中没有直接是input,这是他们之间的区别

猜你喜欢

转载自blog.csdn.net/u011738045/article/details/82423843
今日推荐