I had to import math in order to determine the area. I then added the formula for the area of the circle, and defined pi.

Checkpoint 1:
A value is a number. For example, I gave pi a value of 3.14. A name is referencing a value. The name I gave the value 3.14 is pi.
One example I thought of is the name of students. The students do not have a numerical value, however it is important to distinguish who you may be talking to as a teacher to two students who have the same first name.

Variables store data in programming. It is helpful to use variables when you are using the same data more than once. It makes coding more efficient.

Checkpoint 2:
A function is like a variable because they can both be manipulated within a program. They can both also be stored within a program.

I teach an introductory course on Javascript. There are no prerequisites, so we use functions to breakdown code into smaller pieces, easing the anxiety for new coders. For example, we use functions when defining operations like sum, then identify what sum is, then use console.log to print the sum of two integers. We have also used int for user input to find the sum of two integers.
This commit is contained in:
Diana Panarello
2025-09-08 17:54:17 -04:00
parent a930aaaee1
commit 3a280698a2
2 changed files with 7 additions and 2 deletions

View File

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

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)