Enjoy coding for illustrate Human Health Passport by Karel, mental capacity from Human Health Passport and Graphical animation for short breathing exercises!
I would like to presents my first work in coding. https://codeinplace.stanford.edu/cip4/share/T0LPepIHsSrSLu3PcGZa for Karel's field
from karel.stanfordkarel import *
"""Long healthy life Karel. Karel's life is demonsrates
the moves and possibilities, creative fun work
in one interesting world. Karel can draw these levels
and to put point beeper signs for knowledge of each health level
in accordance with functional capabilities, good rehabilitation
and treatment, daily physical and cognitive activity,
well-being and physical training. 1. https://doi.org/10.47855/jal9020-2023-3-3
2. https://doi.org/10.47855/jal9020-2022-1-3 """
def main():
birth_growth_education()
blue_sky()
wheat_field()
rest()
health_level()
red()
orange()
yellow()
lime()
green()
"""Karel is studying. """
def birth_growth_education():
turn_left()
move_to_wall()
turn_right()
"""Karel is painting or flying in the sky."""
def blue_sky():
while front_is_clear():
paint_corner("DeepSkyBlue")
move()
paint_corner("DeepSkyBlue")
turn_right()
move()
turn_right()
while front_is_clear():
paint_corner("LightSkyBlue")
move()
paint_corner("LightSkyBlue")
turn_left()
move()
turn_left()
while front_is_clear():
paint_corner("PowderBlue")
move()
paint_corner("PowderBlue")
turn_right()
move()
turn_right()
while front_is_clear():
paint_corner("PaleTurquoise")
move()
paint_corner("PaleTurquoise")
turn_left()
move()
turn_left()
while front_is_clear():
paint_corner("LightCyan")
move()
paint_corner("LightCyan")
"""Karel plants wheat or a garden in the field."""
def wheat_field():
turn_right()
move()
turn_right()
while front_is_clear():
paint_corner("LightYellow")
move()
paint_corner("LightYellow")
turn_left()
move()
turn_left()
while front_is_clear():
paint_corner("LemonChiffon")
move()
paint_corner("LemonChiffon")
turn_right()
move()
turn_right()
while front_is_clear():
paint_corner("LightGoldenrodYellow")
move()
paint_corner("LightGoldenrodYellow")
turn_left()
move()
turn_left()
while front_is_clear():
paint_corner("PaleGoldenrod")
move()
paint_corner("PaleGoldenrod")
turn_right()
move()
turn_right()
while front_is_clear():
paint_corner("Gold")
move()
paint_corner("Gold")
"""Karel rests in order to reach new horizons over and over."""
def rest():
turn_right()
if corner_color_is("LightCyan"):
turn_left()
else:
for i in range(5):
move()
turn_right()
for i in range(5):
move()
"""Karel knows the secrets of determining and improving
health with age by his example."""
def health_level():
paint_corner("green")
move()
paint_corner("lime")
move()
paint_corner("yellow")
move()
paint_corner("orange")
move()
paint_corner("red")
turn_right()
"""Karel is need medical and social help, passive moving
in this health level"""
def red():
move()
put_beeper()
turn_right()
"""Karel is need the active rehabilitation and diagnosis of your
health, light physical activity in this health level"""
def orange():
move()
paint_corner("orange")
put_beeper()
move()
"""Kare is need to pay especially attention to physical activity,
deep breathing exercises and detail consultation by physician
in this health level"""
def yellow():
turn_left()
turn_right()
paint_corner("yellow")
put_beeper()
move()
"""Karel is need to harmonize the optimal relationship between rest
and work, physical training and deep breathing exercises in
this health level"""
def lime():
turn_left()
for i in range(4):
move()
turn_right()
turn_right()
for i in range(4):
move()
paint_corner("lime")
put_beeper()
turn_left()
"""Healthy, physical and deep breathing training in
this health level"""
def green():
move_to_wall()
turn_arround()
while no_beepers_present():
move()
turn_right()
turn_right()
move()
put_beeper()
paint_corner("green")
turn_arround()
def move_to_wall():
while front_is_clear():
move()
def turn_right():
for i in range(3):
turn_left()
def turn_arround():
for i in range(2):
turn_left()
# don't change this code
if __name__ == '__main__':
main()
https://codeinplace.stanford.edu/cip4/share/jzqrULRxJAwNtEp3j5n9 for console field
import random
CHOICE = [0, 1, 2, 3, 4, 5, 6, 7]
def item1(num3, sample1):
if num3 in sample1:
return 0.0
elif num3 == 8:
return 0.0
elif num3 == 9:
return 0.0
else:
return 0.25
def item2(num4, sample2):
if num4 in sample2:
return 0.0
elif num4 == 8:
return 0.0
elif num4 == 9:
return 0.0
else:
return 0.25
def item3(num5, sample3):
if num5 in sample3:
return 0.0
elif num5 == 8:
return 0.0
elif num5 == 9:
return 0.0
else:
return 0.25
def item4(num6, sample4):
if num6 in sample4:
return 0.0
elif num6 == 8:
return 0.0
elif num6 == 9:
return 0.0
else:
return 0.25
def main():
sample1 = random.sample(CHOICE, k=7)
print(sample1)
num3 = int(input("What number was missing in each series of seven-digit combinations from 0 to 7? Please enter a number: "))
result1 = item1(num3, sample1)
sample2 = random.sample(CHOICE, k=7)
print(sample2)
num4 = int(input("What number was missing in each series of seven-digit combinations from 0 to 7? Please enter a number: "))
result2 = item2(num4, sample2)
sample3 = random.sample(CHOICE, k=7)
print(sample3)
num5 = int(input("What number was missing in each series of seven-digit combinations from 0 to 7? Please enter a number: "))
result3 = item3(num5, sample3)
sample4 = random.sample(CHOICE, k=7)
print(sample4)
num6 = int(input("What number was missing in each series of seven-digit combinations from 0 to 7? Please enter a number: "))
result4 = item4(num6, sample4)
total_score = (result1 + result2 + result3 + result4) * 100
print("Your results of mental capacity:", total_score, "%!" )
if __name__ == "__main__":
main()
and graphical animation for short breathing exercises
https://codeinplace.stanford.edu/cip4/share/U1OYpVgN0gc5kv8zcUuK
from graphics import Canvas
RECTANGLE_SIZE = 200
CANVAS_WIDTH = 400
CANVAS_HEIGHT = 400
x = 400
y = 200
def main():
canvas = Canvas(CANVAS_WIDTH, CANVAS_HEIGHT)
# TODO: your code here!
rect1 = canvas.create_rectangle(0, 400, 400, 0, "#F3D3F5")
time.sleep(1)
obj1 = canvas.create_text(45, 25, text = 'Please perform breathing exercises', font = 'Arial', font_size = 20, color = 'blue')
time.sleep(2)
top_x = x / 4
top_y = 300
base_x = x / 4
base_y = 400
rect2 = canvas.create_rectangle(base_x, base_y, base_x + RECTANGLE_SIZE, base_y - RECTANGLE_SIZE, "#79DCFF")
time.sleep(2)
obj2 = canvas.create_text(5, 100, text = 'Your breathing movements must match the rhythm of the sky blue square fun animation!', font = 'Arial', font_size = 10, color ='blue')
time.sleep(4)
dx_top, dy_top = 0, -90
obj3 = canvas.create_text(100, 200, text = 'Please, deep inhalation', font = 'Arial', font_size = 15, color ='blue')
time.sleep(1)
for i in range(5):
canvas.change_text(obj3, new_text = 'Please, deep inhalation')
canvas.move(rect2, dx_top, dy_top)
time.sleep(5)
while canvas.get_top_y(rect2) < (CANVAS_WIDTH / 2 - RECTANGLE_SIZE / 2):
canvas.move(rect3, 1, 0)
time.sleep(5)
canvas.change_text(obj3, new_text = 'Please, deep exhalation')
canvas.moveto(rect2, base_x, base_y)
time.sleep(8)
canvas.set_color(rect1, "#A499E3")
time.sleep(2)
canvas.set_color(rect2, "#A499E3")
canvas.set_color(obj1, "#A499E3")
canvas.set_color(obj2, "A499E3")
canvas.change_text(obj3, "Thank's a lot for your good folowing!")
time.sleep(5)
canvas.change_text(obj3, "HAVE A GOOD HEALTH :)")
if __name__ == '__main__':
main()
I'm happy to see good job for beginner Python in Stanford: Code in Place 2024.

Comments
Post a Comment