zoukankan      html  css  js  c++  java
  • python入门_老男孩_习题_day1 + day 2

    试写出下面的结果

    1 8 or 3 and 4 or 2 and 0 or 9 and 7 # 8
    2 6 or 2>1 #6
    3 0 or 5<4 #False
    4 3 and 2>1 #True
    5 0 and 3>1 #0

    简述变量命名规范

    • 数字,字母下划线组成/ 不能有其他特殊字符
    • 不能以数字开头
    • 不能是汉字
    • 变量具有可描述性

    两种方式

      birthOfChina  birth_of_china

    name = input('>>>')name变量是什么数据类型

    str

    故后续用到该变量时,最好事先转变类型int,以避免错误

    age = int(input('>>>'))

    if条件语句的基本结构

    while语句的基本结构

     1 # 从0开始计数,循环不超过10次
     2 count = 0
     3 while count < 10:
     4     pass
     5     count += 1
     6 
     7 # 从1开始计数,循环不超过10次
     8 count = 1
     9 while count <= 10:
    10     pass
    11     count += 1

    写代码:计算1-2+3...+99中除了88以外的所有数的和

     1 count = 1
     2 sum = 0
     3 
     4 while count < 100:
     5     if count%2 != 0:
     6         sum = sum + count
     7     else:
     8         if count == 88:
     9             count += 1
    10             continue
    11         else:
    12             sum = sum - count
    13     count += 1

    写代码:计算1-2+3...-99中除了88以外的所有数的和,注意88之后变号

     1 i = 0
     2 j = -1
     3 sum = 0
     4 
     5 while i <99:
     6     i += 1
     7     if  i == 88:
     8         continue
     9     else:
    10         j = -j
    11         sum = sum + i*j
    12 print(sum)

    用户登录(三次输错机会)且每次输错误时显示剩余的错误次数(使用字符串格式化)

    简述ascii,unicode,utf-8编码关系

  • 相关阅读:
    我们在期待什么?
    ASP.NET的本质–IIS以及进程模式
    javascript开发中要注意的事情
    通过配置web.config发电子邮件详解
    VS2005 中文版下载
    td自动换行CSS
    巧妙利用图片IMG的onerror事件
    网页 页面不缓存
    JS检测对像(支持多版本)
    利用js预缓存图片
  • 原文地址:https://www.cnblogs.com/dignity/p/9726365.html
Copyright © 2011-2022 走看看