Natija: 2-Misol Musbat yoki Manfiyligini aniqlash dasturi


a=[4,6,8] for i in range(len(a))



Download 0,57 Mb.
bet2/5
Sana28.04.2022
Hajmi0,57 Mb.
#588258
1   2   3   4   5
Bog'liq
SHaxsiy masalalarim pythonda ishlangan

a=[4,6,8]
for i in range(len(a)):
a[i]+=3
print(a)

10-Misol
1 danm 100 gacha bo’lgan butun sonlarni chop etamiz:


for i in range(1,101):
print(i)
Qiymatni nafaqat oshirib boorish balki, kamaytirish ham mumkin. 100 dan 1 gacha barcha sonlarni chop etamiz:

for i in range(100,0,-1):


print(i)

11-Misol
1 dan 10 gacha bo’lgan sonlarni chop etish


i=1
while i<10:
print(i)
i+=1

12-Misol
Kvadratning tomoni a berilgan.Uning perimetiri aniqlansin. p=4*a


a=int(input("Sonni kiriting="))
P=4*a
print(P)
Natija:
Sonni kiriting=12

48
13-Misol


Kvadratning tomoni a berilgan.Uning yuzi aniqlansin.S=a*a
a=int(input("Sonni kiriting="))
S=a*a
print(S)
Natija:


14-Misol
To’g’ri to’rtburchakning tomonlari a va b berilgan.Uning yuzi S=a*b va P=2(a+b) perimetiri aniqlansin.

a=int(input("a="))


b=int(input("b="))
S=a*b
P=2*(a+b)
print(S)
print(P)

Natija:


15-Misol



pi=3.14
d=int(input("Sonni kiriting="))
L=pi*d
print(L)
16-Misol

a=int(input("a="))


V=pow(a,3)
S=6*pow(a,2)
print(V)
print(S)

Natija:


17-Misol

a=int(input("a="))
b=int(input("b="))
c=int(input("c="))
V=a*b*c
S=2*(a*b+b*c+a*c)
print(V)
print(S)


18-Misol

19-Misol

import math
a=int(input("A"))
b=int(input("B"))
S=math.sqrt(a*b)
print(S)
19-Misol

Ilon o’yin dasturi.

from tkinter import *


import random
game_width=500
game_height=500
snake_item=10
snake_color1="red"
snake_color2="white"
snake_x=24
snake_y=24
snake_x_nav =0
snake_y_nav=0
present_color1 = "blue"
present_color2 = "yellow"

snake_list= [ ]


snake_size =4

virtual_game_x = game_width/ snake_item


virtual_game_y = game_height/ snake_item

presents_list = [ ]


presents_size = 5

tk = Tk()


tk.title("Ilon O'yini")
tk.resizable(0,0)
tk.wm_attributes("-topmost",1)
canvas = Canvas(tk, width=game_width, height=game_height, bd=0,highlightthickness=0)
canvas.pack()
tk.update()
for i in range ( presents_size):
x = random.randrange (virtual_game_x )
y = random.randrange (virtual_game_y )
id1 = canvas.create_oval(x*snake_item, y*snake_item, x*snake_item+snake_item, y*snake_item+snake_item, fill=present_color2)
id2 = canvas.create_oval(x*snake_item+2, y*snake_item+2, x*snake_item+snake_item-2, y*snake_item+snake_item-2, fill=present_color2)
presents_list.append([x, y])
print(presents_list)

def snake_paint_item(canvas, x, y,):


global snake_list
id1 = canvas.create_oval(x*snake_item, y*snake_item, x*snake_item+snake_item, y*snake_item+snake_item, fill=snake_color2)
id2 = canvas.create_oval(x*snake_item+2, y*snake_item+2, x*snake_item+snake_item-2, y*snake_item+snake_item-2, fill=snake_color2)
snake_list.append([x, y, id1, id2])

snake_paint_item(canvas, snake_x, snake_y)

def check_can_we_delete_snake_item() :
if len(snake_list)>=snake_size:
temp_item = snake_list.pop(0)
canvas.delete(temp_item[2])
canvas.delete(temp_item[3])
def check_found_sovga():
global snake_size
for i in range(len(presents_list)):
if presents_list[i][0]==snake_x and presents_list[i][1]==snake_y:
snake_size=snake_size+1
canvas.dalete(presents_list[i][2])
canvas.dalete(presents_list[i][3])

def snake_move(event):


global snake_x
global snake_y
if event.keysym=="Up":
snake_x_nav=0
snake_y_nav=-1
check_can_we_delete_snake_item()
elif event.keysym=="Down":
snake_x_nav=0
snake_y_nav=1
check_can_we_delete_snake_item()
elif event.keysym == "Left":
snake_x_nav=-1
snake_y_nav=0
check_can_we_delete_snake_item()
elif event.keysym=="Right":
snake_x_nav=1
snake_y_nav=0
check_can_we_delete_snake_item()
snake_x= snake_x+snake_x_nav
snake_y=snake_y+snake_y_nav
snake_paint_item(canvas, snake_x, snake_y)
check_found_sovga()
canvas.bind_all("" ,snake_move)
canvas.bind_all("", snake_move)
canvas.bind_all("" ,snake_move)
canvas.bind_all("", snake_move)


Download 0,57 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish