I chnaged and wrote new codes for finding circle area and shapes drawing.

A value is a data that the variable stores like 1 or "hello".A name is a label that shows the value.
A situation where its important to distiguish between a name and a value is when buying a drink. The name on the juice tells you ehat type of frink it is and the value is the juice inside the bottle.
Its important to use variables in programming because it makes it easier to read and understand the code that is being written. If you just write the value without labeling it, it won't be possible to know what the value stands for if you have more than one.

 A function is like a variable because both store something in them like a block of code or a value.
 A function helps to solve a problem in smaller section separetely rather then doing a big problem together.
 For example, instead of drawing both the triangle and rectangle in one function we did in two separately function to make is simplier to do.
This commit is contained in:
juddin2
2025-09-07 21:23:00 -04:00
parent 4e6a52196b
commit a5c50ab9d5
4 changed files with 24 additions and 10 deletions

View File

@@ -4,3 +4,6 @@
print("This program will calculate the area of a circle.")
radius = float(input("What is the circle's radius? "))
pi=3.14
circle_area=pi*radius*radius
print(circle_area)

View File

@@ -7,17 +7,17 @@ from shapes import triangle, rectangle
def flyto(x, y):
penup()
goto(x, y)
goto(x,y)
pendown()
flyto(-100, 0)
triangle(40)
triangle(60)
triangle(80)
flyto(100, 0)
triangle(90)
triangle(100)
triangle(90)
triangle(100)
flyto(100, 0)
rectangle(10, 90)
rectangle(20, 80)
rectangle(50, 80)
rectangle(30, 70)
rectangle(40, 60)
rectangle(50, 50)

View File

@@ -2,6 +2,6 @@
# ------------
# By MWC contributors
my_name ="Chris"
my_name = input("What is your name?")
greeting = "Hello, " + my_name
print(greeting)

View File

@@ -5,7 +5,18 @@
from turtle import *
def triangle(side_length):
pass
forward(side_length)
left(120)
forward(side_length)
left(120)
forward(side_length)
left(120)
def rectangle(height, width):
pass
forward(width)
left(90)
forward(height)
left(90)
forward(width)
left(90)
forward(height)
left(90)