Saturday, January 14, 2023

My_Avocado

 

Finally, the definitive approach to deciding whether an avocado is ready

to eat. From CNN:

https://www.cnn.com/videos/health/2023/01/13/picking-a-ripe-avocado-explainer-lbb-orig.cnn

                                            *     *     *

Working on, with the Leaves problem. Got random working this morning:

                                                                     




The tirck here is to get my choices in a python list (within square brackets). 

I then call random.choice().






                                                                     


Friday, January 13, 2023

T_Shape

 Been playing with turtle shape to stamp a leaf form. Works well enough;

one needs to register the new shape with the screen. Only problem, that shape will always

be right side up ie will not bend to show a new heading...

                                                            


from turtle import*
import turtle
import time

screen = Screen()
turtle = Turtle()
screen.register_shape('T_Leaf.gif')
turtle.shape('T_Leaf.gif')
turtle.pensize(3)

def draw():
turtle.pu()
turtle.forward(100)
turtle.stamp()
turtle.left(30)
turtle.forward(100)
turtle.stamp()
time.sleep(.5)
turtle.left(90)
turtle.forward(140)

draw()
done()

                                                               *     *     *


                                                                         



from turtle import*
import turtle
import time

screen = Screen()
turtle = Turtle()
#Shapes should be registered on the screen
screen.register_shape('T_Leaf.gif')
screen.register_shape('R_Lean.gif')
screen.register_shape('L_Lean.gif')

# Brown tree
turtle.pensize(10)
turtle.color('brown')
turtle.pu()
turtle.goto(0, -140)
turtle.pd()
turtle.setheading(90)
turtle.forward(100)
turtle.right(40)
turtle.forward(40)
turtle.backward(40)
turtle.goto(0,0)

# One needs to add sleep time to get all images
def draw():
turtle.pu()
turtle.goto(20, 0)
turtle.shape('R_Lean.gif')
turtle.setheading(40)
turtle.forward(20)
turtle.stamp()
turtle.shape('T_Leaf.gif')
turtle.left(120)
turtle.forward(40)
turtle.stamp()
time.sleep(.5)
turtle.shape('L_Lean.gif')
turtle.left(95)
turtle.forward(100)

# Calling draw and keeping the window open
draw()
done()


Thursday, January 12, 2023

Leaf

 This appears to be the basic model for drawing curved shapes with

turtle. We are, effectively, defining mathematical functions.

from turtle import*

Screen().bgcolor('LightYellow2')
my_t = Turtle()
my_t.color('green')
my_t.speed(1)
my_t.pu()
my_t.goto(0, -100)
my_t.pd()

def draw_leaf():
my_t.begin_fill()
for i in range(50):
my_t.forward(1)
my_t.left(1)

for j in range(75):
my_t.forward(2)
my_t.left(1)


while my_t.xcor() >= 0:
my_t.forward(3)
my_t.left(1)
my_t.end_fill()

draw_leaf()
done()

                                                                                  


*     *     *

from turtle import*

# set up for two turtles that will be drawing the actual leaf.
Screen().bgcolor('LightYellow2')
my_t = Turtle()
my_t.color('green')
my_t.fillcolor('pale green')
my_t.speed(1)
my_t.pu()
my_t.goto(0, -100)
my_t.pd()

my_t2 = Turtle()
my_t2.color('green')
my_t2.fillcolor('pale green')
my_t2.speed(1)
my_t2.pu()
my_t2.goto(0, -100)
my_t2.setheading(180)
my_t2.pd()

# right side of leaf
def draw_leaf1():
my_t.begin_fill()
for i in range(50):
my_t.forward(1)
my_t.left(1)

for j in range(75):
my_t.forward(2)
my_t.left(1)


while my_t.xcor() >= 0:
my_t.forward(3)
my_t.left(1)
my_t.end_fill()

# left side of leaf
def draw_leaf2():
my_t2.begin_fill()
for i in range(50):
my_t2.forward(1)
my_t2.right(1)

for j in range(75):
my_t2.forward(2)
my_t2.right(1)

while my_t2.xcor() <= 0:
my_t2.forward(3)
my_t2.right(1)
my_t2.end_fill()

# grey line.. need to define T3 within function so that it will be on top.
def draw_leaf3():
global my_t3
my_t3 = Turtle()
my_t3.color('grey68')
my_t3.pensize(3)
my_t3.pu()
my_t3.goto(0, -125)
my_t3.setheading(90)
my_t3.pd()
my_t3.forward(232)

#function calls, hide the turtle, keep the window open

draw_leaf1()
draw_leaf2()
draw_leaf3()
my_t.hideturtle()
my_t2.hideturtle()
my_t3.hideturtle()
done()

                                                                                 

Inflation(US_Dec)

 The US inflation story:

December Inflation Report to Show Whether Price Increases Continued to Moderate - WSJ

US CPI Soared 6.5% in December, Matching the Estimate (businessinsider.com)


                                             *     *     *

It's a long interview and I'm still working my way through it; but the message

about variety of veg seems right. The book is "Spoon Fed".


Wednesday, January 11, 2023

Cali_Floods

 Can't catch a break, California. Five storms down in the last two weeks, four 

to go in the next ten days.

https://www.cnn.com/2023/01/11/weather/california-flooding-atmospheric-river-wednesday/index.html


But then, things are looking better with respect to reservoir levels. Might well be

back to normal once all this is over!!

https://youtu.be/_ZYTKxH9Wlc


                                                        *     *     *

Trying various approaches:

                                                                               



from turtle import*

my_t = Turtle()
my_t.color('green')
my_t.speed(1)

def make_Shape(numSides):
my_t.begin_fill()
for i in range(numSides):

my_t.forward(100)
my_t.left(360.0/numSides)
my_t.end_fill()

numSides = input("How many would you like? ")

make_Shape(int(numSides))

done()

Tuesday, January 10, 2023

Flooded

 Today, looking at drawing a curve. One sees, below, a succession

of turn, advance commands is doing the job for a circular curve

at the top of the heart figure.

                                                   




                                              *     *     *

Montecito California is currently under evacuation order. Below, flood watch:


                                                    





                                                                              


                                                                                 *     *     *

Lyse had the good idea of getting me for Christmas, an oriental cookbook.

Because - left to my own devices, and web recipes - I was making all kinds

of weird things. 


The book is from the For Dummies series, and just right to ease into a different way

of eating.


I started with an Iranian rice dish, with raisins, chickpeas, butter, and saffron. I didn't

have saffron; have never seen it anywhere I shop, so I used a bit of chicken stock and

Oregano. Turned out tasting just fine. An unsusal combination from what I am used to,

but interesting...I had cranberries rather than raisins, and ate a leftover portion with

turkey and veg.





Monday, January 9, 2023

Learner_Code

 I'm at it again: taking inspiration from eisting code in trying to

develop new things. I've been looking for a cute tree done with turtle

but all I can find is all-too-clever fractal figures. So I.ve been tryibg

to develop a simple tree shape with nice leaves.Something of a 

challenge, it turns out. Real leavea look the way they do because they

have three dimensions. A two-dimensional leaf is a methematical puzzle.


Long story short, I am trying to adapt  Christmas tree codde go do the job.

                                                            


https://pythondex.com/draw-christmas-tree-in-python

from turtle import *
speed(0)
# Tree Trunk
penup()
goto(-10, -200)
pendown()
color("brown")
begin_fill()
for i in range(2):
forward(20)
right(90)
forward(20)
right(90)
end_fill()

# Set the start position and the inital tree width
y = -200
width = 16
height = 25
#Green section 1
while width <=240 :
width = width + 32 # Make the tree get smaller as it goes up in height
x = 0 - width / 2 # Set the starting x-value of each level of the tree
color("green")
penup()
goto(x, y)
pendown()
begin_fill()
for i in range(2):
forward(width)
left(90)
forward(height)
left(90)
end_fill()

y = y + height # Keep drawing the levels of the tree higher than the previous

# Green section 2
while width > 20:
width = width - 32 # Make the tree get smaller as it goes up in height
x = 0 - width / 2 # Set the starting x-value of each level of the tree
color("green")
penup()
goto(x, y)
pendown()
begin_fill()
for i in range(2):
forward(width)
left(90)
forward(height)
left(90)
end_fill()

y = y + height # Keep drawing the levels of the tree higher than the previous

hideturtle()
done()