• python全栈第一章


    第一章 Python基础
    变量定义规则:
    1、变量名只能是字母数字或者下划线的任意组合
    2、变量名的第一个字符不能是数字
    3、关键字不能申明为变量名
    定义方式:
    1、驼峰体AgeOfSzp
    2、下划线隔开Age_of_Szp
    (推荐用第二种下划线隔开的方式)
    变量:会变化的量
    程序员约定俗成用变量名全部大写表示常量
    '''
    # name=input('what is your name ?')
    # print('hell0,'+name)
    ####格式化输出
    # name=input('please input your name ')
    # age=input('please input your age ')
    # hometown=input('please input your hometown ')
    # print('my name is {},and i am {} years old .I am from {}'.format(name,age,hometown))
    # print('my name is %s,and i am %s year old '%(name,age))
    ##前面用大括号,后面用点format传参
    '''

    基本数据类型:
    数字:在python2当中,有整型int和长整型long之分,但是在Python3中,全部都是int,在Python3中,如果整数发生溢出,Python会自动将整数数据类型转换为长整数
    字符串:在Python中,加了引号的字符都被认为是字符串
    列表:
    字典:
    '''
    '''
    基本运算符:
    +加法,也可以用于字符串的相加
    -减法
    *乘法
    /单纯的除法,保留相应位的小数
    %相除返回余数
    **幂运算 次方
    //相除取整数,返回商,

    '''
    # a=3
    # b=7
    # print(b//a)
    # i=1
    # while i<4:
    # score=int(input("请输入一个分数,在0-100之间"))
    # if score>=90:
    # print('A')
    # elif score>=80:
    # print('B ')
    # elif score >=70:
    # print("C")
    # elif score >=60:
    # print("D")
    # elif 0<=score<60:
    # print("成绩太差了")
    # else:
    # print('输入无效,请重新输入')
    # i+=1
    # count=0
    # list1=[]
    # while count<=100:
    # if count%2==0:
    # # print("LOOP",count)
    # list1.append(count)
    # count+=1
    # print(list1)
    """
    循环终止语句:
    break:用于完全结束一个循环,跳出循环体执行循环后面的语句。
    continue:终止本次循环,接着执行后面的循环。
    """
    # count=1
    # while count <=5:
    # print("loop",count)
    # if count==5:
    # # break
    # continue
    # if count==6:
    # break
    # count+=1
    #
    # print("___out of while loop ")
    # count=0
    # while count<=100:
    # count+=1
    # ##只要count 在6-94之间,就不走下面的print语句,直接进入下一次loop
    # if count>5 and count <94:
    # continue
    # print("LOOP:",count)
    # print("------------out of while loop--------------")


    """
    # while else
    # 当while循环正常执行完,中间没有被break中止的话,就会执行else后面的语句。
    # """
    # count=0
    # while count <=5:
    # count+=1
    # print("LOOP:",count)
    # # if count==3:
    # # break
    # else:
    # print("循环正常执行完了")
    # print("-------------out of whlie loop------------------")
    '''
    课后练习

    '''
    # i=0
    # list1=['seven','alex']
    # while i<3:
    # a=input("please input your username")
    # b=int(input("please input your password"))
    # if a in list1 and b==123:
    # print('登陆成功')
    # i+=1
    # else:
    # print("登陆失败")
    # i+=1
    # i=2
    # sum=0
    # while i<101:
    # sum=sum+(-1)**i*i
    # i+=1
    # print(sum)
    # """
    # 下面这段程序有问题,功能是用while输出12345789 d
    # """
    # i=1
    # list1=[]
    # while i<13:
    # if i!=6 and i!=10:
    # list1.append(i)
    # i+=1
    # if i ==13:
    # list1.append("d")
    # i+=1
    # print(list1)
    # i=1
    # while i<101:
    # if i%2==1:
    # print(i)
    # i+=1
    name=input('please input a name')
    palace=input('please input a palace')
    thing=input('please input a thing ')
    print("{}最喜欢在{}{}".format(name,palace,thing))
    print("%s最喜欢在%s%s" %(name,palace,thing ))



  • 相关阅读:
    ThinkPHP5 API 文档
    【转】移动web页面使用字体的思考
    【原】移动web页面兼容处理的思考
    20140829分享正则大纲
    javascript reverse string
    备忘“与”、“非”、“或”、“异或” 运算
    关于 Apple Metal API 的一些想法
    transform:rotate在手机上显示有锯齿的解决方案
    JS正则表达式验证数字(很全)
    去掉 wap (android/ios)网页等点击后的阴影
  • 原文地址:https://www.cnblogs.com/1832921tongjieducn/p/10422192.html
Copyright © 2020-2023  润新知