def qs(x):
sum=0
num=1
while num<=x:
sum+=num
num+=1
return sum
print(qs(100))
def fact(n):
if n==1:
return 1
return n+fact(n-1)
print(fact(100))
sum=0
num=1
while num<=x:
sum+=num
num+=1
return sum
print(qs(100))
def fact(n):
if n==1:
return 1
return n+fact(n-1)
print(fact(100))
2020-11-27
def sub_sum(L):
sum_ji=0
sum_ou=0
num=1
for x in L:
if num % 2 != 0:
sum_ji+=x
num+=1
else:
sum_ou+=x
num+=1
return sum_ji,sum_ou
print(sub_sum([1,3,2,4,3,5]))
sum_ji=0
sum_ou=0
num=1
for x in L:
if num % 2 != 0:
sum_ji+=x
num+=1
else:
sum_ou+=x
num+=1
return sum_ji,sum_ou
print(sub_sum([1,3,2,4,3,5]))
2020-11-27
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for a in L:
if a in S:
S.remove(a)
else:
S.add(a)
print(S)
S = set([1, 3, 5, 7, 9, 11])
for a in L:
if a in S:
S.remove(a)
else:
S.add(a)
print(S)
2020-11-26
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
if 'Alice' in d:
result="Alice's old grade is "+str(d['Alice'])
print(result)
d['Alice']=60
print(d)
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
if 'Alice' in d:
result="Alice's old grade is "+str(d['Alice'])
print(result)
d['Alice']=60
print(d)
2020-11-26
T = (100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
print(T.count(100))
print(T.count(100))
2020-11-26
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
N = [89,72,88,79,99]
dictA=dict(zip(L,N))
dictB=sorted(dictA, key=dictA.get, reverse = True)
print(dictB)
N = [89,72,88,79,99]
dictA=dict(zip(L,N))
dictB=sorted(dictA, key=dictA.get, reverse = True)
print(dictB)
2020-11-26
# Enter a code
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(squre, 2))
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(squre, 2))
2020-11-23
# Enter a code
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(wide, 2))
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(wide, 2))
2020-11-23
l=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
l[0]='Ellena'
l[1]='Alice'
l[-1]='Bob'
print(l)
l[0]='Ellena'
l[1]='Alice'
l[-1]='Bob'
print(l)
2020-11-23
print(r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.''')
print('\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.')
Whether it's nobler in the mind to suffer.''')
print('\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.')
2020-11-21