>>> print(type(3.1415926))
<class 'float'>
>>> print(type('Learn Python in imoc'))
<class 'str'>
>>> print(type(100))
<class 'int'>
>>> print(type(0b1101))
<class 'int'>
>>>
<class 'float'>
>>> print(type('Learn Python in imoc'))
<class 'str'>
>>> print(type(100))
<class 'int'>
>>> print(type(0b1101))
<class 'int'>
>>>
2023-08-03
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
names.append('Zero')
names.insert(5,'Phoebe')
names.insert(-2,'Gen')
print(names)
names.append('Zero')
names.insert(5,'Phoebe')
names.insert(-2,'Gen')
print(names)
2023-08-02
d = {
'Alice': [45],
'Bob': [60],
'Candy': [75],
}
d['Alice'] = [50,61,66]
d['Bob'] = [80,61,66]
d['Candy'] = [88,75,90]
print(d)
'Alice': [45],
'Bob': [60],
'Candy': [75],
}
d['Alice'] = [50,61,66]
d['Bob'] = [80,61,66]
d['Candy'] = [88,75,90]
print(d)
2023-07-29
a=2
at=0
while a<=1000:
if a == 1000:
break;
at+=a
a=a+2
print(at)
at=0
while a<=1000:
if a == 1000:
break;
at+=a
a=a+2
print(at)
2023-07-26
template = 'Life is short,{}'
A = 'you need Python'
result = template.format(A)
print(result)
template = 'Life is short,{}'
result = template.format('you need Python')
print(result)
A = 'you need Python'
result = template.format(A)
print(result)
template = 'Life is short,{}'
result = template.format('you need Python')
print(result)
2023-07-26
最新回答 / 送東野
根據(jù)短路運(yùn)算原理,True or True進(jìn)行運(yùn)算時(shí),在看到第一個(gè)True時(shí)就可以確定結(jié)果是True,不需要關(guān)注后面參與運(yùn)算的是True還是False,所以只輸出第一個(gè)True。
2023-07-22
template='Life is {},you need {}'
result=template.format('short','python')
print(result)
template='Life is {s},you need {p}'
short='short'
python='python'
result=template.format(s=short,p=python)
print(result)
result=template.format('short','python')
print(result)
template='Life is {s},you need {p}'
short='short'
python='python'
result=template.format(s=short,p=python)
print(result)
2023-07-18
# Enter a code
def classmate(**kwargs):
for i in range(0,len(kwargs.get('names'))):
print('{} ,{} ,{}'.format(kwargs.get('names')[i],kwargs.get('gender')[i],kwargs.get('age')[i]))
classmate(names = ['Alice', 'Bob', 'Candy'], gender = ['girl', 'boy', 'girl'], age = [16, 17, 15])
def classmate(**kwargs):
for i in range(0,len(kwargs.get('names'))):
print('{} ,{} ,{}'.format(kwargs.get('names')[i],kwargs.get('gender')[i],kwargs.get('age')[i]))
classmate(names = ['Alice', 'Bob', 'Candy'], gender = ['girl', 'boy', 'girl'], age = [16, 17, 15])
2023-07-16
def greet(x=None):
if x != None:
print("Hello,World")
else:
print('hello')
s1=greet(22)
print(s1)
if x != None:
print("Hello,World")
else:
print('hello')
s1=greet(22)
print(s1)
2023-07-15
可以這樣就行了
def fact(n):
if n==1:
return 1
return n + fact(n - 1)
s2 =fact(100)
print(s2)
def fact(n):
if n==1:
return 1
return n + fact(n - 1)
s2 =fact(100)
print(s2)
2023-07-15
>>> print(r'''"To be,or not to be":that is the question.
... Whether it's nobler in the mind to suffer.''')
"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.
>>>
... Whether it's nobler in the mind to suffer.''')
"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.
>>>
2023-07-14
s='special string:(該重復(fù)符號了,用\隔開)\',",(又該重復(fù)\符號了)\\(表示\本身),(又和\\重復(fù)了)\\\\(兩個(gè)本身),(又重復(fù)\)\\n,\\t'
2023-07-14
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
for intem in s2:
if intem in s1:
s1.isdisjoint("")
else:
print(intem)
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
for intem in s2:
if intem in s1:
s1.isdisjoint("")
else:
print(intem)
2023-07-14