您的位置:首页 > 编程语言 > Python开发

Python第一周学习总结

2018-03-04 14:42 357 查看

Python概述

Python这门语言可以用Python之禅来形容其特点
''' python
import this
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
'''


Python的优缺点

优点:简单、直接、生态圈特别好、完美的平台可移植性

缺点:执行效率低下、无法进行加密

Python中变量的类型

1.整型(int)
2.字符串类型(string)
3.浮点型(float)
4.布尔型(Boolean)


Python中的运算符

1.赋值运算符:=
2.算数运算符:>、<、==、>=、<=、
3.逻辑运算符:and、or
4.身份运算符:is、is not


Python中的分支结构

练习

'''python
import math
num = random.randint()
if num > 3 :
print('你是个瓜皮')
else :
print('你在玩蛇')
'''


Python中的循环结构

练习

'''python
fish=1
while True:
total = fish
is_enough = True
for _ in range(5):
if (total - 1) % 5 == 0:
total = (total - 1) // 5 * 4
else:
is_enough = False
break
if is_enough:
print(fish)
break
fish += 1
'''
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: