age = 19
if age >= 18:
print('your age = {}'.format(age))
print('adult')
if age >= 18:
print('your age = {}'.format(age))
print('adult')
2021-03-25
>>> r = 'you need Python'
>>> template = 'Life is short,{}'
>>> result = template.format(r)
>>> print(result)
Life is short,you need Python
>>> template = 'Life is short,{w}'
>>> w = 'you need Python'
>>> result = template.format(w=w)
>>> print(result)
Life is short,you need Python
>>>
>>> template = 'Life is short,{}'
>>> result = template.format(r)
>>> print(result)
Life is short,you need Python
>>> template = 'Life is short,{w}'
>>> w = 'you need Python'
>>> result = template.format(w=w)
>>> print(result)
Life is short,you need Python
>>>
2021-03-25
最赞回答 / 慕丝7207896
你的变量K没有递增啊,正确代码如下def l_sum1(k): a = 0 b = 0 while b <= k: a += b b += 1 return aprint(l_sum1(100))
2021-03-25
T = (1, 'CH', [3, 4])
T = list(T)
T[2]=tuple(T[2])
print(tuple(T))
T = list(T)
T[2]=tuple(T[2])
print(tuple(T))
2021-03-23
最新回答 / 慕粉1217398274
取模运算的结果就是除法运算的余数,99/30=3余9所以99%3的结果就是9,==>没什么用就是表示个箭头,后面是这行程序运行的结果,#是注释,#后面的部分只会作为文本显示,不作为程序运行
2021-03-22
最新回答 / 慕运维1448452
额,,,,,短路计算,a and b 如果a是false 那么输出就是a 如果a是true 那么输出无论b是true或者false,都是b。你这里a=“pd”然后print(“hello”,a and “world”)a已经赋值字符串pd应该是true!
2021-03-22
已采纳回答 / qq_加油少年_2
template="Life is short,{} " data="you need Python."result=template.format(data) print(result)不要全部写在一行啊
2021-03-21
最新回答 / 慕斯卡8373086
def sums (n): refult = 0 if n > 0 and n <= 100: while n > 0 : refult = refult + n n -= 1 return refult else: return '参数要在1-100之间'n1 = 99print(sums(n1))def fact(n): if n == 1: return 1 ...
2021-03-20
a='python'
print('hello',a and 'world') #==>hello, python
在and语句下,a值为true,所以运算结果取决于前者
b=''
print('hello',b or 'world') #==>hello, world
在or语句下,b值为false(空,0,None),所以运算结果取后者
print('hello',a and 'world') #==>hello, python
在and语句下,a值为true,所以运算结果取决于前者
b=''
print('hello',b or 'world') #==>hello, world
在or语句下,b值为false(空,0,None),所以运算结果取后者
2021-03-20