Wednesday, December 21, 2022

Хэрчмүүдээр зүрх зурах



import turtle

import math

def xt(t):
    return 16*math.sin(t)**3

def yt(t):
    return 13*math.cos(t)-5*\
        math.cos(2*t)-2*\
            math.cos(3*t)-\
                math.cos(4*t)

t = turtle.Turtle()
t.speed(0)
turtle.bgcolor('black')

for i in range(2550):
    t.goto((xt(i)*20, yt(i)*20))
    t.pencolor('red')
    t.goto(0,0)

Sunday, December 11, 2022

Жишээ №2: Өгүүлбэр бичээд, хүрээ татах

 sentence = input("Sentence: ")

screen_width = 80

text_width = len(sentence)
box_width = text_width + 6
left_margin = (screen_width - box_width) // 2
print()
print(' ' * left_margin + '+' + '-' * (box_width - 2) + '+')
print(' ' * left_margin + '|  ' + ' ' * text_width + '  |')
print(' ' * left_margin + '|  ' + sentence + '  |')
print(' ' * left_margin + '|  ' + ' ' * text_width + '  |')
print(' ' * left_margin + '+' + '-' * (box_width - 2) + '+')
print()