Dasturi:
|
Natijasi:
|
import turtle #tashqi
wn = turtle.Screen()
wn.bgcolor("light green")
wn.title("Turtle")
t = turtle.Turtle()
t.color("blue")
def sqrfunc(size):
for i in range(4):
t.fd(size)
t.left(90)
size = size-5
dlina = 146
while dlina > 6:
sqrfunc(dlina)
dlina = dlina - 20
wn.mainloop()
|
|
3-misol. Python dasturlash tilida fon rangi qizil va yashil rangdagi siniq chiziqlardan faoydalangan holda daraxt shaklini hosil qiluvchi dastur tuzing.
|
Dasturi:
|
Natijasi:
|
import turtle as tu
t = tu.Turtle()
t.screen.bgcolor('red')
t.left(90)
t.speed(20)
t.color('green')
t.pensize(5)
t.screen.title("My Fractal Tree")
def draw_fractal(blen):
if(blen<10):
return
else:
t.forward(blen)
t.left(30)
draw_fractal(3*blen/4)
t.right(60)
draw_fractal(3*blen/4)
t.left(30)
t.backward(blen)
draw_fractal(80)
t = tu.done()
|
|
4-misol. Python dasturlash tilida ko’k rangdagi aylanan hosil qiluvchi dastur tuzing. Shakl chiziqni chizishda toshbaqa yordamida hosil qiling.
Dasturi:
|
Natijasi:
|
import turtle
window = turtle.Screen()
t = turtle.Turtle()
t.shape('turtle')
t.color('blue')
t.circle(100)
#window = turtle.Screen()
window.mainloop()
|
|
5-misol. Python dasturlash tilida turli xil rangdagi uchburchaklar hosil qiluvchi dastur tuzing. Shakl chiziqni chizishda toshbaqa yordamida hosil qiling.
Dasturi:
|
Natijasi:
|
from turtle import *
shape("turtle")
wheel=12
bgcolor("blue")
pensize(10)
pencolor("red")
goto(100,0)
for i in range(wheel):
begin_fill() ;
rt (90)
fd(200)
lt(120)
fd (200)
lt(120)
fd (200)
end_fill()
fd (200)
exitonclick()
|
|
6-misol. Python dasturlash tilida turli xil rangdagi kvadratlar hosil qiluvchi dastur tuzing.
Dasturi:
|
Natijasi:
|
from turtle import *
from random import randint
speed(0)
bgcolor('black')
x = 1
while x <= 400:
r = randint(0,255)
g = randint(0,255)
b = randint(0,255)
colormode(255)
pencolor(r,g,b)
fd(50 + x)
rt(90.91)
x = x+1
exitonclick()
|
|
7-misol. Python dasturlash tilida atirgul rasmini hosil qiluvchi dastur tuzing. Shakl chiziqni chizishda toshbaqa yordamida hosil qiling. Shakl chiziqni chizishda toshbaqa yordamida hosil qiling.
Dasturi:
|
from turtle import*
speed(10)
shape("turtle")
bgcolor("black")
pencolor("gray");pensize(40);circle(100, 360);rt(90);circle(130, 360); rt(90);circle(100,360);rt(90);circle(130,360)
pencolor("white");pensize(34);circle(160,360);rt(90);circle(160,360); rt(90);circle (160,360);rt (90);circle(160, 360)
pencolor("brown");pensize(28);circle(110,360);rt(90);circle(140,360); rt(90);circle(140,360);rt(90); circle(110,360)
pencolor("red");pensize(25);circle (120,360);rt(90);circle(120,360); rt(90);circle(120,360);rt(90);circle(120,360)
pencolor ("blue" ); pensize(20); circle(100, 360); rt(90); circle(100,360); rt(90);circle(100,360);rt(90);circle(100,360)
pencolor("yellow");pensize(15);circle(80,360);rt(90);circle(80,360); rt(90);circle(80,360);rt(90);circle(80,360)
pencolor("Aqua");pensize(10);circle(60,360);rt(90); circle(60,360); rt(90); circle(60,360);rt(90);circle(60,360)
pencolor("red");pensize(5);circle(43,360);rt(90);circle(40,360); rt(90);circle(40, 360);rt(90);circle(40,360)
pencolor("white");pensize(2);circle(20,360);rt(90);circle(20,360); rt(90);circle(20, 360);rt(90);circle(20,360)
exitonclick()
|
|
8-misol. Python dasturlash tilida turli xil rangdagi aylanalardan pufakchalar hosil qiluvchi dastur tuzing.
Do'stlaringiz bilan baham: |