python学习笔记(一)

第三讲变量和字符串

1.      变量名能以数字开头

2.      变量名大小写敏感

3.      字符串可以是“  也可以是  ’

4.      转意符 \  : print(‘let\’s go!’)  

Print(“let’s go!”)  #不用转意符的

Str=’C:\\PR\\casdasd\\cascassss\\ccccc’

#简便方式(添加“r”,原始字符串):Str = r’C:\PR\casdasd\cascassss\ccccc’

 

5.       字符串多行内容:“”“内容”“”

第四讲 改进小游戏

1.      比较操作符号:

2.      条件分支:

If 条件

           操作

else

           操作

3.      While循环:

While 条件

           操作

4.      小游戏代码:

#注意缩进风格(暂定采用四个空格!)

import random

secret =random.randint(1,10)

 

print("------游戏1.0-----")

 

temp =input("请输入数字:")

guess =int(temp)

 

while guess !=secret:

   

 

    if guess == secret:

        print("win!")

    else:

        if guess > secret:

            print("大了!")

        else:

            print("小了")

    temp = input("再猜猜看:")

    guess = int(temp)

print("GAMEOVER!")

 

第五讲 数据类型

1.      整形:pathon 3整合了长整形

2.      类型转化:

a)        int()

b)        str()

c)        float()

3.      显示类型type()

Isinstance(a,int) #返回True或者False

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值