From 4ee01676863c3ca411ea11fdf0c2840cb2e1f115 Mon Sep 17 00:00:00 2001 From: mbhatti4 Date: Sun, 7 Sep 2025 17:43:20 -0400 Subject: [PATCH] Greeting and circle area In the greetings code, I added in the input line so when the code is ran, it asks the user for their name. I then assigned the input to a variable so it can print out the input at the end For the circle lab, i created a variable "pi" to assign the value of 3.14159265359 to it. I then created a variable to make a math sentence to compute the radius with the given radius. Checkpoint 1: A name is a varaible, and it refers to something. It is the label of the value. The value is the actual data that is stored in the name. -> name = value An everyday example of name and value would be in math where you can variables that represent certain values. For example, in the area formula of a triangle, the varaible b represents the name "base". The value of the is whatever the base of the triangle is. Variables can be useful in programming, rather than just using the value itself, because it will help keep your codes less repatiative. You could create a varaible and use the name of it in later lines with more ease. It overall would make the code less repatitve. Variables are also useful because you can change and reassign the value to the name. If at an earliar line you assign some value to a name, you can later alter that value by reassigning that name to carry out the rest of the program. --- circle_area.py | 6 ++++++ greetings.py | 2 +- poetry.lock | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 poetry.lock diff --git a/circle_area.py b/circle_area.py index 513d6f7..e6f2b26 100644 --- a/circle_area.py +++ b/circle_area.py @@ -4,3 +4,9 @@ print("This program will calculate the area of a circle.") radius = float(input("What is the circle's radius? ")) +pi = 3.14159265359 + +area = pi * (radius * radius) + +print(area) + diff --git a/greetings.py b/greetings.py index 2d878a6..bd544b0 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/poetry.lock b/poetry.lock new file mode 100644 index 0000000..7e72dc6 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. +package = [] + +[metadata] +lock-version = "2.1" +python-versions = ">=3.10,<4.0" +content-hash = "7b8fc01b274bd807fb00372bbc8e138330f15ae7978ed61e180f3b17ec076725"