快手号码绑定如何删除绑定的号码已经不用了,申请几次也都说不对拿咋个办

#!/usr/bin/envpython#coding=utf-8#实现加减乘除-无优先级,从左至右计算defsplit_str(str):L=[]s_index=0#上次切割的索引i=0#遍历时当前的索引#printstrforsinstr:ifsin'+-*/':#遇到运算符开始执行切割L.append(str[s_index:i])#写入list#print"str[s_index:i]:",str[s_index:i]s_index=i#上次切割索引前移#print"s_index:",s_indexi+=1#非运算符索引前移#print'i:',iL.append(str[s_index:])#切割后最后一部分写入listinit_value=L[0]#list第一个值无需计算,设为初始值fornuminrange(1,len(L)):init_value=calculate_list(init_value,L[num])#计算结果赋值给初始值,即左操作数returninit_valuedefcalculate_list(a,b):returnoperate_map[b[0]](int(a),int(b[1:]))#定义词典+-*/符号为key,value为运算结果operate_map={'+':lambdax,y:x+y,'-':lambdax,y:x-y,'*':lambdax,y:x*y,'/':lambdax,y:x/y}if__name__=='__main__':cal_str="8/2+10+2*3-14"cal_list=split_str(cal_str)printcal_list以上为$ cat calculate1.py利用上面的的规则实现优先级:#!/usr/bin/envpython#coding=utf-8fromcalculate1import*#实现加减乘除--有优先级,先*/后+-def_split_str(str):L=[]s_index=0#上次切割的索引i=0#遍历时当前的索引printstrforsinstr:ifsin'-+':#遇到+-运算符开始执行切割L.append(str[s_index:i])#写入listL.append(s)#写入lists_index=i+1#上次切割索引前移i+=1#非运算符索引前移L.append(str[s_index:])#切割后最后一部分写入listreturnL#cal_str="12+11/13*1-5*9"cal_str=raw_input("Enteranarithmeticexpress:")cal_list=_split_str(cal_str)#['12','+','11/13*1','-','5*9']s=''foriincal_list:if"*"inior'/'ini:s=s+str(split_str(i))else:s=s+str(i)printsplit_str(s)另外在Stackoverflow上看到的后缀四则运算的代码,记录下:#ThequestionI'mhavingproblemoniscalculatingthepostfixformexpressions:forexample,(1,2,'+',3,'*').#/questions//stack-calculator-postfix-python/85579importsysifsys.hexversion&0x3000000:#Python2.xis_str=lambdas:isinstance(s,basestring)inp=raw_inputelse:#Python3.xis_str=lambdas:isinstance(s,str)inp=inputclassStack(list):defpop_n(self,n):"""Popnitemsoffstack,returnaslist"""assertn&=0,"Badvalue{}:ncannotbenegative".format(n)ifn==0:return[]elifn&=len(self):res=self[-n:]delself[-n:]print"Stackpop_nres:",resreturnreselse:raiseValueError("cannotpop{}items,only{}instack".format(n,len(self)))defpush_n(self,n,items):"""Pushnitemsontostack"""assertn==len(items),"Expected{}items,received{}".format(n,len(items))self.extend(items)print"Stackpush_nself:",selfclassOp:def__init__(self,num_in,num_out,fn):"""Apostfixoperatornum_in:intnum_out:intfn:acceptnum_inpositionalarguments,performoperation,returnlistcontainingnum_outvalues"""assertnum_in&=0,"Operatorcannothavenegativenumberofarguments"self.num_in=num_inassertnum_out&=0,"Operatorcannotreturnnegativenumberofresults"self.num_out=num_outself.fn=fndef__call__(self,stack):"""Runoperatoragainststack(in-place)"""args=stack.pop_n(self.num_in)#popnum_inargumentsprint"Opargs:",argsres=self.fn(*args)#passtofunction,getresultsprint"Opres:",resstack.push_n(self.num_out,res)#pushnum_outvaluesbackprint"Opstack",stackops={'*':Op(2,1,lambdaa,b:[a*b]),#multiplication'/':Op(2,1,lambdaa,b:[a//b]),#integerdivision'+':Op(2,1,lambdaa,b:[a+b]),#addition'-':Op(2,1,lambdaa,b:[a-b]),#subtraction'/%':Op(2,2,lambdaa,b:[a//b,a%b])#divmod(exampleof2-outputop)}defpostfix_eval(tokens):"""Evaluateaseriesoftokensreturntheresultingstack"""ifis_str(tokens):#iftokensisastring,treatitasaspace-separatedlistoftokenstokens=tokens.split()stack=Stack()fortokenintokens:try:#Converttointandpushonstackstack.append(int(token))print"postfix_evalstack:",stackexceptValueError:try:#Notanint-mustbeanoperator#Gettheappropriateoperatorandrunitagainstthestackop=ops[token]print"postfix_evalop:",op#op(stack)#runsOp.__call__(op,stack)print"token:",tokenprint"postfix_evalop(stack)",op(stack)exceptKeyError:#NotavalidoperatoreitherraiseValueError("unknownoperator{}".format(token))returnstackdefmain():whileTrue:expr=inp('/nEnterapostfixexpression(ornothingtoquit):').strip()ifexpr:try:print("=&{}".format(postfix_eval(expr)))exceptValueErroraserror:print("Yourexpressioncausedanerror:{}".format(error))else:breakif__name__=="__main__":main()
最新教程周点击榜
微信扫一扫Python 基础教程
Python 运算符
什么是运算符?
本章节主要说明Python的运算符。举个简单的例子 4 +5 = 9 。
例子中,4 和 5 被称为操作数,"+" 称为运算符。
Python语言支持以下类型的运算符:
接下来让我们一个个来学习Python的运算符。
Python算术运算符
以下假设变量a为10,变量b为20:
运算符描述实例
+加 - 两个对象相加 a + b 输出结果 30
-减 - 得到负数或是一个数减去另一个数 a - b 输出结果 -10
*乘 - 两个数相乘或是返回一个被重复若干次的字符串 a * b 输出结果 200
/除 - x除以y b / a 输出结果 2
%取模 - 返回除法的余数 b % a 输出结果 0
**幂 - 返回x的y次幂 a**b 为10的20次方, 输出结果
//取整除 - 返回商的整数部分 9//2 输出结果 4 , 9.0//2.0 输出结果 4.0
以下实例演示了Python所有算术运算符的操作:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
print "1 - c 的值为:", c
print "2 - c 的值为:", c
print "3 - c 的值为:", c
print "4 - c 的值为:", c
print "5 - c 的值为:", c
# 修改变量 a 、b 、c
print "6 - c 的值为:", c
print "7 - c 的值为:", c
以上实例输出结果:
1 - c 的值为: 31
2 - c 的值为: 11
3 - c 的值为: 210
4 - c 的值为: 2
5 - c 的值为: 1
6 - c 的值为: 8
7 - c 的值为: 2
Python比较运算符
以下假设变量a为10,变量b为20:
运算符描述实例
== 等于 - 比较对象是否相等 (a == b) 返回 False。
!= 不等于 - 比较两个对象是否不相等 (a != b) 返回 true.
&&不等于 -
比较两个对象是否不相等 (a && b) 返回 true。这个运算符类似 != 。
& 大于 - 返回x是否大于y (a & b) 返回 False。
& 小于 - 返回x是否小于y。所有比较运算符返回1表示真,返回0表示假。这分别与特殊的变量True和False等价。注意,这些变量名的大写。 (a & b) 返回 true。
&= 大于等于 - 返回x是否大于等于y。 (a &= b) 返回 False。
&= 小于等于 - 返回x是否小于等于y。 (a &= b) 返回 true。
以下实例演示了Python所有比较运算符的操作:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
if ( a == b ):
print "1 - a 等于 b"
print "1 - a 不等于 b"
if ( a != b ):
print "2 - a 不等于 b"
print "2 - a 等于 b"
if ( a && b ):
print "3 - a 不等于 b"
print "3 - a 等于 b"
if ( a & b ):
print "4 - a 小于 b"
print "4 - a 大于等于 b"
if ( a & b ):
print "5 - a 大于 b"
print "5 - a 小于等于 b"
# 修改变量 a 和 b 的值
if ( a &= b ):
print "6 - a 小于等于 b"
print "6 - a 大于
if ( b &= a ):
print "7 - b 大于等于 a"
print "7 - b 小于 a"
以上实例输出结果:
1 - a 不等于 b
2 - a 不等于 b
3 - a 不等于 b
4 - a 大于等于 b
5 - a 大于 b
6 - a 小于等于 b
7 - b 大于等于 a
Python赋值运算符
以下假设变量a为10,变量b为20:
运算符描述实例
=简单的赋值运算符 c = a + b 将 a + b 的运算结果赋值为 c
+=加法赋值运算符 c += a 等效于 c = c + a
-=减法赋值运算符 c -= a 等效于 c = c - a
*=乘法赋值运算符 c *= a 等效于 c = c * a
/=除法赋值运算符 c /= a 等效于 c = c / a
%=取模赋值运算符 c %= a 等效于 c = c % a
**=幂赋值运算符 c **= a 等效于 c = c ** a
//= 取整除赋值运算符 c //= a 等效于 c = c // a
以下实例演示了Python所有赋值运算符的操作:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
print "1 - c 的值为:", c
print "2 - c 的值为:", c
print "3 - c 的值为:", c
print "4 - c 的值为:", c
print "5 - c 的值为:", c
print "6 - c 的值为:", c
print "7 - c 的值为:", c
以上实例输出结果:
1 - c 的值为: 31
2 - c 的值为: 52
3 - c 的值为: 1092
4 - c 的值为: 52
5 - c 的值为: 2
6 - c 的值为: 2097152
7 - c 的值为: 99864
Python位运算符
按位运算符是把数字看作二进制来进行计算的。Python中的按位运算法则如下:
下表中变量 a 为 60,b 为 13,二进制格式如下:
-----------------
运算符描述实例
&按位与运算符:参与运算的两个值,如果两个相应位都为1,则该位的结果为1,否则为0 (a & b) 输出结果 12 ,二进制解释:
| 按位或运算符:只要对应的二个二进位有一个为1时,结果位就为1。 (a | b) 输出结果 61 ,二进制解释:
^按位异或运算符:当两对应的二进位相异时,结果为1
(a ^ b) 输出结果 49 ,二进制解释:
~ 按位取反运算符:对数据的每个二进制位取反,即把1变为0,把0变为1
(~a ) 输出结果 -61 ,二进制解释: , 在一个有符号二进制数的补码形式。
&&左移动运算符:运算数的各二进位全部左移若干位,由"&&"右边的数指定移动的位数,高位丢弃,低位补0。 a && 2 输出结果 240 ,二进制解释:
&&右移动运算符:把"&&"左边的运算数的各二进位全部右移若干位,"&&"右边的数指定移动的位数
a && 2 输出结果 15 ,二进制解释:
以下实例演示了Python所有位运算符的操作:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
print "1 - c 的值为:", c
print "2 - c 的值为:", c
print "3 - c 的值为:", c
print "4 - c 的值为:", c
c = a && 2;
print "5 - c 的值为:", c
c = a && 2;
print "6 - c 的值为:", c
以上实例输出结果:
1 - c 的值为: 12
2 - c 的值为: 61
3 - c 的值为: 49
4 - c 的值为: -61
5 - c 的值为: 240
6 - c 的值为: 15
Python逻辑运算符
Python语言支持逻辑运算符,以下假设变量 a 为 10, b为 20:
运算符逻辑表达式描述实例
andx and y 布尔"与" - 如果 x 为 False,x and y 返回 False,否则它返回 y 的计算值。
(a and b) 返回 20。
orx or y布尔"或" - 如果 x 是非 0,它返回 x 的值,否则它返回 y 的计算值。 (a or b) 返回 10。
notnot x布尔"非" - 如果 x 为 True,返回 False 。如果 x 为 False,它返回 True。 not(a and b) 返回 False
以上实例输出结果:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
if ( a and b ):
print "1 - 变量 a 和 b 都为 true"
print "1 - 变量 a 和 b 有一个不为 true"
if ( a or b ):
print "2 - 变量 a 和 b 都为 true,或其中一个变量为 true"
print "2 - 变量 a 和 b 都不为 true"
# 修改变量 a 的值
if ( a and b ):
print "3 - 变量 a 和 b 都为 true"
print "3 - 变量 a 和 b 有一个不为 true"
if ( a or b ):
print "4 - 变量 a 和 b 都为 true,或其中一个变量为 true"
print "4 - 变量 a 和 b 都不为 true"
if not( a and b ):
print "5 - 变量 a 和 b 都为 false,或其中一个变量为 false"
print "5 - 变量 a 和 b 都为 true"
以上实例输出结果:
1 - 变量 a 和 b 都为 true
2 - 变量 a 和 b 都为 true,或其中一个变量为 true
3 - 变量 a 和 b 有一个不为 true
4 - 变量 a 和 b 都为 true,或其中一个变量为 true
5 - 变量 a 和 b 都为 false,或其中一个变量为 false
Python成员运算符
除了以上的一些运算符之外,Python还支持成员运算符,测试实例中包含了一系列的成员,包括字符串,列表或元组。
运算符描述实例
如果在指定的序列中找到值返回 True,否则返回 False。
x 在 y 序列中 , 如果 x 在 y 序列中返回 True。
not in如果在指定的序列中没有找到值返回 True,否则返回 False。
x 不在 y 序列中 , 如果 x 不在 y 序列中返回 True。
以下实例演示了Python所有成员运算符的操作:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
list = [1, 2, 3, 4, 5 ];
if ( a in list ):
print "1 - 变量 a 在给定的列表中 list 中"
print "1 - 变量 a 不在给定的列表中 list 中"
if ( b not in list ):
print "2 - 变量 b 不在给定的列表中 list 中"
print "2 - 变量 b 在给定的列表中 list 中"
# 修改变量 a 的值
if ( a in list ):
print "3 - 变量 a 在给定的列表中 list 中"
print "3 - 变量 a 不在给定的列表中 list 中"
以上实例输出结果:
1 - 变量 a 不在给定的列表中 list 中
2 - 变量 b 不在给定的列表中 list 中
3 - 变量 a 在给定的列表中 list 中
Python身份运算符
身份运算符用于比较两个对象的存储单元
运算符描述实例
is是判断两个标识符是不是引用自一个对象 x is y, 如果 id(x)
等于 id(y) , is 返回结果 1
is notis not是判断两个标识符是不是引用自不同对象 x is not y, 如果 id(x) 不等于 id(y). is not 返回结果 1
以下实例演示了Python所有身份运算符的操作:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
if ( a is b ):
print "1 - a 和 b 有相同的标识"
print "1 - a 和 b 没有相同的标识"
if ( id(a) is not id(b) ):
print "2 - a 和 b 有相同的标识"
print "2 - a 和 b 没有相同的标识"
# 修改变量 b 的值
if ( a is b ):
print "3 - a 和 b 有相同的标识"
print "3 - a 和 b 没有相同的标识"
if ( a is not b ):
print "4 - a 和 b 没有相同的标识"
print "4 - a 和 b 有相同的标识"
以上实例输出结果:
1 - a 和 b 有相同的标识
2 - a 和 b 有相同的标识
3 - a 和 b 没有相同的标识
4 - a 和 b 没有相同的标识
Python运算符优先级
以下表格列出了从最高到最低优先级的所有运算符:
运算符描述
指数 (最高优先级)
按位翻转, 一元加号和减号 (最后两个的方法名为 +@ 和 -@)
乘,除,取模和取整除
右移,左移运算符
比较运算符
等于运算符
= %= /= //= -= += *= **=
赋值运算符
身份运算符
成员运算符
not or and
逻辑运算符
以下实例演示了Python所有运算符优先级的操作:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
e = (a + b) * c / d
#( 30 * 15 ) / 5
print "(a + b) * c / d 运算结果为:",
e = ((a + b) * c) / d
# (30 * 15 ) / 5
print "((a + b) * c) / d 运算结果为:",
e = (a + b) * (c / d);
# (30) * (15/5)
print "(a + b) * (c / d) 运算结果为:",
e = a + (b * c) /
20 + (150/5)
print "a + (b * c) / d 运算结果为:",
以上实例输出结果:
(a + b) * c / d 运算结果为: 90
((a + b) * c) / d 运算结果为: 90
(a + b) * (c / d) 运算结果为: 90
a + (b * c) / d 运算结果为: 50
反馈内容(*必填)
截图标记颜色
联系方式(邮箱)
联系邮箱:
投稿页面:
记住登录状态
重复输入密码Python的条件语句与运算符优先级详解
投稿:goldensun
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了Python的条件语句与运算符优先级,是Python入门学习中的基础知识,需要的朋友可以参考下
Python 条件语句
Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块。
可以通过下图来简单了解条件语句的执行过程:
Python程序语言指定任何非0和非空(null)值为true,0 或者 null为false。
Python 编程中 if 语句用于控制程序的执行,基本形式为:
if 判断条件:
执行语句……
执行语句……
其中"判断条件"成立时(非零),则执行后面的语句,而执行内容可以多行,以缩进来区分表示同一范围。
else 为可选语句,当需要在条件不成立时执行内容则可以执行相关语句,具体例子如下:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# 例1:if 基本用法
flag = False
name = 'luren'
if name == 'python':
# 判断变量否为'python'
flag = True
# 条件成立时设置标志为真
print 'welcome boss'
# 并输出欢迎信息
print name
# 条件不成立时输出变量名称
输出结果为:
# 输出结果
if 语句的判断条件可以用&(大于)、&(小于)、==(等于)、&=(大于等于)、&=(小于等于)来表示其关系。
当判断条件为多个值是,可以使用以下形式:
if 判断条件1:
执行语句1……
elif 判断条件2:
执行语句2……
elif 判断条件3:
执行语句3……
执行语句4……
实例如下:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# 例2:elif用法
if num == 3:
# 判断num的值
print 'boss'
elif num == 2:
print 'user'
elif num == 1:
print 'worker'
elif num & 0:
# 值小于零时输出
print 'error'
print 'roadman'
# 条件均不成立时输出
输出结果为:
&&& roadman # 输出结果
由于 python 并不支持 switch 语句,所以多个条件判断,只能用 elif 来实现,如果判断需要多个条件需同时判断时,可以使用 or (或),表示两个条件有一个成立时判断条件成功;使用 and (与)时,表示只有两个条件同时成立的情况下,判断条件才成功。
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# 例3:if语句多个条件
if num &= 0 and num &= 10:
# 判断值是否在0~10之间
print 'hello'
&&& hello # 输出结果
if num & 0 or num & 10:
# 判断值是否在小于0或大于10
print 'hello'
print 'undefine'
&&& undefine # 输出结果
# 判断值是否在0~5或者10~15之间
if (num &= 0 and num &= 5) or (num &= 10 and num &= 15):
print 'hello'
print 'undefine'
&&& undefine # 输出结果
当if有多个条件时可使用括号来区分判断的先后顺序,括号中的判断优先执行,此外 and 和 or 的优先级低于&(大于)、&(小于)等判断符号,即大于和小于在没有括号的情况下会比与或要优先判断。
简单的语句组
你也可以在同一行的位置上使用if条件判断语句,如下实例:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
if ( var == 100 ) : print "变量 var 的值为100"
print "Good bye!"
以上代码执行输出结果如下:
变量 var 的值为100
Python运算符优先级
以下表格列出了从最高到最低优先级的所有运算符:
以下实例演示了Python所有运算符优先级的操作:
#!/usr/bin/python
e = (a + b) * c / d
#( 30 * 15 ) / 5
print "Value of (a + b) * c / d is ", e
e = ((a + b) * c) / d
# (30 * 15 ) / 5
print "Value of ((a + b) * c) / d is ", e
e = (a + b) * (c / d);
# (30) * (15/5)
print "Value of (a + b) * (c / d) is ", e
e = a + (b * c) /
# 20 + (150/5)
print "Value of a + (b * c) / d is ", e
以上实例输出结果:
Value of (a + b) * c / d is 90
Value of ((a + b) * c) / d is 90
Value of (a + b) * (c / d) is 90
Value of a + (b * c) / d is 50
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具1449人阅读
PHP_I love U_衣食父母(25)
C&C++(18)
个人随手记(40)
最近着迷上了 Python
用Python给小宝做的数学算数口算练习程序(2015年1月添加四则运算)!
给小宝做的口算游戏:
#用Python给小宝做的数学算数口算练习程序(2015年1月添加四则运算)!
#给小宝做的口算游戏:
import string
import random
righ1t=0 #分数#
flagwrong=0 #没错过
print &\e[1;34mThis text is bold blue.\e[0m\n&
print &一共有%d道题目:&%(nums)
print &\e[33;45;1mBold yellow on magenta.\e[0m\n&;
while True:
& & flagwrong=0
& & if num&=nums:
& & & & print &一共(1次就)做对了%d道/%d道 题目&%(righ1t,nums),
& & & & if righ1t&=10:
& & & & & & print &你真棒啊! 100分啊!!!&
& & & & elif righ1t&=8:
& & & & & & print &你不错啊,80分以上啊!!!&
& & & & else:
& & & & & & print &还要加油哦!&
& & elif num&nums:
& & & & num=num+1
& & x=random.randint(1, 100) & &#100以内的数字
& & y=random.randint(1, 10)
& & print &&
& & symbol=random.randint(0,3)
& & #symbol=3 & & & & & & & & & &#测试除法#
& & if 0==symbol: & & & &#加法
& & & & # 内循环-做题
& & & & print &第%d题:%d+%d=&%(num,x,y),
& & & & input=raw_input()
& & & & intp=string.atoi(input)
& & & & print intp
& & & & while intp!=(x+y):
& & & & & & print &不对! %d+%d不等于%d&%(x,y,intp)
& & & & & & flagwrong=1; #错过一次,就不能做成绩(分数)的增长了
& & & & & & print &再算一遍,第%d题:%d+%d=&%(num,x,y),
& & & & & & input=raw_input()
& & & & & & intp=string.atoi(input)
& & & & & & if intp==x+y:
& & & & & & & &
& & & & & &
& & & & if intp == (x+y):
& & & & & & print &对了! %d+%d就是等于%d&%(x,y,intp)
& & & & & & if flagwrong==0:
& & & & & & & & righ1t=righ1t+1
& & & & & &
& & elif 1==symbol: & & & &#减法
& & & & # 内循环-做题
& & & & if x&y: x01temp=x; x=y; y=x01
& & & & print &第%d题:%d-%d=&%(num,x,y),
& & & & input=raw_input()
& & & & intp=string.atoi(input)
& & & & print intp
& & & & while intp!=(x-y):
& & & & & & print &不对! %d-%d不等于%d&%(x,y,intp)
& & & & & & flagwrong=1; #错过一次,就不能做成绩(分数)的增长了
& & & & & & print &再算一遍,第%d题:%d-%d=&%(num,x,y),
& & & & & & input=raw_input()
& & & & & & intp=string.atoi(input)
& & & & & & if intp==x-y:
& & & & & & & &
& & & & & &
& & & & if intp == (x-y):
& & & & & & print &对了! %d-%d就是等于%d&%(x,y,intp)
& & & & & & if flagwrong==0:
& & & & & & & & righ1t=righ1t+1
& & & & & &
& & elif 2==symbol: & & & &#乘法
& & & & # 内循环-做题
& & & & #if x&y: x01temp=x; x=y; y=x01
& & & & print &第%d题:%d*%d=&%(num,x,y),
& & & & input=raw_input()
& & & & intp=string.atoi(input)
& & & & print intp
& & & & while intp!=(x*y):
& & & & & & print &不对! %d*%d不等于%d&%(x,y,intp)
& & & & & & flagwrong=1; #错过一次,就不能做成绩(分数)的增长了
& & & & & & print &再算一遍,第%d题:%d*%d=&%(num,x,y),
& & & & & & input=raw_input()
& & & & & & intp=string.atoi(input)
& & & & & & if intp==x*y:
& & & & & & & &
& & & & & &
& & & & if intp == (x*y):
& & & & & & print &对了! %d*%d就是等于%d&%(x,y,intp)
& & & & & & if flagwrong==0:
& & & & & & & & righ1t=righ1t+1
& & & & & &
& & elif 3==symbol: & & & &#除法
& & & & # 内循环-做题
& & & & if x&y: x01temp=x; x=y; y=x01
& & & & print &第%d题:%d/%d=&%(num,x,y),
& & & & print &商?:&,
& & & & input=raw_input()
& & & & intp=string.atoi(input)
& & & & print &余数是?:&,
& & & & input2yushu=raw_input()
& & & & intp2yushu=string.atoi(input2yushu)
& & & & print &商:&,
& & & & print intp,
& & & & print &余数是:&,
& & & & print intp2yushu
& & & & while x !=( ( intp * y)+intp2yushu ):
& & & & & & print &不对! %d/%d不等于商%d,余%d &!&%(x,y,intp,intp2yushu)
& & & & & & flagwrong=1; #错过一次,就不能做成绩(分数)的增长了
& & & & & & print &再算一遍,第%d题:%d/%d的商=?&%(num,x,y),
& & & & & & input=raw_input()
& & & & & & intp=string.atoi(input)
& & & & & & print &余?=&,
& & & & & & input2yushu=raw_input()
& & & & & & intp2yushu=string.atoi(input2yushu)
& & & & & & if x ==( intp*y + intp2yushu ):
& & & & & & & &
& & & & & &
& & & & if x == ( (intp*y)+intp2yushu ):
& & & & & & print &对了! %d/%d就是等于商%d,余%d !&%(x,y,intp,intp2yushu)
& & & & & & if flagwrong==0:
& & & & & & & & righ1t=righ1t+1
& & & & & &
#100以内的 加法/减法/乘法/除法
------------------------------------------------------------------------
“缩进问题”暂时用 选则(选灰)然后用&Tab&键实现缩进……
缩进还是问题啊!&
希望以后 Python 能添加& {}(代码块,或者 : 用& “end”实现代码块的结束……而不是强制缩进!&
=====================================================================
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:71066次
积分:1277
积分:1277
排名:千里之外
原创:43篇
转载:19篇
译文:12篇
评论:12条
(1)(1)(2)(1)(2)(4)(3)(2)(5)(8)(2)(2)(1)(1)(1)(3)(3)(2)(3)(1)(1)(4)(2)(1)(1)(2)(2)(1)(1)(4)(3)(2)(2)

我要回帖

更多关于 快手号码绑定如何删除 的文章

 

随机推荐