1.使用while循环输入 1 2 3 4 5 6 8 9 10

# Author:Tony.lou
i = 1
while i < 11:
if i == 7:
pass
else:
print (i)
i+=1

2.求1-100所有的和

# Author:Tony.lou

i = 0
n = 0
while i <100:
tmp = i % 2
if tmp == 0:
n = n - i
else:
n = n + i
i = i + 1
print(n)
print(sum(i for i in range(1,101)))

3.输出1-100内所有基数

i = 0
while i < 101:
tmp = i % 2
if tmp != 0:
print(i)
else:
pass
i+=1
for i in range(1,100,2):
print(i)

4.求1-2+3-4+5..99所有数的和

# Author:Tony.lou

i = 0
n = 0
while i <100:
tmp = i % 2
if tmp == 0:
n = n - i
else:
n = n + i
i = i + 1
print(n)

5.用户三次登录

count = 0

while count < 3:
user = input('user:')
password = input('password:')
if user == 'tony' and password =='Omd':
print('welcome')
print('........')
break
else:
print('error..try again')
count += 1

Python 习题一的更多相关文章

  1. Python [习题] 文件操作:目录间copy 文件

    [习题] 指定一个源文件,实现copy到目标目录.例如把/tmp/sample1.txt 拷贝到/tmp/sample2.txt原文件需要有读权限(默认rt权限),目标文件需要给写(w即可)权限. I ...

  2. python习题实例(上)_update18/07/03

    用以记录python学习过程中做过的小习题~ ヾ(◍°∇°◍)ノ゙ 1.生成两个列表,分别存放将100以内的偶数&奇数 odd_number=[] even_number=[] for i i ...

  3. 笨办法学Python - 习题11-12: Asking Questions & Prompting People

    目录 1.习题 11: 提问 2.习题 12: 提示别人 3.总结 1.习题 11: 提问 学习目标:了解人机交互场景,熟悉raw_input 的用法. 1.在 Python2.x 中 raw_inp ...

  4. 笨办法学Python - 习题8-10: Printing & Printing, Printing

    目录 1.习题 8: 打印,打印 2.习题 9: 打印,打印,打印 3.习题 10: 那是什么? 3.1.转义序列: 4.习题总结: 1.习题 8: 打印,打印 学习目标:继续学习 %r 的格式化输出 ...

  5. 笨办法学Python - 习题6-7: Strings and Text & More Printing

    目录 1.习题 6: 字符串(string) 和文本 2.加分习题: 3.我的答案 4.习题总结 5.习题 7: 更多打印 6.习题总结 1.习题 6: 字符串(string) 和文本 学习目标:了解 ...

  6. 笨办法学Python - 习题5: More Variables and Printing

    1.习题 5: 更多的变量和打印 学习目标:了解用户输入方法,明白pthon2和Python3之间的用户输入的区别.了解格式化字符串(format string)的概念,学会如何创建包含变量内容的字符 ...

  7. 笨办法学Python - 习题4: Variables and Names

    1.习题 4: 变量(variable)和命名 学习目标:了解Python中变量的定义,学习定义简明易记的变量名 变量:变量是存储内存中的值,就是每定义一个变量就会在内存中开辟一个空间.基于变量的类型 ...

  8. 笨办法学Python - 习题3: Numbers and Math

    目录 习题 3: 数字和数学计算 算术运算符 加分习题: 我的答案: 总结: 扩展: Python比较运算符 Python赋值运算符 Python位运算符 Python逻辑运算符 Python成员运算 ...

  9. 笨办法学Python - 习题1: A Good First Program

    在windows上安装完Python环境后,开始按照<笨办法学Python>书上介绍的章节进行练习. 习题 1: 第一个程序 第一天主要是介绍了Python中输出函数print的使用方法, ...

  10. python习题20190130

    #encoding=utf-8 ''' 一家商场在降价促销.如果购买金额50-100元(包含50元和100元)之间,会给10%的折扣,如果购买金额大于100元会给20%折扣.编写一程序,询问购买价格, ...

随机推荐

  1. Valotile关键字详解

    在了解valotile关键字之前.我们先来了解其他相关概念. 1.1  java内存模型: 不同的平台,内存模型是不一样的,我们可以把内存模型理解为在特定操作协议下,对特定的内存或高速缓存进行读写访问 ...

  2. Ocelot概述

    Ocelot是一个基于netcoreapp2.0构建,.NET Core框架下的开源Api网关项目,用于开发基于.NET微服务架构或面向服务架构系统的统一入口.

  3. svn hotcopy backup

    ================== 备份 1/2 ==================svnbackup.bat@echo off@rem Subversion Server 的安装目录set SV ...

  4. y

    switch(update_state) { : switch(num){ : window.progressn=num $('#h_progress_bar .ui-progress').anima ...

  5. Redis(四)-持久化

    1.Redis将所有数据存储在内存中,从内存同步到磁盘上,就做持久化过程. 2.持久化有两种方式:rdb(Redis Database)和aof(Append of file) # rdb持久化方法: ...

  6. vue单位文本控件与vue加密文本控件

    vue单位文本控件: 使用方式: npm install dami-text-input --save 使用: <text-input v-model="test" :uni ...

  7. Django web框架-----Django templates模板

    说明:mytestsite是django框架下的项目,quicktool是mytestsite项目中的应用 一般的变量之类的用 {{ }}(变量),功能类的比如循环.条件判断是用 {% %}(标签) ...

  8. diango admin 添加成员报错

    [报错内容]: IntegrityError at /admin/users/userprofile/add/ (1452, 'Cannot add or update a child row: a ...

  9. js 格式化带时区的日期

    /** * 格式化带时区的日期 */ function formatDate(date) { var arr = date.split("T"); var d = arr[0]; ...

  10. Python3爬虫系列:理论+实验+爬取妹子图实战

    Github: https://github.com/wangy8961/python3-concurrency-pics-02 ,欢迎star 爬虫系列: (1) 理论 Python3爬虫系列01 ...