generated from mwc/lab_names
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.
This commit is contained in:
@@ -4,3 +4,9 @@
|
|||||||
|
|
||||||
print("This program will calculate the area of a circle.")
|
print("This program will calculate the area of a circle.")
|
||||||
radius = float(input("What is the circle's radius? "))
|
radius = float(input("What is the circle's radius? "))
|
||||||
|
pi = 3.14159265359
|
||||||
|
|
||||||
|
area = pi * (radius * radius)
|
||||||
|
|
||||||
|
print(area)
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
# ------------
|
# ------------
|
||||||
# By MWC contributors
|
# By MWC contributors
|
||||||
|
|
||||||
my_name ="Chris"
|
my_name = input("What is your name? ")
|
||||||
greeting = "Hello, " + my_name
|
greeting = "Hello, " + my_name
|
||||||
print(greeting)
|
print(greeting)
|
||||||
|
|||||||
7
poetry.lock
generated
Normal file
7
poetry.lock
generated
Normal file
@@ -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"
|
||||||
Reference in New Issue
Block a user