if语句题目练习
#print("您好")
#
# count=1 #count 表示计数
# while count<=8:
# print("你是小学僧吗?")
# print("托儿所,儿童劫")
# count=count+1
# while True:
# s=input("请输入你喷的内容:")
# if s=="q":
# break
# if "马化腾" in s:
# print("这是一个赚取人名币的坑人玩家,输入有误")
# continue
# print("你喷的内容是"+s)
# count=1
# sum=0
# while count <=100:
# sum = sum + count
# count = count + 1
# print(sum,type(sum))
# count=1
# sum=0
# while count<=100:
# if count%2 !=0:
# sum=sum+count
# count=count+1
# print(sum)
# count=1
# sum=0
# while count<=100:
# sum=sum+count
# count=count+2
# print(sum)
# name1=input("请输入英雄联盟的人物角色名")
# name2=input("请输入该英雄人物的外号")
# age=input("请输入英雄的大致年龄")
# gender=input("请输入他或她的性别")
# hobby=input("请输入他或她的爱好")
# skill=input("请输入他的技能大招")
# a=int(input("请输入英雄胜率排名名次"))
#print("年龄为%s的英雄联盟角色%s外号叫%s性别为%s喜欢%s,并且其大招%s能够对敌方英雄造成200%%的伤害,胜率排名第%d" % (age,name1,name2,gender,hobby,skill,a))
print(1 < 2 and 3 < 4 or 1>2 ) # T
print(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # T
print(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) # F
print(1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6)
print(not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F
#1.判断下列语句的True和False
# 1)1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6 结果为True
# print(1>1or 3<4 or 4<5 and 2>1 and 9>8 or 7<6)
# 2)not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6 结果为False
# print(not 2>1 and 3<4 or 4>5 and 2>1 and 9>8 or 7<6)
#2、求出下列逻辑语句的值。
# 1),8 or 3 and 4 or 2 and 0 or 9 and 7 值为8
# 2),0 or 2 and 3 and 4 or 6 and 0 or 3 值为4
#print(8 or 3 and 4 or 2 and 0 or 9 and 7)
#print(0 or 2 and 3 and 4 or 6 and 0 or 3)
# 3、下列结果是什么?
# 1)、6 or 2 > 1 结果为6
# 2)、3 or 2 > 1 结果为3
# 3)、0 or 5 < 4 结果为False
# 4)、5 < 4 or 3 结果为3
# 5)、2 > 1 or 6 结果为True
# 6)、3 and 2 > 1 结果为True
# 7)、0 and 3 > 1 结果为0
# 8)、2 > 1 and 3 结果为3
# 9)、3 > 1 and 0 结果为0
# 10)、3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2 结果为2
#4、while循环语句句基本结构?
# while 条件:
# 代码块1(循环体)
# else:
# 代码块2
# 判断条件是否为真,若条件为真,则执行代码块1.
# 再次判断条件是否为真,直到条件为假时,执行else代码块2跳出循环体.
# 5、利用while语句写出猜大小的游戏:
# 设定一个理想数字比如:66,让用户输入数字,如果比66大,
# 则显示猜测 的结果大了;如果比66小,则显示猜测的结果小了;
# 只有等于66,显示猜测结果 正确,然后退出循环。
# while True:
# num=int(input("请输入一个数字"))
# if num==66:
# # print("猜测正确")
# # break
# # if num>66:
# # print("结果大了")
# # continue
# # if num<66:
# # print("结果小了")
# continue
# 6、在5题的基础上进行升级: 给用户三次猜测机会,
# 如果三次之内猜测对了,则显示猜测正确,退出循 环,如果
# 三次之内没有猜测正确,则自动退出循环,并显示‘太笨了你....’。
# count=1
# # while count<=3:
# # num = int(input("请输入数字:"))
# # if num==66:
# # print("猜测正确")
# # break
# # if num>66 and count<3:
# # print("结果大了")
# # if num<66 and count<3:
# # print("结果小了")
# # count=count+1
# # else:
# # print("太笨了你....")
#7.使用while循环输入 1 2 3 4 5 6 8 9 10
# count=0
# while count<10:
# count=count+1
# if count==7:
# continue
# print(count)
#8.求1-100数的总和
# count=1
# sum=0
# while count<=100:
# sum=sum+count
# count=count+1
# print(sum)
#9.输出1-100数的奇数
# count=1
# while count<=100:
# if count%2 !=0:
# count=count+1
# print(count)
#10.输出1-100数的偶数
# count=1
# while count<=100:
# if count%2 ==0:
# count=count+1
# print(count)
#11.
# count=1
# sum=0
# while count<=99:
# if count%2==1:
# sum=sum+count
# if count%2==0:
# sum=sum-count
# count=count+1
# print(sum)
#12.
# count=1
# while count<=3:
# username = input("请输入用户名:")
# password = input("请输入密码:")
# if username!="ZMC" or password!="1996":#用户名为ZMC,密码为1996
# print("还有%d次机会输入" % (3-count))
# else:
# print("用户名密码输入正确!")
# break
# count=count+1
#13. 用户输入一个数. 判断这个数是否是一个质数(升级题).
#hile True:
# s = int(input('请输入一个数字:'))
# if s <= 1:
# print('不是质数' )
# elif s == 2 :
# print('是质数')
# else :
# i = 2
# while s > i :
# if s % i == 0 :
# print('%s不是质数' % s)
# break
# i += 1
# else :
# print('%s是质数'% s)
# 14.
# while True:
# adv=input("请输入广告标语:")
# if ("第一" or "最" or "国家级") in adv:
# print("不合法")
# else:
# print("合法")
#15.
# a=0
# b=int(input("输入的数字"))
# while b!=0:
# b=b//10
# a=a+1
# print("数字是%s" % (a))
if语句题目练习的更多相关文章
- 美丽的for循环语句
美丽的for循环语句 题目:用for循环语句实现四个三角形不同的形状. 图案: ---------------第一个三角形图形形状----------------**********第二个三 ...
- C语言第一次博客作业---顺序机构基础练习
一.PTA实验作业 题目1.温度转换 本题要求编写程序,计算华氏温度150°F对应的摄氏温度.计算公式:C=5×(F−32)/9,式中:C表示摄氏温度,F表示华氏温度,输出数据要求为整型. 1.实验代 ...
- 【数据库】SQL经典面试题 - 数据库查询 - 子查询应用二
上节课我们通过子查询,完成了查询的最高分学生的需求,今天我们来学习子查询的分类,以及通过子查询来完成工作中经常遇到一些个性化需求. 子查询概念: 一个SELECT语句嵌套在另一个SELECT语句中,子 ...
- oracle数据库之数据插入、修改和删除
作为一合格的测试人员对数据库的单表查询.多表查询.分组查询.子查询等等这些基本查询方法还是要会的.不然到企业中,容易被一些人鄙视,或者说如果数据库学不好,表查不明白,那么对自己能力来说也是一种侮辱,因 ...
- 暴力打表之hdu 2089
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2089 有两种方法: 1.数位DP算法 2.暴力打表——真是个好法子!!! 接下来是注意点: 1.一般这 ...
- 多测师_讲解python__004 函数
# 函数:一个工具,随调随用# 降级代码冗余## 增加代码的复用性,提高开发效率,为了不成为cv战士## 提高程序扩展性## 函数有两个阶段:定义阶段,调用阶段.## 定义时:只检查函数体内代码语法, ...
- MySQL 迁移到 Redis 记
前些日子,一个悠闲又不悠闲的下午,我还在用 Node.js 写着某个移动互联网应用的 API 服务端.那时还是用 MySQL 作为数据库,一切都很好,所有功能正常运行.可是有很多问题让人不安: 频繁的 ...
- python第六天 函数 python标准库实例大全
今天学习第一模块的最后一课课程--函数: python的第一个函数: 1 def func1(): 2 print('第一个函数') 3 return 0 4 func1() 1 同时返回多种类型时, ...
- whdxlib
1 数据库系统实现 实 验 指 导 书 齐心 彭彬 计算机工程与软件实验中心 2016 年 3 月2目 录实验一.JDBC 应用程序设计(2 学时) ......................... ...
随机推荐
- a标签下载;页面传参row对象先转换成字符串。
jsp:添加一列 <th data-options="field:'id',width:180,formatter: rowformater" width="20% ...
- bootstrap ui
附加访问地址:http://www.bootcss.com/p/jquery-ui-bootstrap/
- python爬虫-基础入门-爬取整个网站《2》
python爬虫-基础入门-爬取整个网站<2> 描述: 开场白已在<python爬虫-基础入门-爬取整个网站<1>>中描述过了,这里不在描述,只附上 python3 ...
- laravel orm
###多对多关系 多对多关系和之前的关系完全不一样,因为多对多关系可能出现很多冗余数据,用之前自带的表存不下了. 我们定义两个模型:Article 和 Tag,分别表示文章和标签,他们是多对多的关系. ...
- windows启动项管理
在运行框中输入 msconfig 选择启动栏 会跳转到任务管理器,可以管理启动项,可以看到我的启动项里有nc病毒 ,点击禁用即可.
- sql privot 实现行转列
表结构如下: RefID HRMS Name InsuranceMoney InsuranceNamefb2bdee8-e4c9-4470-8e7f-14550d3212f7 ...
- loadRunner手动关联,通过 web_reg_save_param()函数
Action() { //<B>sign up now</B></A> /* web_reg_save_param_regexp( ...
- c# 类的知识
在英语中类(class)是分类(classification)的根词.设计类的过程就是对信息进行分类,将相关信息放到有意义的实体中. 封装的目的: 封装就是定义类的重要原则.中心思想是:使用类的程序不 ...
- 进程表示之进程ID号
UNIX进程总是会分配一个号码用于在其命名空间总唯一地标识它们,该号码称作进程ID号,简称PID. 1.进程ID 但每个进程除了PID外,还有其他的ID,有下列几种可能的类型: (1)处于某个线程组中 ...
- Codeforce 733B - Parade (枚举)
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldi ...