7 topshiriq. Ixtiyoriy berilgan N natural sonning raqamlar yig’indisi nechaga
teng.
Python dasturi:
from math import *
print(“n natural son qiymatini kiriting”)
n=int(input(“n=”))
s=0
while n!=0:
k=n%10
n=n//10
s+=k
print (“Yig’indi qiymati S=”, s)
n natural son qiymatini kiriting
n=4789
Yig'indi qiymati S= 28
8 topshiriq. a natural soniga ko’paytirish karra jadvalini chiqaruvchi dastur
tuzing.
Python dasturi:
from math import *
print(“Karra jadvalini hisoblash sonini
kiriting”)
a=int(input(“a=”))
for i in range (1,11):
print (a, “x”, i, “=”, a*i)
Karra jadvalini hisoblash sonini kiriting
a=6
6 x 1 = 6
6 x 2 = 12
6 x 3 = 18
6 x 4 = 24
87
6 x 5 = 30
6 x 6 = 36
6 x 7 = 42
6 x 8 = 48
6 x 9 = 54
6 x 10 = 60
9 topshiriq. M>1 natural son berilgan bo’sin.
4
𝑘
< 𝑀
shartni
qanoatlantiradigan eng katta k sonini toping.
Python dasturi:
from math import *
print(“M>1 natural sonini kiriting”)
m=int(input(“M=”))
for i in range (m):
if 4**iprint()
else:
print(“k=”, i-1)
break
M>1 natural sonini kiriting
M=80
k= 3
10 topshiriq. N natural soni berilgan.
1 ∗ 2 + 2 ∗ 3 + ⋯ + 𝑛 ∗ (𝑛 + 1)
hisoblovchi dastur tuzing.
Python dasturi:
from math import *
print(“n natural son qiymatini kiriting”)
n=int(input(“n=”))
s=0
for i in range (1, n+1):
n natural sonini kiriting
n=30
Yig'indini qiymati S= 9920