首页 > 编程语言 > 详细

python入门学习之变量篇

时间:2016-01-26 01:44:46      阅读:300      评论:0      收藏:0      [点我收藏+]

【前言】

在公司内部wiki上看到一个不错的学习网站,遂开始了我这慢悠悠的学习之旅。

网站链接:https://www.codecademy.com


1.理解布尔值

一种数据类型。

简单来说,正如你家里的电灯有开关两种状态一样,布尔值

同样也有两个值,即为True和False。

你可以使用变量来存储布尔数据。

a = True 
b = False

2.实战

以下为网站给出的任务:

Set the following variables to the corresponding values:

    my_int to the value 7
    my_float to the value 1.23
    my_bool to the value True

完成如下:

# Set the variables to the values listed in the instructions!
my_int = 7
my_float = 1.23
my_bool = True
print ‘The three variables are as follows ‘,my_int,my_float,my_bool

输出结果:

技术分享

3.总结

1)变量前后都要保持一个空格。

2)变量名之间用下划线_隔开,当然也可以使用驼峰式(VarName)。

3)True与False的第一个字母要大写。


BTW,这种学习风格有点像打游戏冲关式的,让人沉迷于其中。

python入门学习之变量篇

原文:http://xoyabc.blog.51cto.com/7401264/1738499

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!