Skip to main content

Posts

Showing posts from July, 2026

Turtle Race on Python

Still on Day 46 Turtle Race Code: from turtle import Turtle, Screen import random screen = Screen() screen.setup( width = 500 , height = 400 ) start = False user_bet = screen.textinput( title = "Make Your Bet" , prompt = "Which turtle will win the race? Enter a color: " ) colors = [ "red" , "orange" , "yellow" , "green" , "blue" , "purple" ] all_turtles = [] for color in colors: maddy = Turtle( shape = "turtle" ) maddy.color(color) maddy.penup() maddy.goto(- 240 , - 100 + colors.index(color) * 40 ) all_turtles.append(maddy) if user_bet: start = True while start: for turtle in all_turtles: if turtle.xcor() > 240 : start = False winning_turtle = turtle.pencolor() if winning_turtle == user_bet: print ( f"You've won! The { winning_turtle } turtle is the winner!" ) else : ...

Etch-A-Sketch on Python

Turtle Event Listener # W = Forwards # S = Backwards # A = Counter-Clockwise / Left # D = Clockwise / Right # C = Clear drawing and put the Turtle back in the center from turtle import Turtle, Screen maddy = Turtle() screen = Screen() def move_forward (): maddy.forward( 10 ) def move_backward (): maddy.backward( 10 ) def turn_left (): maddy.left( 10 ) def turn_right (): maddy.right( 10 ) screen.listen() screen.onkey(move_forward, "w" ) screen.onkey(move_backward, "s" ) screen.onkey(move_left, "a" ) screen.onkey(move_right, "d" ) screen.onkey(maddy.reset, "c" ) screen.exitonclick() On Day 46 I really looked forward to working on this. It was fun all the way :)

Hirst Painting Project

  Drawing dots with the python turtle module: import random from turtle import Turtle, Screen, colormode color_list = [( 216 , 103 , 19 ), ( 67 , 171 , 214 ), ( 231 , 167 , 72 ), ( 200 , 122 , 181 ), ( 23 , 11 , 6 ), ( 251 , 141 , 158 ), ( 213 , 98 , 71 ), ( 245 , 193 , 65 ), ( 183 , 135 , 53 ), ( 5 , 19 , 31 ), ( 18 , 6 , 11 ), ( 247 , 164 , 142 ), ( 58 , 106 , 129 ), ( 122 , 161 , 143 ), ( 5 , 10 , 7 ), ( 117 , 80 , 101 ), ( 90 , 67 , 27 ), ( 191 , 97 , 119 ), ( 81 , 145 , 168 ), ( 92 , 52 , 43 ), ( 162 , 204 , 211 ), ( 97 , 42 , 72 ), ( 29 , 74 , 92 ), ( 90 , 158 , 150 ), ( 76 , 100 , 88 ), ( 43 , 63 , 92 ), ( 170 , 204 , 202 ), ( 123 , 117 , 151 ), ( 48 , 71 , 69 )] maddy = Turtle() maddy.speed( 0 ) maddy.penup() maddy.setpos(- 200 , - 200 ) colormode( 255 ) def dot_row (): for i in range ( 10 ): maddy.color(random.choice(color_list)) maddy.dot( 20 ) maddy.forward( 50 ) def move_up...

Extracting Colors from Images in Python using the colorgram.py module

Day 45 My Code: import colorgram colors = colorgram.extract( "image.jpg" , 1000 ) color_list = [] for _ in range ( len (colors)): color_list.append(colors[_].rgb) print (color_list) Output: [Rgb(r=250, g=234, b=220), Rgb(r=216, g=103, b=19), Rgb(r=67, g=171, b=214), Rgb(r=231, g=167, b=72), Rgb(r=200, g=122, b=181), Rgb(r=23, g=11, b=6), Rgb(r=251, g=141, b=158), Rgb(r=213, g=98, b=71), Rgb(r=252, g=238, b=243), Rgb(r=245, g=193, b=65), Rgb(r=249, g=252, b=251), Rgb(r=183, g=135, b=53), Rgb(r=5, g=19, b=31), Rgb(r=18, g=6, b=11), Rgb(r=247, g=164, b=142), Rgb(r=235, g=245, b=247), Rgb(r=58, g=106, b=129), Rgb(r=122, g=161, b=143), Rgb(r=5, g=10, b=7), Rgb(r=117, g=80, b=101), Rgb(r=90, g=67, b=27), Rgb(r=191, g=97, b=119), Rgb(r=81, g=145, b=168), Rgb(r=92, g=52, b=43), Rgb(r=162, g=204, b=211), Rgb(r=97, g=42, b=72), Rgb(r=29, g=74, b=92), Rgb(r=90, g=158, b=150), Rgb(r=76, g=100, b=88), Rgb(r=43, g=63, b=92), Rgb(r=170, g=204, b=202), Rgb(r=123, g=117, b=151), Rgb(r=48,...

Some Exercises on Python Turtle Module

Day 44 Drawing dotted lines using the turtle module: from turtle import Turtle, Screen maddy = Turtle() maddy.shape( "turtle" ) maddy.color( "green" ) maddy.pencolor( "black" ) for i in range ( 50 ): maddy.forward( 3.5 ) maddy.penup() maddy.forward( 3.5 ) maddy.pendown() screen = Screen() screen.exitonclick() Drawing shapes: from turtle import Turtle, Screen import random colors = [ "red" , "green" , "blue" , "yellow" , "cyan" , "magenta" , "orange" , "violet" , "brown" , "black" ] maddy = Turtle() maddy.shape( "turtle" ) maddy.color( "green" ) draw = True sides = 2 while draw: maddy.pencolor(random.choice(colors)) if sides <= 10 : sides += 1 for i in range (sides): maddy.forward( 70 ) maddy.right( 360 / sides) else : draw = False screen = Screen() screen.exito...

PYTHON TURTLE CHALLENGE

On day 43 of the 365 days of code, I am still on the turtle documentation. Using turtle to draw a square: from turtle import Turtle, Screen maddy = Turtle() maddy.shape( "turtle" ) maddy.color( "blue" ) for i in range ( 4 ): maddy.forward( 100 ) maddy.left( 90 ) screen = Screen() screen.exitonclick()  

I'M BACK - DAY 42

I'm back.  I'm back.  I'm back. After a not so long break and some soul searching, I'm back on my Python journey. Today we'll be learning about the turtle documentation. I've tried going through documentations before (even Pytorch's ) but could not really understand them. Maybe I did not try enough or maybe I just lacked experience. It is the later. I do lack experience. :) I am quite excited for today's class.

A JILL OF ALL TRADES

I guess our ancestors we're right, although I don't really want to admit it. I like to disagree with stuff like this. It's hard to accept defeat sometimes. These days I've been struggling with having a lot of interests. I think I always have. So many things to do. So many things I want to do. So many things I wish I could do. It's a plus one whenever I see something I like. I proceed to wish I could do it and most times actually add it to my learning list. Out of my learning list is the priority list. There was definitely a time I decided to focus on just one thing (i.e., Python) till I mastered it. It sounds easy because why would somebody want to learn a couple of things when they could just stick with one. It's less work to do. I have always struggled to stick to one hobby or activity or whatever. I have too many interests making it difficult. I did fail to stick it out till the end with my new companion Python. One was just not enough. I wanted more. And why...

Figuring out what the "학교 독서교육 활성화 방안" is all about

I cannot view .hwpx files on my PC, so I made use of vertopal.com The Korean Ministry of Education provided 2 files . I will be going through these files to get the message and kickstart my daily 10 minutes Korean Reading Practice. I read about 2.5 pages today, although the font size was 14, it is something. I got compelled to keep on reading. At least finish the remaining 2 paragraphs under the current subheading I thought. I could do it but I did not.  태스트 파학해야돼서

365 DAYS OF CODE - DAY 40

  Watched this video and was thinking of what path to branch into. I would have loved web dev but Machine Learning is calling to me. Tensorflow vs Pytorch?? I will start with Pytorch. How about my Udemy course?? I will keep on taking it. So help me God.

365 DAYS OF CODE - DAY 39

Still working on projects from pynative.com Progress so far (17) TODO .17 Full-Time vs Part-Time Employee Pay Logic class Employee: def __init__ ( self , name): self .name = name class FullTimeEmployee(Employee): def __init__ ( self , name, salary): super (). __init__ (name) self .salary = salary monthly_pay = self .salary / 12 print ( f" { self .name } 's monthly pay: { monthly_pay } " ) class PartTimeEmployee(Employee): def __init__ ( self , name, salary, hours): super (). __init__ (name) self .salary = salary self .hours = hours monthly_pay = self .salary * self .hours print ( f" { self .name } 's monthly pay: { monthly_pay } " ) FullTimeEmployee( "Alice" , 60000 ) PartTimeEmployee( "Bob" , 500 , 20 )  

365 DAYS OF CODE - DAY 38

Still working on projects from pynative.com Progress so far (15 & 16) TODO .15 Add Maintenance Fee in Child Class via super () class Vehicle: def __init__ ( self , base_fare): self .base = base_fare class Taxi(Vehicle): def __init__ ( self , base_fare, input ): super (). __init__ (base_fare) self .maintenance = base_fare + ( 0.1 * base_fare) print ( f"Total fare with maintenance fee: { self .maintenance } " ) taxi = Taxi( 500 ) taxi.base TODO .16 Polymorphism with Dog & Cat speak() class Animal: def __init__ ( self , name, sound): self .name = name self .sound = sound def speak ( self ): print ( f" { self .name } says: { self .sound } !" ) class Dog(Animal): # def __init__(self, name, sound): # super().__init__(name, sound) # self.sound = "Woof" pass class Cat(Animal): # def __init__(self, name, sound): # super().__init__(name, sound) #...

365 DAYS OF CODE - DAY 37

Still working on projects from pynative.com Progress so far (8 - 12) TODO .8 . User Class with Password Validation class User: def __init__ ( self , username, password): self .username = username self .password = password def check_password ( self , input_password): if input_password == self .password: return True else : return False user = User( "Alice" , "secure123" ) print (user.check_password( "secure123" )) print (user.check_password( "password" )) TODO .9 . Temperature Class with Unit Converters class Temperature: def __init__ ( self , temp): self .temp = temp print ( f"Celsius: { self .temp } " ) def to_fahrenheit ( self , temp ): print ( f"Fahrenheit: { ( self .temp * 1.8 ) + 32 } " ) def to_kelvin ( self , temp ): print ( f"Kelvin: { ( self .temp + 273.15 ) } " ) temperature = Temperature( 100 ) temper...

365 DAYS OF CODE - DAY 36

Trying out project from pynative.com Thank you GOA :) Progress so far (1 - 6) TODO .1 . Define an Empty Vehicle Class class Vehicle: pass print ( type (Vehicle())) TODO .2 . Vehicle Class with Instance Attributes class Vehicle: def __init__ ( self , max_speed, mileage): self .speed = max_speed self .mileage = mileage model1 = Vehicle( 500 , 1300 ) print (model1.speed) print (model1.mileage) TODO .3 . Rectangle Class with Area & Perimeter class Rectangle: def __init__ ( self , length, width): self .length = length self .width = width def area ( self ): return self .length * self .width def perimeter ( self ): return 2 *( self .length + self .width) rectangle1 = Rectangle( 1 , 2 ) print (rectangle1.area()) print (rectangle1.perimeter()) TODO .4 . Student Class with Average Grade class Student: def __init__ ( self , name, marks): self .name = name self .marks = marks def average ( self ): ...

365 DAYS OF CODE - DAY 32

Use the dot (.) notation to create attributes for an object.  An attribute is a variable that is associated with an object. We looked at initializing attributes in a class with the init function, and creating methods.