# data[].attributes.attachment_link.description
See all the wonderful things PPCS2018 PERMATApintar has made

# data[].attributes.attachment_link.readable_text
import pygame
import random
 
# Kod setiap warna
HITAM = (0, 0, 0)
PUTIH = (255, 255, 255)
MERAH = (255, 0, 0)
BIRU = (0, 0, 255)
 
# --- Kod
 
 
class Block(pygame.sprite.Sprite):
    """ Kod untuk blok. """
    def __init__(self, color):
        # Call the parent class (Sprite) constructor
        super().__init__()
 
        self.image = pygame.Surface([20, 15])
        self.image.fill(color)
 
        self.rect = self.image.get_rect()
 
 
class Player(pygame.sprite.Sprite):
    """ Kod untuk pemain. """
 
    def __init__(self):
        """ Tetapkan pemain pada blok. """
        # Call the parent class (Sprite) constructor
        super().__init__()
 
        self.image = pygame.Surface([20, 20])
        self.image.fill(MERAH)
 
        self.rect = self.image.get_rect()
 
    def update(self):
        """ Ubah kedudukan pemain. """
        #Gerakkan mouse
        pos = pygame.mouse.get_pos()
 
        # Tetapkan pemain
        self.rect.x = pos[0]
 
 
class Bullet(pygame.sprite.Sprite):
    """ Blok ini mewakili peluru . """
    def __init__(self):
        #Tekan butang mouse di bahagian kiri
        super().__init__()
 
        self.image = pygame.Surface([4, 10])
        self.image.fill(HITAM)
 
        self.rect = self.image.get_rect()
 
    def update(self):
        """ Peluru akan bergerak. """
        self.rect.y -= 3
 
 
# --- Cipta tetingkap
 
pygame.init()
 
# Tetapkan lebar dan tinggi skrin
lebar_skrin = 700
tinggi_skrin = 400
screen = pygame.display.set_mode([lebar_skrin, tinggi_skrin])
 
# --- senarai sprite
 
# Ini ialah senarai sprite. Semua blok dan blok pemain juga termasuk.
all_sprites_list = pygame.sprite.Group()
 
# Senarai untuk setiap blok dalam permainan
block_list = pygame.sprite.Group()
 
# Senarai setiap peluru
bullet_list = pygame.sprite.Group()
 
# --- Cipta Sprite
 
for i in range(50):
    # warna blok yang ditembak
    block = Block(BIRU)
 
    # Tetapkan kedudukan rawak setiap blok
    block.rect.x = random.randrange(lebar_skrin)
    block.rect.y = random.randrange(350)
 
    # Tambahkan blok dalam senarai objek
    block_list.add(block)
    all_sprites_list.add(block)
 
# Blok untuk pemain ialah merah
player = Player()
all_sprites_list.add(player)
 
# Tunggu sehingga pengguna mengklik butang tutup.
done = False
 
# Digunakan untuk menguruskan seberapa cepat pembaikan skrin
clock = pygame.time.Clock()
 
score = 0
player.rect.y = 370
 
# -------- Main Program Loop -----------
while not done:
    # --- Proses
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
 
        elif event.type == pygame.MOUSEBUTTONDOWN:
            # Tembak peluru apabila butang kiri pada mouse ditekan
            bullet = Bullet()
            # Peluru akan mengikut arah peluru yang ditembak oleh pemain
            bullet.rect.x = player.rect.x
            bullet.rect.y = player.rect.y
            # Tambah peluru dalam senarai
            all_sprites_list.add(bullet)
            bullet_list.add(bullet)
 
    all_sprites_list.update()
 
    
    for bullet in bullet_list:
 
        
        block_hit_list = pygame.sprite.spritecollide(bullet, block_list, True)
 
        # Apabila terkena blok biru, tambah markah dan hilangkan peluru
        for block in block_hit_list:
            bullet_list.remove(bullet)
            all_sprites_list.remove(bullet)
            score += 1
            print(score)
 
        # Padamkan peluru dari skrin
        if bullet.rect.y < -10:
            bullet_list.remove(bullet)
            all_sprites_list.remove(bullet)
 
    
 
    # Kosongkan skrin
    screen.fill(PUTIH)
 
    # Lukis sprit
    all_sprites_list.draw(screen)
 
    pygame.display.flip()
 
    clock.tick(60)
 
pygame.quit()

# data[].attributes.attachment_link.readable_text
import pygame, sys
from pygame.locals import*

#colours
black = (0, 0, 0)
brown = (153, 76, 0)
green = (0, 255, 0)
blue = (0, 0, 255)

#resources
dirt = 0
grass = 1
water = 2
coal = 3

#resources to colours
colours = {
    dirt : brown
    grass : green
    water : blue
    coal : black
    }

#tilemap
tilemap = [
    [grass, coal, dirt]
    [water, water, grass]
    [coal, grass, water]
    [dirt, grass, coal]
    [grass, water, dirt]
    ]

#dimensions
tilesize = 40
mapwidth = 3
mapheight = 5

#display setup
pygame.init( )
DISPLAYSURF = pygame.display.set

while True:
    
    #get user events
    for event in pygame.event.get( ):
        #to quit
        if event.type == QUIT:
            #close the window
            pygame.quit( )
            sys.exit( )
    
    #loop through each row
    for row in range(mapheight):
        #loop through each column in the row
        
            

# data[].attributes.body
kth

# data[].attributes.attachment_link.readable_text
import math
import pygame
 
# Define some colors
black = (0, 0, 0)
white = (255, 255, 255)
blue = (0, 0, 255)
 
# Size of break-out blocks
block_width = 23
block_height = 15
 
 
class Block(pygame.sprite.Sprite):
    """This class represents each block that will get knocked out by the ball
    It derives from the "Sprite" class in Pygame """
 
    def __init__(self, color, x, y):
        """ Constructor. Pass in the color of the block,
            and its x and y position. """
 
        # Call the parent class (Sprite) constructor
        super().__init__()
 
        # Create the image of the block of appropriate size
        # The width and height are sent as a list for the first parameter.
        self.image = pygame.Surface([block_width, block_height])
 
        # Fill the image with the appropriate color
        self.image.fill(color)
 
        # Fetch the rectangle object that has the dimensions of the image
        self.rect = self.image.get_rect()
 
        # Move the top left of the rectangle to x,y.
        # This is where our block will appear..
        self.rect.x = x
        self.rect.y = y
 
 
class Ball(pygame.sprite.Sprite):
    """ This class represents the ball
        It derives from the "Sprite" class in Pygame """
 
    # Speed in pixels per cycle
    speed = 10.0
 
    # Floating point representation of where the ball is
    x = 0.0
    y = 180.0
 
    # Direction of ball (in degrees)
    direction = 200
 
    width = 10
    height = 10
 
    # Constructor. Pass in the color of the block, and its x and y position
    def __init__(self):
        # Call the parent class (Sprite) constructor
        super().__init__()
 
        # Create the image of the ball
        self.image = pygame.Surface([self.width, self.height])
 
        # Color the ball
        self.image.fill(white)
 
        # Get a rectangle object that shows where our image is
        self.rect = self.image.get_rect()
 
        # Get attributes for the height/width of the screen
        self.screenheight = pygame.display.get_surface().get_height()
        self.screenwidth = pygame.display.get_surface().get_width()
 
    def bounce(self, diff):
        """ This function will bounce the ball
            off a horizontal surface (not a vertical one) """
 
        self.direction = (180 - self.direction) % 360
        self.direction -= diff
 
    def update(self):
        """ Update the position of the ball. """
        # Sine and Cosine work in degrees, so we have to convert them
        direction_radians = math.radians(self.direction)
 
        # Change the position (x and y) according to the speed and direction
        self.x += self.speed * math.sin(direction_radians)
        self.y -= self.speed * math.cos(direction_radians)
 
        # Move the image to where our x and y are
        self.rect.x = self.x
        self.rect.y = self.y
 
        # Do we bounce off the top of the screen?
        if self.y <= 0:
            self.bounce(0)
            self.y = 1
 
        # Do we bounce off the left of the screen?
        if self.x <= 0:
            self.direction = (360 - self.direction) % 360
            self.x = 1
 
        # Do we bounce of the right side of the screen?
        if self.x > self.screenwidth - self.width:
            self.direction = (360 - self.direction) % 360
            self.x = self.screenwidth - self.width - 1
 
        # Did we fall off the bottom edge of the screen?
        if self.y > 600:
            return True
        else:
            return False
 
 
class Player(pygame.sprite.Sprite):
    """ This class represents the bar at the bottom that the
    player controls. """
 
    def __init__(self):
        """ Constructor for Player. """
        # Call the parent's constructor
        super().__init__()
 
        self.width = 75
        self.height = 15
        self.image = pygame.Surface([self.width, self.height])
        self.image.fill((blue))
 
        # Make our top-left corner the passed-in location.
        self.rect = self.image.get_rect()
        self.screenheight = pygame.display.get_surface().get_height()
        self.screenwidth = pygame.display.get_surface().get_width()
 
        self.rect.x = 0
        self.rect.y = self.screenheight-self.height
 
    def update(self):
        """ Update the player position. """
        # Get where the mouse is
        pos = pygame.mouse.get_pos()
        # Set the left side of the player bar to the mouse position
        self.rect.x = pos[0]
        # Make sure we don't push the player paddle
        # off the right side of the screen
        if self.rect.x > self.screenwidth - self.width:
            self.rect.x = self.screenwidth - self.width
 
# Call this function so the Pygame library can initialize itself
pygame.init()
 
# Create an 800x600 sized screen
screen = pygame.display.set_mode([800, 600])
 
# Set the title of the window
pygame.display.set_caption('Breakout')
 
# Enable this to make the mouse disappear when over our window
pygame.mouse.set_visible(0)
 
# This is a font we use to draw text on the screen (size 36)
font = pygame.font.Font(None, 36)
 
# Create a surface we can draw on
background = pygame.Surface(screen.get_size())
 
# Create sprite lists
blocks = pygame.sprite.Group()
balls = pygame.sprite.Group()
allsprites = pygame.sprite.Group()
 
# Create the player paddle object
player = Player()
allsprites.add(player)
 
# Create the ball
ball = Ball()
allsprites.add(ball)
balls.add(ball)
 
# The top of the block (y position)
top = 80
 
# Number of blocks to create
blockcount = 32
 
# --- Create blocks
 
# Five rows of blocks
for row in range(5):
    # 32 columns of blocks
    for column in range(0, blockcount):
        # Create a block (color,x,y)
        block = Block(blue, column * (block_width + 2) + 1, top)
        blocks.add(block)
        allsprites.add(block)
    # Move the top of the next row down
    top += block_height + 2
 
# Clock to limit speed
clock = pygame.time.Clock()
 
# Is the game over?
game_over = False
 
# Exit the program?
exit_program = False
 
# Main program loop
while not exit_program:
 
    # Limit to 30 fps
    clock.tick(30)
 
    # Clear the screen
    screen.fill(black)
 
    # Process the events in the game
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit_program = True
 
    # Update the ball and player position as long
    # as the game is not over.
    if not game_over:
        # Update the player and ball positions
        player.update()
        game_over = ball.update()
 
    # If we are done, print game over
    if game_over:
        text = font.render("Game Over", True, white)
        textpos = text.get_rect(centerx=background.get_width()/2)
        textpos.top = 300
        screen.blit(text, textpos)
 
    # See if the ball hits the player paddle
    if pygame.sprite.spritecollide(player, balls, False):
        # The 'diff' lets you try to bounce the ball left or right
        # depending where on the paddle you hit it
        diff = (player.rect.x + player.width/2) - (ball.rect.x+ball.width/2)
 
        # Set the ball's y position in case
        # we hit the ball on the edge of the paddle
        ball.rect.y = screen.get_height() - player.rect.height - ball.rect.height - 1
        ball.bounce(diff)
 
    # Check for collisions between the ball and the blocks
    deadblocks = pygame.sprite.spritecollide(ball, blocks, True)
 
    # If we actually hit a block, bounce the ball
    if len(deadblocks) > 0:
        ball.bounce(0)
 
        # Game ends if all the blocks are gone
        if len(blocks) == 0:
            game_over = True
 
    # Draw Everything
    allsprites.draw(screen)
 
    # Flip the screen and show what we've drawn
    pygame.display.flip()
 
pygame.quit()

# data[].attributes.attachment_link.readable_text
# --- Import libraries used for this program
 
import math
import pygame
 
# Define some colors
black = (0, 0, 0)
white = (255, 255, 255)
blue = (0, 0, 255)
 
# Size of break-out blocks
block_width = 23
block_height = 15
 
 
class Block(pygame.sprite.Sprite):

 
    def __init__(self, color, x, y):
        
 
        # Call the parent class (Sprite) constructor
        super().__init__()
 
        # Create the image of the block of appropriate size
        # The width and height are sent as a list for the first parameter.
        self.image = pygame.Surface([block_width, block_height])
 
        # Fill the image with the appropriate color
        self.image.fill(color)
 
        # Fetch the rectangle object that has the dimensions of the image
        self.rect = self.image.get_rect()
 
        # Move the top left of the rectangle to x,y.
        # This is where our block will appear..
        self.rect.x = x
        self.rect.y = y
 
 
class Ball(pygame.sprite.Sprite):

 
    # Speed in pixels per cycle
    speed = 10.0
 
    # Floating point representation of where the ball is
    x = 0.0
    y = 180.0
 
    # Direction of ball (in degrees)
    direction = 200
 
    width = 10
    height = 10
 
    # Constructor. Pass in the color of the block, and its x and y position
    def __init__(self):
        # Call the parent class (Sprite) constructor
        super().__init__()
 
        # Create the image of the ball
        self.image = pygame.Surface([self.width, self.height])
 
        # Color the ball
        self.image.fill(white)
 
        # Get a rectangle object that shows where our image is
        self.rect = self.image.get_rect()
 
        # Get attributes for the height/width of the screen
        self.screenheight = pygame.display.get_surface().get_height()
        self.screenwidth = pygame.display.get_surface().get_width()
 
    def bounce(self, diff):
       
 
        self.direction = (180 - self.direction) % 360
        self.direction -= diff
 
    def update(self):
        
        # Sine and Cosine work in degrees, so we have to convert them
        direction_radians = math.radians(self.direction)
 
        # Change the position (x and y) according to the speed and direction
        self.x += self.speed * math.sin(direction_radians)
        self.y -= self.speed * math.cos(direction_radians)
 
        # Move the image to where our x and y are
        self.rect.x = self.x
        self.rect.y = self.y
 
        # Do we bounce off the top of the screen?
        if self.y <= 0:
            self.bounce(0)
            self.y = 1
 
        # Do we bounce off the left of the screen?
        if self.x <= 0:
            self.direction = (360 - self.direction) % 360
            self.x = 1
 
        # Do we bounce of the right side of the screen?
        if self.x > self.screenwidth - self.width:
            self.direction = (360 - self.direction) % 360
            self.x = self.screenwidth - self.width - 1
 
        # Did we fall off the bottom edge of the screen?
        if self.y > 600:
            return True
        else:
            return False
 
 
class Player(pygame.sprite.Sprite):
    
 
    def __init__(self):
        
        # Call the parent's constructor
        super().__init__()
 
        self.width = 75
        self.height = 15
        self.image = pygame.Surface([self.width, self.height])
        self.image.fill((white))
 
        # Make our top-left corner the passed-in location.
        self.rect = self.image.get_rect()
        self.screenheight = pygame.display.get_surface().get_height()
        self.screenwidth = pygame.display.get_surface().get_width()
 
        self.rect.x = 0
        self.rect.y = self.screenheight-self.height
 
    def update(self):
      
        # Get where the mouse is
        pos = pygame.mouse.get_pos()
        # Set the left side of the player bar to the mouse position
        self.rect.x = pos[0]
        # Make sure we don't push the player paddle
        # off the right side of the screen
        if self.rect.x > self.screenwidth - self.width:
            self.rect.x = self.screenwidth - self.width
 
# Call this function so the Pygame library can initialize itself
pygame.init()
 
# Create an 800x600 sized screen
screen = pygame.display.set_mode([800, 600])
 
# Set the title of the window
pygame.display.set_caption('Breakout')
 
# Enable this to make the mouse disappear when over our window
pygame.mouse.set_visible(0)
 
# This is a font we use to draw text on the screen (size 36)
font = pygame.font.Font(None, 36)
 
# Create a surface we can draw on
background = pygame.Surface(screen.get_size())
 
# Create sprite lists
blocks = pygame.sprite.Group()
balls = pygame.sprite.Group()
allsprites = pygame.sprite.Group()
 
# Create the player paddle object
player = Player()
allsprites.add(player)
 
# Create the ball
ball = Ball()
allsprites.add(ball)
balls.add(ball)
 
# The top of the block (y position)
top = 80
 
# Number of blocks to create
blockcount = 32
 
# --- Create blocks
 
# Five rows of blocks
for row in range(5):
    # 32 columns of blocks
    for column in range(0, blockcount):
        # Create a block (color,x,y)
        block = Block(blue, column * (block_width + 2) + 1, top)
        blocks.add(block)
        allsprites.add(block)
    # Move the top of the next row down
    top += block_height + 2
 
# Clock to limit speed
clock = pygame.time.Clock()
 
# Is the game over?
game_over = False
 
# Exit the program?
exit_program = False
 
# Main program loop
while not exit_program:
 
    # Limit to 30 fps
    clock.tick(30)
 
    # Clear the screen
    screen.fill(black)
 
    # Process the events in the game
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit_program = True
 
    # Update the ball and player position as long
    # as the game is not over.
    if not game_over:
        # Update the player and ball positions
        player.update()
        game_over = ball.update()
 
    # If we are done, print game over
    if game_over:
        text = font.render("Game Over", True, white)
        textpos = text.get_rect(centerx=background.get_width()/2)
        textpos.top = 300
        screen.blit(text, textpos)
 
    # See if the ball hits the player paddle
    if pygame.sprite.spritecollide(player, balls, False):
        # The 'diff' lets you try to bounce the ball left or right
        # depending where on the paddle you hit it
        diff = (player.rect.x + player.width/2) - (ball.rect.x+ball.width/2)
 
        # Set the ball's y position in case
        # we hit the ball on the edge of the paddle
        ball.rect.y = screen.get_height() - player.rect.height - ball.rect.height - 1
        ball.bounce(diff)
 
    # Check for collisions between the ball and the blocks
    deadblocks = pygame.sprite.spritecollide(ball, blocks, True)
 
    # If we actually hit a block, bounce the ball
    if len(deadblocks) > 0:
        ball.bounce(0)
 
        # Game ends if all the blocks are gone
        if len(blocks) == 0:
            game_over = True
 
    # Draw Everything
    allsprites.draw(screen)
 
    # Flip the screen and show what we've drawn
    pygame.display.flip()
 
pygame.quit()

# data[].attributes.attachment_link.readable_text
#!/usr/bin/python

# Tic-Tac-Toe
# pyGame Demo
# Nathan R. Yergler
# 13 May 2002

# import necessary modules
import pygame
from pygame.locals import *

# declare our global variables for the game
XO   = "O"   # track whose turn it is; O goes first
grid = [ [ None, None, None ], \
         [ None, None, None ], \
         [ None, None, None ] ]

winner = None

# declare our support functions

def initBoard(ttt):
    # initialize the board and return it as a variable
    # ---------------------------------------------------------------
    # ttt : a properly initialized pyGame display variable

    # set up the background surface
    background = pygame.Surface (ttt.get_size())
    background = background.convert()
    background.fill ((127, 250, 250))

    # draw the grid lines
    # vertical lines...
    pygame.draw.line (background, (255,255,255), (100, 0), (100, 300), 2)
    pygame.draw.line (background, (255,255,255), (200, 0), (200, 300), 2)

    # horizontal lines...
    pygame.draw.line (background, (255,255,255), (0, 100), (300, 100), 2)
    pygame.draw.line (background, (255,255,255), (0, 200), (300, 200), 2)

    # return the board
    return background

def drawStatus (board):
    # draw the status (i.e., player turn, etc) at the bottom of the board
    # ---------------------------------------------------------------
    # board : the initialized game board surface where the status will
    #         be drawn

    # gain access to global variables
    global XO, winner

    # determine the status message
    if (winner is None):
        message = XO + "'s turn"
    else:
        message = winner + " won!"
        
    # render the status message
    font = pygame.font.Font(None, 24)
    text = font.render(message, 1, (10, 10, 10))

    # copy the rendered message onto the board
    board.fill ((0, 255, 250), (0, 300, 300, 25))
    board.blit(text, (10, 300))

def showBoard (ttt, board):
    # redraw the game board on the display
    # ---------------------------------------------------------------
    # ttt   : the initialized pyGame display
    # board : the game board surface

    drawStatus (board)
    ttt.blit (board, (0, 0))
    pygame.display.flip()
    
def boardPos (mouseX, mouseY):
    # given a set of coordinates from the mouse, determine which board space
    # (row, column) the user clicked in.
    # ---------------------------------------------------------------
    # mouseX : the X coordinate the user clicked
    # mouseY : the Y coordinate the user clicked

    # determine the row the user clicked
    if (mouseY < 100):
        row = 0
    elif (mouseY < 200):
        row = 1
    else:
        row = 2

    # determine the column the user clicked
    if (mouseX < 100):
        col = 0
    elif (mouseX < 200):
        col = 1
    else:
        col = 2

    # return the tuple containg the row & column
    return (row, col)

def drawMove (board, boardRow, boardCol, Piece):
    # draw an X or O (Piece) on the board in boardRow, boardCol
    # ---------------------------------------------------------------
    # board     : the game board surface
    # boardRow,
    # boardCol  : the Row & Col in which to draw the piece (0 based)
    # Piece     : X or O
    
    # determine the center of the square
    centerX = ((boardCol) * 100) + 50
    centerY = ((boardRow) * 100) + 50

    # draw the appropriate piece
    if (Piece == 'O'):
        pygame.draw.circle (board, (0,0,0), (centerX, centerY), 44, 2)
    else:
        pygame.draw.line (board, (0,0,0), (centerX - 22, centerY - 22), \
                         (centerX + 22, centerY + 22), 2)
        pygame.draw.line (board, (0,0,0), (centerX + 22, centerY - 22), \
                         (centerX - 22, centerY + 22), 2)

    # mark the space as used
    grid [boardRow][boardCol] = Piece
    
def clickBoard(board):
    # determine where the user clicked and if the space is not already
    # occupied, draw the appropriate piece there (X or O)
    # ---------------------------------------------------------------
    # board : the game board surface
    
    global grid, XO
    
    (mouseX, mouseY) = pygame.mouse.get_pos()
    (row, col) = boardPos (mouseX, mouseY)

    # make sure no one's used this space
    if ((grid[row][col] == "X") or (grid[row][col] == "O")):
        # this space is in use
        return

    # draw an X or O
    drawMove (board, row, col, XO)

    # toggle XO to the other player's move
    if (XO == "X"):
        XO = "O"
    else:
        XO = "X"
    
def gameWon(board):
    # determine if anyone has won the game
    # ---------------------------------------------------------------
    # board : the game board surface
    
    global grid, winner

    # check for winning rows
    for row in range (0, 3):
        if ((grid [row][0] == grid[row][1] == grid[row][2]) and \
           (grid [row][0] is not None)):
            # this row won
            winner = grid[row][0]
            pygame.draw.line (board, (250,0,0), (0, (row + 1)*100 - 50), \
                              (300, (row + 1)*100 - 50), 2)
            break

    # check for winning columns
    for col in range (0, 3):
        if (grid[0][col] == grid[1][col] == grid[2][col]) and \
           (grid[0][col] is not None):
            # this column won
            winner = grid[0][col]
            pygame.draw.line (board, (250,0,0), ((col + 1)* 100 - 50, 0), \
                              ((col + 1)* 100 - 50, 300), 2)
            break

    # check for diagonal winners
    if (grid[0][0] == grid[1][1] == grid[2][2]) and \
       (grid[0][0] is not None):
        # game won diagonally left to right
        winner = grid[0][0]
        pygame.draw.line (board, (250,0,0), (50, 50), (250, 250), 2)

    if (grid[0][2] == grid[1][1] == grid[2][0]) and \
       (grid[0][2] is not None):
        # game won diagonally right to left
        winner = grid[0][2]
        pygame.draw.line (board, (250,0,0), (250, 50), (50, 250), 2)

# --------------------------------------------------------------------
# initialize pygame and the window
pygame.init()
ttt = pygame.display.set_mode ((300, 325))
pygame.display.set_caption ('Tic-Tac-Toe')

# create the game board
board = initBoard (ttt)

# main event loop
running = 1

while (running == 1):
    for event in pygame.event.get():
        if event.type is QUIT:
            running = 0
        elif event.type is MOUSEBUTTONDOWN:
            # the user clicked; place an X or O
            clickBoard(board)

        # check for a winner
        gameWon (board)

        # update the display
        showBoard (ttt, board)

# data[].attributes.attachment_link.readable_text
import pygame
import random
import time

pygame.init()

lebar_skrin = 600
tinggi_skrin = 400

hitam = (0, 0, 0)
putih = (255, 255, 255)
merah = (255, 0, 0)
hijau = (0, 255, 0)
biru = (0, 0, 255)
oren = (255, 127, 0)
kuning = (255, 255, 0)
ungu = (127, 0, 255)
coklat = (102, 51, 0)

skrin_game = pygame.display.set_mode([lebar_skrin, tinggi_skrin])
pygame.display.set_caption("Table Football")
stail_huruf = pygame.font.SysFont("monospace", 75)

bola_x = int(lebar_skrin/2)
bola_y = int(tinggi_skrin/2)

bola_xv = 5
bola_yv = 5

bola_r = 20
 
bat1_x = 10
bat1_y = 10
bat1_w = 25
bat1_h = 100
#
bat2_x = lebar_skrin - 35
bat2_y = 10
bat2_w = 25
bat2_h = 100

bat3_x = lebar_skrin - 150
bat3_y = 10
bat3_w = 25
bat3_h = 100

bat4_x = lebar_skrin - 450
bat4_y = 10
bat4_w = 25
bat4_h = 100

skor_kumpulan1 = 0
skor_kumpulan2 = 0

pygame.mouse.set_visible(0)
do_main = True

while do_main:
    tekan = pygame.key.get_pressed()
    pygame.key.set_repeat
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            do_main = False

    if tekan[pygame.K_ESCAPE]:
      do_main = False
      
    if tekan[pygame.K_w]:
        bat1_y -= 5
    elif tekan[pygame.K_s]:
        bat1_y += 5
        
    if tekan[pygame.K_UP]:
        bat2_y -= 5
    elif tekan[pygame.K_DOWN]:
        bat2_y += 5
        
    if tekan[pygame.K_i]:
        bat3_y -= 5
    elif tekan[pygame.K_k]:
        bat3_y += 5
        
    if tekan[pygame.K_r]:
        bat4_y -= 5
    elif tekan[pygame.K_f]:
        bat4_y += 5         
        
        
    bola_x += bola_xv
    bola_y += bola_yv
    
    if bola_y - bola_r <= 0 or bola_y + bola_r >= tinggi_skrin:
        bola_yv *= -1
        
    if bat1_y < 0:
        bat1_y = 0
    elif bat1_y + bat1_h > tinggi_skrin:
        bat1_y = tinggi_skrin - bat1_h
        
    if bat2_y < 0:
        bat2_y = 0
    elif bat2_y + bat2_h > tinggi_skrin:
        bat2_y = tinggi_skrin - bat2_h
        
    if bat3_y < 0:
        bat3_y = 0
    elif bat3_y + bat3_h > tinggi_skrin:
        bat3_y = tinggi_skrin - bat3_h
        
    if bat4_y < 0:
        bat4_y = 0
    elif bat4_y + bat4_h > tinggi_skrin:
        bat4_y = tinggi_skrin - bat4_h
        
    if bola_x < bat1_x + bat1_w and bola_y >= bat1_y and bola_y <= bat1_y + bat1_h:
        bola_xv*=-1
        
    if bola_x < bat2_x + bola_y >= bat2_y and bola_y <= bat2_y + bat2_h:
        bola_xv*=-1
        
    if bola_x < bat3_x + bola_y >= bat3_y and bola_y <= bat3_y + bat3_h:
        bola_xv*=-1
        
    if bola_x < bat4_x + bola_y >= bat4_y and bola_y <= bat4_y + bat4_h:
        bola_xv*=-1
        
    if bola_x <= 0:
        skor_kumpulan2 +=1
        bola_x = int(lebar_skrin/2)
        bola_y = int(tinggi_skrin/2)
    elif bola_x >= lebar_skrin:
        skor_kumpulan1 +=1
        bola_x = int(lebar_skrin/2)
        bola_y = int(tinggi_skrin/2)
        
    skrin_game.fill(hijau)
    bat_1 = pygame.draw.rect(skrin_game, merah, [bat1_x, bat1_y, bat1_w, bat1_h], 0)
    bat_2 = pygame.draw.rect(skrin_game, biru, [bat2_x, bat2_y, bat2_w, bat2_h], 0)
    bat_3 = pygame.draw.rect(skrin_game, biru, [bat3_x, bat3_y, bat3_w, bat3_h], 0)
    bat_4 = pygame.draw.rect(skrin_game, merah, [bat4_x, bat4_y, bat4_w, bat4_h], 0)
    
    jaring = pygame.draw.line(skrin_game, hitam, [300,5], [300,400])
    bola = pygame.draw.circle(skrin_game, putih, [bola_x,bola_y], bola_r, 0)
    teks_skor = stail_huruf.render(str(skor_kumpulan1) + " " + str(skor_kumpulan2), 1, hitam)
    skrin_game.blit(teks_skor, [lebar_skrin/2 - teks_skor.get_width()/2, 10])
    
    pygame.display.update()
    time.sleep(0.0166666667)
    
pygame.quit
        
        
                     

# data[].attributes.body
Breakout Forever

# data[].attributes.attachment_link.readable_text
import math
import pygame
 
# Define some colors
blue = (0, 0, 255)
white = (255, 255, 255)
green = (0, 255, 0)
 
# Size of break-out blocks
block_width = 23
block_height = 15
 
 
class Block(pygame.sprite.Sprite):
    """This class represents each block that will get knocked out by the ball
    It derives from the "Sprite" class in Pygame """
 
    def __init__(self, color, x, y):
        """ Constructor. Pass in the color of the block,
            and its x and y position. """
 
        # Call the parent class (Sprite) constructor
        super().__init__()
 
        # Create the image of the block of appropriate size
        # The width and height are sent as a list for the first parameter.
        self.image = pygame.Surface([block_width, block_height])
 
        # Fill the image with the appropriate color
        self.image.fill(color)
 
        # Fetch the rectangle object that has the dimensions of the image
        self.rect = self.image.get_rect()
 
        # Move the top left of the rectangle to x,y.
        # This is where our block will appear..
        self.rect.x = x
        self.rect.y = y
 
 
class Ball(pygame.sprite.Sprite):
    """ Kelas ini menunjukkan bola """
 
    # Kelajuan pixel
    speed = 10.9
 
    # Dimana bola itu pertama kali
    x = 0.0
    y = 180.0
 
    # Arah bola (didalam darjah)
    direction = 150
 
    width = 10
    height = 10
 
    # Pembuat.Menentukan warna dan posisi x y bola
    def __init__(self):
        # Memanggil kelas utama pembuat (Sprite) 
        super().__init__()
 
        # Buat Image bola
        self.image = pygame.Surface([self.width, self.height])
 
        # Warnakan bola
        self.image.fill(blue)
 
        # Dapatkan objek segiempat tepat untuk image
        self.rect = self.image.get_rect()
 
        # Atribut untuk skrin
        self.screenheight = pygame.display.get_surface().get_height()
        self.screenwidth = pygame.display.get_surface().get_width()
 
    def bounce(self, diff):
        """ Ini melantunkannya ke arah melintang """
 
        self.direction = (180 - self.direction) % 360
        self.direction -= diff
 
    def update(self):
        """ Kemaskini kedudukan bola """
        # Sine dan Cosine berfungsi dalam darjah, jadi kita harus menukarnya
        direction_radians = math.radians(self.direction)
 
        # Tukar posisi x y mengikut arah dan kelajuan
        self.x += self.speed * math.sin(direction_radians)
        self.y -= self.speed * math.cos(direction_radians)
 
        # Menggerakkan imej ke posisi x y
        self.rect.x = self.x
        self.rect.y = self.y
 
        # Perlu melantunkannya ?
        if self.y <= 0:
            self.bounce(0)
            self.y = 1
 
        # Perlu melantunkan dari kiri?
        if self.x <= 0:
            self.direction = (360 - self.direction) % 360
            self.x = 1
 
        #  Perlu melantunkan dari kanan?
        if self.x > self.screenwidth - self.width:
            self.direction = (360 - self.direction) % 360
            self.x = self.screenwidth - self.width - 1
 
        # Jatuh dari skrin?
        if self.y > 600:
            return True
        else:
            return False
 
 
class Player(pygame.sprite.Sprite):
    """ Kelas ini untuk paddle """
 
    def __init__(self):
        """ Constructor untuk Player. """
        # Dapatkan parent's constructor
        super().__init__()
 
        self.width = 75
        self.height = 15
        self.image = pygame.Surface([self.width, self.height])
        self.image.fill((blue))
 
        
        self.rect = self.image.get_rect()
        self.screenheight = pygame.display.get_surface().get_height()
        self.screenwidth = pygame.display.get_surface().get_width()
 
        self.rect.x = 0
        self.rect.y = self.screenheight-self.height
 
    def update(self):
        """ Kemaskini posisi pemain (paddle) """
        # Pergi posisi tetikus
        pos = pygame.mouse.get_pos()
        # Set sisi kiri bar pemain
        self.rect.x = pos[0]
        # Pastikan paddle pemain tidak ditolak
        # keluar sebelah kanan
        if self.rect.x > self.screenwidth - self.width:
            self.rect.x = self.screenwidth - self.width
 
# Call this function so the Pygame library can initialize itself
pygame.init()
 
# Buat skrin saiz 800x600 
screen = pygame.display.set_mode([800, 600])
 
# Set Nama tetingkap
pygame.display.set_caption('A Fun Breakout')
 
# Ini supaya mouse tidak ada apabila diatas skrin tetingkap
pygame.mouse.set_visible(0)
 
# Font tulisan saiz 36
font = pygame.font.Font(None, 36)
 
# Create a surface we can draw on
background = pygame.Surface(screen.get_size())
 
# Create sprite lists
blocks = pygame.sprite.Group()
balls = pygame.sprite.Group()
allsprites = pygame.sprite.Group()
 
# Create the player paddle object
player = Player()
allsprites.add(player)
 
# Create the ball
ball = Ball()
allsprites.add(ball)
balls.add(ball)
 
# The top of the block (y position)
top = 80
 
# Number of blocks to create
blockcount = 300
 
# --- Create blocks
 
# Five rows of blocks
for row in range(5):
    # 32 columns of blocks
    for column in range(0, blockcount):
        # Create a block (color,x,y)
        block = Block(green, column * (block_width + 2) + 1, top)
        blocks.add(block)
        allsprites.add(block)
    # Move the top of the next row down
    top += block_height + 2
 
# Clock to limit speed
clock = pygame.time.Clock()
 
# Is the game over?
game_over = False
 
# Exit the program?
exit_program = False
 
# Main program loop
while not exit_program:
 
    # Limit to 30 fps
    clock.tick(30)
 
    # Membersihkan skrin
    screen.fill(white)
 
    # Proses acara didalam permainan
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit_program = True
 
    # Kemaskini posisi paddle pemain dan bola selagi
    # permainan tidak tamat
    if not game_over:
        # Kemaskini posisi paddle pemain dan bola
        player.update()
        game_over = ball.update()
 
    # Jika tamat paparkan Permainan Tamat
    if game_over:
        text = font.render("Permainan Tamat", True, blue)
        textpos = text.get_rect(centerx=background.get_width()/2)
        textpos.top = 300
        screen.blit(text, textpos)
 
    # Lihat jika bola terkena paddle
    if pygame.sprite.spritecollide(player, balls, False):
        # 'diff' beri kamu cuba melantunkannya ke kanan atau kiri
        # bergantung kepada dimana di paddle ia terkena 
        diff = (player.rect.x + player.width/2) - (ball.rect.x+ball.width/2)
 
        # Set posisi y bola jika
        # terkena sisi paddle
        ball.rect.y = screen.get_height() - player.rect.height - ball.rect.height - 1
        ball.bounce(diff)
 
    # Periksa jika bola dan block berlanggaran
    deadblocks = pygame.sprite.spritecollide(ball, blocks, True)
 
    # Jika terkena block,Lantunkan bola
    if len(deadblocks) > 0:
        ball.bounce(0)
 
        #Jika tiada block hentikan permainan
        if len(blocks) == 0:
            game_over = True
 
    #Lukis semuanya
    allsprites.draw(screen)
 
    # Terbalikkan skrin dan tunjukkan apa kita buat
    pygame.display.flip()
 
pygame.quit()#Hentikan Permainan

# data[].attributes.attachment_link.readable_text
import pygame
import random
import time

pygame.init()

lebar_skrin=600
tinggi_skrin=400

merah=(255,0,0)
oren=(255,127,0)
kuning=(255,255,0)
hijau=(0,255,0)
biru=(0,0,255)
unggu=(127,0,255)
coklat=(102,51,0)
hitam=(0,0,0)
putih=(255,255,255)

skrin_utkgame=pygame.display.set_mode([lebar_skrin,tinggi_skrin])
pygame.display.set_caption("Pong")
stall_huruf= pygame.font.SysFont("monospace", 75)

bola_x=int(lebar_skrin/2)
bola_y=int(tinggi_skrin/2)

bola_xv=4
bola_yv=4

bola_r=10

bat1_x=10
bat1_y=10
bat1_w=70
bat1_h=70
# draw paddle1 (bat1 pingpong)
bat2_x=lebar_skrin-35
bat2_y=10
bat2_w=70
bat2_h=70
#initiallizing the score
skor_pemain1=0
skor_pemain2=0
#gmaeloop
pygame.mouse.set_visible(0)
do_main= True

while do_main:
    tekan=pygame.key.get_pressed()
    pygame.key.set_repeat
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            do_main =False
    
    if tekan[pygame.K_ESCAPE]:
        do_main= False
    
    if tekan[pygame.K_w]:
        bat1_y -= 10
    
    elif tekan[pygame.K_s]:
        bat1_y += 10
        
    elif tekan[pygame.K_d]:
        bat1_x += 10
        
    elif tekan[pygame.K_a]:
        bat1_x -= 10
         
    if tekan[pygame.K_UP]:
        bat2_y -= 10
    
    elif tekan[pygame.K_DOWN]:
        bat2_y += 10
    elif tekan[pygame.K_LEFT]:
        bat2_x -= 10
    elif tekan[pygame.K_RIGHT]:
        bat2_x += 10
    #location of ball is updated    
    bola_x += bola_xv
    bola_y += bola_yv
    #collision of ball with top/bottom of screen
    if bola_y - bola_r <= 0 or bola_y + bola_r >= tinggi_skrin:
        bola_yv *= -1
    #collision of paddle with edges of skrin    
    if bat1_y < 0:
        bat1_y = 0
    elif bat1_y + bat1_h > tinggi_skrin:
        bat1_y = tinggi_skrin - bat1_h
        
    if bat2_y < 0:
        bat2_y = 0
    elif bat2_y + bat2_h > tinggi_skrin:
        bat2_y = tinggi_skrin - bat2_h
        
    if bola_x < bat1_x + bat1_w and bola_y >= bat1_y and bola_y <= bat1_y + bat1_h:
        bola_xv*=-1
    if bola_x > bat2_x and bola_y >= bat2_y and bola_y <= bat2_y + bat2_h:
        bola_xv*=-1
        
    if bola_x <= 0:
        skor_pemain2 +=1
        bola_x = int(lebar_skrin/2)
        bola_y = int(tinggi_skrin/2)
    elif bola_x >= lebar_skrin:
        skor_pemain1 +=1
        bola_x = int(lebar_skrin/2)
        bola_y = int(tinggi_skrin/2)
    if skor_pemain1 >= 20:
        do_main=False
    if skor_pemain2 >= 20:
        do_main=False
    skrin_utkgame.fill(coklat)
    bat_1 = pygame.draw.rect(skrin_utkgame, putih, [bat1_x, bat1_y, bat1_w, bat1_h],0)
    bat_2 = pygame.draw.rect(skrin_utkgame, biru, [bat2_x, bat2_y, bat2_w, bat2_h],0)
    
    jaring=pygame.draw.line(skrin_utkgame, putih,  [300,5], [300,400])
    bola= pygame.draw.circle(skrin_utkgame, merah, [bola_x,bola_y], bola_r,0)
    teks_skor = stall_huruf.render(str(skor_pemain1) + " " + str(skor_pemain2), 1,hitam)
    skrin_utkgame.blit(teks_skor, [lebar_skrin/2 - teks_skor.get_width()/2, 10])
    
    pygame.display.update()
    time.sleep(0.016666667)
    
pygame.quit()

# data[].attributes.attachment_link.readable_text
from tkinter import*
from tkinter.ttk import*

ikon_bergambar = Tk( )

def display():
    strLblOutput.set("Paparkan Output")
    
def dispaly2():
    strLblOutput.set("Mengosongkan label")
    
def exit():
    strLblOutput.set("Keluar")
    
#border style, relief: raised, sunken, flat, groove, solid
strLblOutput = StringVar()
lblGambar = Label(ikon_bergambar, textvariable=strLblOutput, relief="sunken")
lblGambar.place(x=30, y=20, width=370, height=40)


gambar1 = PhotoImage(file="cat2.png")
gambar2 = PhotoImage(file="ayam.png")
gambar3 = PhotoImage(file="pintu.png")

btnPapar = Button(ikon_bergambar, text="Kucing", image = gambar1, compound="left", command = display)
btnPapar.place(x=30, y=130, width=110, height=50)

btnReset = Button(ikon_bergambar, text="Ayam", image = gambar2, compound="left", command = display2)
btnReset.place(x=160, y=130, width=110, height=50)

btnKeluar = Button(ikon_bergambar, text="Keluar", image = gambar3, compound="left", command = quit)
btnKeluar.place(x=290, y=130, width=110, height=50)

ikon_bergambar.title("Window with picture")
ikon_bergambar.geometry("430x200")

ikon_bergambar.mainloop 

# data[].attributes.attachment_link.readable_text
from tkinter import*

screen_picture = Tk( )

gambar = PhotoImage(file="print.png")

lblGambar = Label(screen_picture, image=gambar, relief="solid", borderwidth=15)
lblGambar.place(x=60, y=30, width=140, height=140)

screen_picture.title("Window with picture")
screen_picture.geometry("300x300")
screen_picture.mainloop
    

# data[].attributes.attachment_link.readable_text
n1=float(input("Type a number: "))
n2=float(input("Type another number: "))
if n1>n2:
    print(str(n1) + ">" + str(n2))
    
elif n1==n2:
        print(str(n1) + "=" + str(n2))
        
elif n1<n2:
            print(str(n1) + "<" + str(n2))

# data[].attributes.attachment_link.readable_text
h=float(input("Give your height in m: "))
w=float(input("Give your weight in kg: "))
b=w/(h*h)
print(b)
if b<18.5:
    print("You are slightly underweight.It is only slightly so do not be so happy ok!")
elif b<24.9:
    print("You are normal.We will see how long can you maintain your weight.")
elif b<29.9:
    print("You are as heavy as a hippopotamus.")
elif b>=30:
    print("How is this possible?You are extremely obese and I cannot describe it in words.")

# data[].attributes.body
the title of the program is random.(i type anything)

# data[].attributes.attachment_link.readable_text
import turtle
import random
import time

width = height = 500 
 
window = turtle.Screen() 
window.setup(width, height) 
window.bgcolor("green")
window.title("Christmas")

snowball_rate=1,3
snowball_size=5,15
wind_change=1,5
max_wind=10


def make_circle(turtle_name, x, y, size, colour):
    turtle_name.color(colour)
    turtle_name.penup()
    turtle_name.setposition(x,y)
    turtle_name.dot(size)


list_of_snowballs=[]
def make_snowball():
    snowball=turtle.Turtle()
    snowball.color("blue")
    snowball.penup()
    snowball.setposition(random.randint(-2*width,width/2),height/2)
    snowball.hideturtle()
    snowball.size = random.randint(*snowball_size) 
    list_of_snowballs.append(snowball)
    
def move_snowball(turtle_name, falling_speed=10, wind=10): 
    turtle_name.clear() 
    turtle_name.sety(turtle_name.ycor() - falling_speed) 
    if wind: 
        turtle_name.setx(turtle_name.xcor() + wind) 
    turtle_name.dot(turtle_name.size)
    
    
snowman = turtle.Turtle() 
x_position = 0 
y_positions = 75, 0, -100 
size = 75 
for y in y_positions: 
    make_circle(snowman, x_position, y, size, "blue") 
    size = size *1.5
    
    
grass = turtle.Turtle() 
grass.fillcolor("light green") 
grass.penup() 
grass.setposition(-width/2, -height/2) 
grass.begin_fill() 
for _ in range(2): 
    grass.forward(width) 
    grass.left(90) 
    grass.forward(70) 
    grass.left(90) 
grass.end_fill() 

ground = turtle.Turtle() 
for x in range(int(-width/2), int(width/2), int(width/200)): 
    make_circle(ground, x, -180, random.randint(20, 20), "blue") 
 
text = turtle.Turtle() 
text.color("black") 
text.penup() 
text.setposition(-100,170) 
text.write("Merry Christmas to one and all !", font=("Apple Chancery", 30, "bold"), align="center") 
text.setposition(130, 140) 
text.color("dark blue") 

time_delay = 0 
start_time = time.time()

time_delay = 0 
start_time = time.time() 
wind = 10 
wind_delay = 5
wind_timer = time.time() 
wind_step = 0.1 
while True: 
    if time.time() - start_time > time_delay: 
        make_snowball() 
        start_time = time.time() 
        time_delay = random.randint(*snowball_rate)/10 

    for snowball in list_of_snowballs: 
        move_snowball(snowball, wind=wind) 
        if snowball.ycor() < -height/2: 
            snowball.clear() 
            list_of_snowballs.remove(snowball) 
 
    if time.time() - wind_timer > wind_delay: 
        wind += wind_step 
        if wind >= max_wind: 
            wind_step = -wind_step 
        elif wind <= 0: 
            wind_step = abs(wind_step) 
 
        wind_timer = time.time() 
        wind_delay = random.randint(*wind_change)/10 
 
 
    window.update() 
 
turtle.done()

# data[].attributes.attachment_link.readable_text
from tkinter import*

screen_picture = Tk( )

gambar = PhotoImage(file="print-icon.png")

lblGambar = Label(screen_picture, image=gambar, relief="solid", borderwidth=15)
lblGambar.place(x=60, y=30, width=140, height=140)

screen_picture.title("Window with picture")
screen_picture.geometry("300x300")
screen_picture.mainloop

# data[].attributes.attachment_link.readable_text
import turtle
fred=turtle.Pen()
fred.shape("turtle")
fred.color("orange","yellow")



fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.forward(100)
fred.left(72)

fred.forward(100)
fred.right(144)

fred.right(10)

# data[].attributes.attachment_link.readable_text
import turtle
fred=turtle.Turtle()
fred.shape("circle")
fred.color("red")
turtle.bgcolor("sky blue")

fred.circle(30)
fred.circle(40)
fred.circle(50)
fred.circle(60)
fred.circle(70)
fred.circle(80)
fred.circle(90)
fred.circle(100)
fred.circle(110)
fred.circle(120)
fred.circle(130)
fred.circle(140)
fred.circle(150)
fred.circle(160)
fred.circle(170)
fred.circle(180)
fred.circle(190)
fred.circle(200)
fred.circle(210)
fred.circle(220)
fred.forward(100)
fred.left(72)
fred.forward(100)
fred.right(144)

turtle.mainloop()






















# data[].attributes.body
Turtle

# data[].attributes.attachment_link.readable_text
import turtle
fred=turtle.Pen()
canvas=turtle.Screen()
canvas.bgcolor("yellow")
fred.shape("turtle")
fred.fillcolor("pink")
fred.pencolor("yellow")
fred.goto(-1000, 300)
fred.pencolor("pink")
fred.forward(2000)
fred.penup()

fred.begin_fill()
fred.left(90)
fred.forward(2000)
fred.left(90)
fred.forward(2000)
fred.left(90)
fred.forward(2000)
fred.left(90)
fred.forward(2000)
fred.end_fill()

fred.fillcolor("pink")
fred.pencolor("yellow")
fred.goto(1000, -300)
fred.pencolor("pink")
fred.forward(-2000)
fred.penup()

fred.begin_fill()
fred.forward(2000)
fred.right(90)
fred.forward(2000)
fred.right(90)
fred.forward(2000)
fred.right(90)
fred.forward(2000)
fred.right(90)
fred.end_fill()
fred.goto(-900, -300)
fred.pencolor("green")
fred.write("To Mum and Dad", font=("Harlow Solid Italic", 24, "normal"))

fred.pencolor("blue")
fred.pensize(20)
fred.goto(-500, 0)
fred.write("Thank you for taking care of me!", font=("Harlow Solid Italic", 54, "normal" ))



















# data[].attributes.attachment_link.readable_text
#import modules
import turtle

#create window
loadWindow=turtle.Screen()
turtle.colormode(258)

#turn of draw mode
turtle.speed(0)

for i in range(40):
    turtle.circle(5*i)
    turtle.circle(-5*i)
    turtle.left(i)
    turtle.color("purple")

#wait for user to end
turtle.exitonclick()






    


# data[].attributes.body
Azrin

# data[].attributes.attachment_link.readable_text
import turtle
jhs=turtle.Pen()
jhs.shape("turtle")
jhs.color("cyan")

jhs.speed(10)
for i in range (40):
    jhs.forward(100)
    jhs.right(30)
    jhs.forward(20)
    jhs.left(60)
    jhs.forward(100)
    jhs.right(30)
    jhs.forward(20)
    jhs.left(60)

    jhs.setposition(0, 0)

    jhs.right(2)
    
turtle.done()

# data[].attributes.attachment_link.readable_text
import turtle
jk=turtle.Pen()
jk.shape("turtle")
jk.color("magenta")

jk.speed(10)
for i in range (120):
    jk.forward(120)
    jk.right(30)
    jk.forward(40)
    jk.left(30)
    jk.forward(120)
    jk.right(30)
    jk.forward(40)
    jk.left(30)
    
    jk.setposition(0, 0)
    
    jk.right(3)
    
turtle.done()

# data[].attributes.body
syuhada

# data[].attributes.attachment_link.readable_text
import turtle
colors=['green', 'blue', 'black', 'purple', 'red', 'orange']

t=turtle.Pen()
t.speed(0)
turtle.bgcolor('gray')
for x in range(320):
    t.pencolor(colors[x%6])
    t.width(x/100+2)
    t.forward(x)
    t.right(1234567)

# data[].attributes.body
turtle

# data[].attributes.attachment_link.readable_text
from turtle import *
colors = ['red', 'purple', 'blue', 'black', 'yellow', 'green']
for x in range(202):
    pencolor(colors[x % 6])
    width(x / 100 + 5)
    forward(x)
    left(99)

# data[].attributes.body
Dayangku Sofea

# data[].attributes.attachment_link.readable_text
def drawSpiral(how_far, how_much):
    if how_far > 0:
        turtle.forward(how_far)
        turtle.right(how_much)
        drawSpiral(how_far-5, how_much)
        
import turtle
turtle.reset()
turtle.pen(speed = 50)
turtle.delay(5)

length = 1000
turn_by = 500
turtle.penup()
turtle.pencolor("indigo")
turtle.pendown()

drawSpiral(length, turn_by)
    

# data[].attributes.body
adam ashraf

# data[].attributes.attachment_link.readable_text
import turtle
a=turtle.Screen()
a.bgcolor("azure")
b=turtle.Turtle()
b.shape("triangle")
b.pensize("3")
b.color("pink","white")
b.write("     Hi, mom and dad")
b.forward(100)
b.left(72)
b.forward(100)
b.right(144)
b.write('Love you')
b.forward(100)
b.left(72)
b.write('     I love you forever ')
b.forward(100)
b.right(144)
b.forward(100)
b.left(72)
b.forward(100)
b.right(144)
b.forward(100)
b.left(72)
b.forward(100)
b.write('        I miss you ')
b.right(144)
b.forward(100)
b.left(72)
b.forward(100)
b.right(144)

    

# data[].attributes.body
Tukarkan nombor satu digit 1 hingga 7
yang dimasukkan pengguna kepada hari,Nombor 1
mewakili Isnin, 2 mewakili Selasa dan
seterusnya.

# data[].attributes.body
Tulis kod aturcara untuk masalah di bawah
Gunakan struktur pilihan bersarang (nested if)
Meminta pengguna memasukkan umur dan tinggi(cm)

Syarat pertama:
Calon yang diterima hanya berumur 25 tahun
ke atas

Syarat kedua:
Kemudian tentukan tinggi yang dibenarkan
iaitu melebihi 150cm

# data[].attributes.body
Given the formula for BMI
BMI=berat/(tinggi*tinggi)

Underweight: BMI is less than 18.5
Normal    : BMI is 18.5 to 24.9
Overweight : BMI is 25 to 29.9
Obese    : BMI is 30 or More

Output application:

Masukkan berat : 80
Masukkan tinggi: 1.62

BMI anda ialah 30.48
Keputusan: Obese

# data[].attributes.body
Masukkan nombor pertama : 12
Masukkan nombor kedua : 10

12>10

Masukkan nombor pertama : 10
Masukkan nombor kedua : 10

10=10

Masukkan nombor pertama : 5
Masukkan nombor kedua : 10

5<10