1:
lst = [i for i in range(100, 1000) if i // 100 == i % 10]
print(sum(lst) / len(lst))
2:
lst = []
for _ in range(int(input('n = '))):
n = int(input())
if n < 10:
lst.append(n)
3:
for i in range(1000, 10000):
sti = str(i)
if all(([sti.count(c) == 1 for c in sti])):
lst.append(i)
print(lst)
4:
n = int(input('n = '))
print(len([i for i in range(1, n + 1) if not n % i and not i % 2]))
5:
lst = [i for i in range(100, 1000) if str(i) == str(i)[::-1] and len([i for i in range(1, i)]) == 1]
6:
from math import factorial as fa
print(sum([fa(i) for i in range(1, int(input('n = ')) + 1)]))
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
1:
lst = [i for i in range(100, 1000) if i // 100 == i % 10]
print(sum(lst) / len(lst))
2:
lst = []
for _ in range(int(input('n = '))):
n = int(input())
if n < 10:
lst.append(n)
print(sum(lst) / len(lst))
3:
lst = []
for i in range(1000, 10000):
sti = str(i)
if all(([sti.count(c) == 1 for c in sti])):
lst.append(i)
print(lst)
4:
n = int(input('n = '))
print(len([i for i in range(1, n + 1) if not n % i and not i % 2]))
5:
lst = [i for i in range(100, 1000) if str(i) == str(i)[::-1] and len([i for i in range(1, i)]) == 1]
print(lst)
6:
from math import factorial as fa
print(sum([fa(i) for i in range(1, int(input('n = ')) + 1)]))