python基础学习1

为什么不把硬盘全换成内存呢?

因为内存断电会消失,成本高

 

打开QQ的过程:点击QQ——操作系统加载.exe文件到内存——CPU运行执行

python 2.4 2004年 Django诞生

2008年 python 2.6 和python 3.0同时出现

python 3比python 2更统一,去除重复代码

 

python是动态解释性强类型语言

 

cmd运行: python+空格+路径   如:python d:t1.py

 

几个例子:

 

1.使用while循环打印1 2 3 4 5 6 8 9 10
count = 0
while (count < 10):
    count = count+1
    if count == 7:
        continue #pass也可以
    else:
        print(count)
2.输入1-100内所有奇数
count = 1
while (count<101) :
    print(count)
    count + = 2
3.求1-2+3-4+5....99的所有数的和
count = 1
sum = 0
while (count < 100):
    if count % 2 == 1:
        sum = sum + count
    else:
        sum = sum - count
    count += 1
print(sum)
4.登录界面三次机会
i=0
while(i<3):
    username = input("请输入一个用户名账号:")
    password = input("请输入密码:")
    if username == 'yangyang' and password == '1989':
        print("登陆成功!!!")
    else:
        print("登录失败!!")
    i += 1

 

posted @ 2019-08-21 11:26  酸奶有点甜1989  阅读(129)  评论(0编辑  收藏  举报