From a5c50ab9d516018cddc2e311c15f2f971b4e6f32 Mon Sep 17 00:00:00 2001 From: juddin2 Date: Sun, 7 Sep 2025 21:23:00 -0400 Subject: [PATCH] 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. --- circle_area.py | 3 +++ draw_with_shapes.py | 12 ++++++------ greetings.py | 2 +- shapes.py | 17 ++++++++++++++--- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/circle_area.py b/circle_area.py index 513d6f7..07ee054 100644 --- a/circle_area.py +++ b/circle_area.py @@ -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) diff --git a/draw_with_shapes.py b/draw_with_shapes.py index 38eb934..2d7754d 100644 --- a/draw_with_shapes.py +++ b/draw_with_shapes.py @@ -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) diff --git a/greetings.py b/greetings.py index 2d878a6..509bf48 100644 --- a/greetings.py +++ b/greetings.py @@ -2,6 +2,6 @@ # ------------ # By MWC contributors -my_name ="Chris" +my_name = input("What is your name?") greeting = "Hello, " + my_name print(greeting) diff --git a/shapes.py b/shapes.py index 731ec39..ee0d35f 100644 --- a/shapes.py +++ b/shapes.py @@ -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) \ No newline at end of file