Institute of Computer Science
  1. Courses
  2. 2024/25 spring
  3. Digital Technology - an Overview (LTAT.00.020)
ET
Log in

Digital Technology - an Overview 2024/25 spring

  • Pealeht
  • Loengud
    • L00 - sissejuhatus
    • L01 - bitt
    • L02 - progemine
    • L03 - algoritm
    • L04 - programmeerimiskeeled
    • L05 - pilt
    • L06 - andmestruktuur
    • L07 - tekst ja otsing
    • L08 - andmebaas
    • L09 - op-süsteem
    • L10 - arvutivõrk
    • L11 - tehisaru
    • L12 - optimeerimine
    • L13 - võrgustikud
    • L14 - infoturve
    • L15 - tarkvaratehnika
    • L16 - muutused
  • Kodutööd
    • Ülesanded
  • Hindamine
  • Zulip vestlustuba
  • Infokirjad
  • Lisamaterjalid
    • Jätkukursused
    • ChatGPT näiteid
  • Tagasiside

Examples of discussions with ChatGPT:

Kättesaadavad suured keelemudelid ja AI assistendid

Soovitused:
  • ChatGPT - tasuta ja tasulised versioonid
  • Copilot - TÜ tellitud Copilot, kasutab TÜ autentimist (SSO)
  • Gemini - Google AI; Google One kasutajatel sisse arvestatud
  • Claude AI
  • Mistral.ai chat
  • DeepSeek - uus vabavara Hiinast
  • LLama - Meta vabavaralised mudelid
  • jne.

Lähtelaused

anna kompaktne python kood, mis joonistab PIL abil juhuslikke ringe, ruute, kolmnurki - juhsulikud värvid ja asukohad. juhuslik läbipaistvus ja värv. Kokku 100 kujundit. 1024x1024 pildile. Ja mis töötaks colabis.

from PIL import Image, ImageDraw
import numpy as np
import random
from IPython.display import display  # Kuvamiseks Colabis

# Pildi suurus
img_size = (1024, 1024)
img = Image.new("RGBA", img_size, (255, 255, 255, 255))
draw = ImageDraw.Draw(img, "RGBA")

def random_color():
    """Genereerib juhusliku RGBA värvi (poolläbipaistvus)."""
    return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), random.randint(50, 200))

def draw_random_shape(draw, img_size):
    """Joonistab juhusliku kujundi juhuslikule asukohale."""
    shape_type = random.choice(["circle", "square", "triangle"])
    x1, y1 = random.randint(0, img_size[0]), random.randint(0, img_size[1])
    size = random.randint(50, 200)  # Kujundi maksimaalne suurus
    color = random_color()

    if shape_type == "circle":
        x2, y2 = x1 + size, y1 + size
        draw.ellipse([x1, y1, x2, y2], fill=color, outline=(0, 0, 0, 100))

    elif shape_type == "square":
        x2, y2 = x1 + size, y1 + size
        draw.rectangle([x1, y1, x2, y2], fill=color, outline=(0, 0, 0, 100))

    elif shape_type == "triangle":
        points = [(x1, y1), (x1 + size, y1 + size), (x1 - size, y1 + size)]
        draw.polygon(points, fill=color, outline=(0, 0, 0, 100))

# Joonistame 100 juhuslikku kujundit
for _ in range(100):
    draw_random_shape(draw, img_size)

display(img)  # Kuvab pildi Colabis

kirjuta kompaktne python kood Google Colab jaoks, mis joonistab mulle geomeetrilised kujundid - kolmnurgast 8-nurgani; ühe tsüklina, kolm kujundit reale. Kasuta Matplotlib lahendust.

 
import matplotlib.pyplot as plt
import numpy as np

def draw_polygon(ax, sides, center, radius=40):
    """Joonistab n-küljelise hulknurga antud keskpunktiga."""
    angles = np.linspace(0, 2 * np.pi, sides + 1)
    x = center[0] + radius * np.cos(angles)
    y = center[1] + radius * np.sin(angles)
    ax.plot(x, y, 'b-', linewidth=2)
    ax.fill(x, y, alpha=0.3)  # Kerge täitevärv

def main():
    fig, ax = plt.subplots(figsize=(8, 6))
    ax.set_xlim(-200, 200)
    ax.set_ylim(-150, 150)
    ax.set_aspect('equal')
    ax.axis('off')  # Eemaldame teljed

    start_x, start_y = -150, 100  # Esimese kujundi keskpunkt
    spacing_x, spacing_y = 100, 100  # Vahed

    for i in range(3, 9):  # Kolmnurgast kaheksanurgani
        row = (i - 3) // 3
        col = (i - 3) % 3
        center = (start_x + col * spacing_x, start_y - row * spacing_y)
        draw_polygon(ax, i, center)

    plt.show()

main()

Analoogne lahendus kuid teise joonistamise teegiga - Pillow (PIL)

from PIL import Image, ImageDraw
import numpy as np
from IPython.display import display  # Kuvab pildi Colabis

# Pildi suurus
img_size = (400, 300)
img = Image.new("RGB", img_size, "white")
draw = ImageDraw.Draw(img)

def draw_polygon(draw, sides, center, radius=40, color="blue"):
    """Joonistab n-küljelise hulknurga antud keskpunktiga."""
    angles = np.linspace(0, 2 * np.pi, sides, endpoint=False)
    points = [(center[0] + radius * np.cos(a), center[1] + radius * np.sin(a)) for a in angles]
    draw.polygon(points, outline=color, fill=color)

# Alguspunkt ja paigutus
start_x, start_y = 70, 60
spacing_x, spacing_y = 120, 100

for i in range(3, 9):  # Kolmnurgast kaheksanurgani
    row, col = divmod(i - 3, 3)
    center = (start_x + col * spacing_x, start_y + row * spacing_y)
    draw_polygon(draw, i, center)

display(img)  # Kuvab pildi Google Colabis
  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment